Giter VIP home page Giter VIP logo

eureca.io's People

Contributors

alaa-eddine avatar gtarcea avatar mehcode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eureca.io's Issues

404 errors with c9.io

https://networktesting-lordkuragari.c9.io/
im getting this error in the console when i try to integrate the eureca.io into the tanks multiplayer tutorial

Cannot GET /eureca.io/?_primuscb=1422126090240-1&EIO=3&transport=polling&t=1422126090241-1&b64=1

im a novice web dev so i have no idea what this means

exmple of EurecaServer inheritence

I think the way you define the server's interface using the eurecaServer object is very nice. It looks conceptually extendable. I.e., it seems that it should be possible to add new functionality to a eurecaServer using deep prototype inheritance (need to deep copy properties such as 'exports' I guess).

is it possible?
can you add such example?

Thanks!

WebRTC problem

I have a problem with webrtc transport in eureca.io.
I installed on my VPS module wrtc.
My server.js:

var http = require('http');
var fs = require('fs');

var server = http.createServer();

var Eureca = require('eureca.io');

var eurecaServer = new Eureca.Server({transport:'webrtc', allow:['hello', 'sub']});

eurecaServer.attach(server);

//functions under "exports" namespace will
//be exposed to client side
eurecaServer.exports.hello = function () {
    var client = eurecaServer.getClient(this.connection.id);
    client.hello();
    console.log('Hello from client');
	return ('hello return');
}


eurecaServer.onConnect(function (conn) {
    
    console.log('new Client');
    var client = eurecaServer.getClient(conn.id);
    

    
    client.sub(10, 4).onReady(function (r) {
        console.log('> 10 - 4 = ', r);
    });
    
});




server.on('request', function (request, response) {
    var i;
    
    if (request.method === 'GET') {
        
        if (request.url.split('?')[0] === '/') {
            var filename = __dirname + '/index.html';
            fs.readFile(filename, function (err, data) {
                var text = data.toString();
                response.writeHead(200, { 'Content-Type': 'text/html' });
                response.write(text);
                response.end();
            });
        }
    }

});


console.log('\033[96mlistening on 8000 \033[39m');
server.listen(8000);

and client.html:

<!doctype html>
<html>
    <head>
        <title>Engine.io test</title>
        <script src="/eureca.js"></script>
    </head>
    <body>    
        <script>
            var client = new Eureca.Client({  uri: 'http://myip:8000', transport: 'webrtc', reliable: false, maxRetransmits:3, ordered:true});
            client.exports.hello = function () {
                console.log('hello from server');
            }
            client.exports.sub = function (a, b) {
                return a - b;
            }
            client.ready(function (proxy) {
                proxy.hello().onReady(function (r) {
                    console.log('returned ', r);
                });
            });
        </script>
    </body>
</html>

On server I see only:

* using webrtc
listening on 8000

On client:

* using webrtc
http://myip:8000 eureca.io

Where is the problem?

Browser-based client issues

I'm working on an application that uses a customized Go-based server to communicate with a Eureca.io client, and I've noticed some discrepancies between how the client behaves depending on whether it's run via node, or in a browser.

The following client code works fine when run using Node:

var Eureca = require('eureca.io');
var client = new Eureca.Client({
    uri: 'ws://localhost:6400',
    prefix: 'rpc',
    transport: 'websockets',
    autoConnect: true
});

but when I try to do the same thing in a browser, something weird starts to happen. It basically ignores the prefix and transport specified, and starts sending polling requests to http://localhost:6400/eureca.io/.

I started hacking together some fixes, but I can't help but feel that they're just band-aids over a fundamental piece of communication that's not working correctly. I got it to start using the right prefix by modifying the line...

if (typeof Primus != "undefined") Primus.prototype.pathname = "/eureca.io";

...and I got it to (kind of) start using websockets by changing the order of the transports in the "don't avoid websockets" case here:

transports: !primus.AVOID_WEBSOCKETS ? ['polling', 'websocket'] : ['polling']

That ends the polling attempts, but it doesn't seem like it's properly initiating the connection either.

These changes were made to the /eureca.js file generated by the Node server, which I just saved to a different location.

Any tips?

Inaccurate Documentation

i note in your documentation most notably here

That you use

eurecaServer.export.echo = function(msg) {
    console.log(msg)
}

in your code example however in other parts of your documentation you use

eurecaServer.exports.helloServer = function (userName) {
    console.log('Hello Server from ',userName);
}

I note that using "export" instead of "exports" yielded errors

Multiple Async callbacks

Hello, I like your rpc framework on top top primus.io. Awesome work! For now, I used in my project dnode rpc with shoe on top of sock.js. I would like to migrate to eureca.io but I need that a server can responed multiple chunks to the client before the async "context.return()" method is called. This would be a kind of streaming, like in dnode or grpc. I know, for this purpose, it is possible do define a stub on the client side, which the server can callback for progress information, but I don't like the coding overhead to associate these client and server functions to each other. A "context.progress()" function would be really nice! On the client side a proxy stub call would callback a progress function passed as third argument to the promise:
proxy.asyncServerHello().then( function(success) {}, function(error){}, function(progress){});

Best regards

Thomas

Use Promises?

I don't quite understand the reasoning behind choosing the onReady, this.context and context.async instead of handling async stuff with the standard Promise objects.

Most libraries nowadays would simply check if the return value of a rpc function call is an immediate value (so return it immediately) or if it is a Promise object (typeof result['then'] === 'function') and then wait on then() to return result (optionally also pass the result of catch forward it to client)?

Similar on client side, one should be able to write serverProxy.add(1,2).then(result=>{...}).catch(error=>{...})

Is there a reason for not adhering to standards?

Can't serve eureca.js on nginx & node.js

Hello Alaa, i'm having an issue, i need eureca.io to schedule jobs on the server side but my nodejs app can't seem to find eureca.js, i know the file its created at runtime but i'm having a hard time configuring my nodejs server to "serve" the eureca javascript file.

I have an nginx server running on port 8080 and my nodejs app running on port 8181 but the console says it can't find eureca.js, maybe i'm doing something wrong? Is it possible to have eureca.js served by a different port?

Thanks!

Request: -quiet option

There are a few places where Eureca logs to stdout. For some applications a -quiet option would be helpful for eliminating non-error messages. Having a logging level would be even better.

Thanks.

Calling client side functions

This is a great library but I am having issues with invoking client side functions and returning a value. My example is:

Client:
var fs = require('fs');
function ConfigReader(callback) {
fs.readFile('C:\directory\file.json', function(err, data) {
callback(data)
});
}

client.exports.Start = function(msg){
ConfigReader(function(data){
return data;
})
}

Server :

connection.client.Start(msg).onReady(function (resp) {
console.log(resp);
});

The problem is when I try to console.log the response from the client nothing is returned.

Once again I love how easy this is! I am just hung on this one issue.

Heroku compatibility issues - should I use strict or not?

Is it possible to use eureca.io with Heroku, Please help?
HEROKU LOCAL works ok, but there are various issues after uploading to herokuapp.com.

Should I use strict mode or not?

With strict mode "node --use_strict server.js"
heroku gives a few errors such as :
2018-05-29T14:20:35.035862+00:00 app[web.1]:
2018-05-29T14:20:35.035879+00:00 app[web.1]: > [email protected] start /app
2018-05-29T14:20:35.035881+00:00 app[web.1]: > node --use_strict server.js
2018-05-29T14:20:35.035882+00:00 app[web.1]:
2018-05-29T14:20:35.313839+00:00 app[web.1]: /app/node_modules/eureca.io/lib/Eur
ecaClient.js:37
2018-05-29T14:20:35.313884+00:00 app[web.1]: trigger(event, ...args) {
2018-05-29T14:20:35.313887+00:00 app[web.1]: ^^^
2018-05-29T14:20:35.313889+00:00 app[web.1]:
2018-05-29T14:20:35.313891+00:00 app[web.1]: SyntaxError: Unexpected token ...
2018-05-29T14:20:35.313893+00:00 app[web.1]: at exports.runInThisContext (vm

AND WITHOUT STRICT MODE it gave this error;

2018-05-29T14:15:07.302362+00:00 app[web.1]: class EObject {
2018-05-29T14:15:07.302364+00:00 app[web.1]: ^^^^^
2018-05-29T14:15:07.302365+00:00 app[web.1]:
2018-05-29T14:15:07.302367+00:00 app[web.1]: SyntaxError: Block-scoped declarati ons (let, const, function, class) not yet supported outside strict mode
2018-05-29T14:15:07.302369+00:00 app[web.1]: at exports.runInThisContext (vm .js:53:16) 2018-05-29T14:15:07.302371+00:00 app[web.1]: at Module._compile (module.js:3

Please see the PACKAGE.JSON below:
{
"name": "node-js-sample",
"version": "0.2.0",
"description": "A sample Node.js app using Express 4",
"main": "server.js",
"scripts": {
"start": "node server.js",
"start2": "node --use_strict server.js"
},
"dependencies": {
"engine.io": "^3.2.0",
"eureca.io": "^0.8.2",
"express": "^4.16.3",
"primus": "^7.2.1"
},
"engines": {
"node": "^4.0.0"
},
"repository": {
"type": "git",
"url": "x"
},
"keywords": [
"node",
"heroku",
"express"
],
"author": "nn",
"contributors": [
"nn"
],
"license": "MIT"
}

SERVER.JS
'use strict'
var express = require('express')
, app = express(app)
, server = require('http').createServer(app);
// serve static files from the current directory
app.use(express.static(__dirname));
var port = process.env.PORT || 80;
var Eureca = require('eureca.io');
and so on..

Strange issue when calling client methods from server

Hi,

I've got a strange kind of problem here, and I don't really know how to debug this.

The situation is like this: My node application is part server, part proxy - it serves some files on its own, but for some things, it has to make a call to another server. Now, since http(s) calls from node are asynchronous, I had to do some crazy twice-asynchronous stuff.

The eureca client exports a resolve and a reject function, the server exports several functions. Basically, in most cases, this happens:

  1. Client calls server function
  2. Server calls to http, saves the promise (let's call it httpPromise)
  3. Server returns randomly generated function call id
  4. Client saves a promise (functionPromise), identified by the function call id
  5. httpPromise gets resolved, calls either client.resolve or client.reject with function call id and the result
  6. Client resolves/rejects functionPromise

Most of the time, this works. for one of the exposed server methods, though, this only works the first time after the node script starts - after that, my script still gets to the client.resolve call (I checked that), but the call is never sent over the websocket. All other server methods still work, even with repeated calls.

Do you have any idea what could be responsible for this, or how I could debug this case further?

'connectionRetry' was not trigger

hi @alaa-eddine

I am trying 001-http-server examples, 'connectionRetry' was not trigger.

client code

var Eureca = require('eureca.io');

var client = new Eureca.Client({ uri: 'ws://localhost:8000/' , timeout:1000, pingTimeout:1000});

client.onError((e) => {
    console.error('an error raise: ', e)
  })
  
  client.onConnect((conn) => {
    console.log('new Client', conn)
  })
  client.onMessage((msg) => {
    console.log('recv msg: ', msg)
  })
  client.onDisconnect((conn) => {
    console.log('Client disconnect', conn)
  })
  
  client.onConnectionLost((conn) => {
    console.log('connection lost', conn)
  })
  
  client.onConnectionRetry((conn) => {
    console.log('connection retrying', conn)
  })
  
client.ready(function (proxy) {

    proxy.hello();

});

server code:

var http = require('http');
var fs = require('fs');

var server = http.createServer();

var Eureca = require('eureca.io');

var eurecaServer = new Eureca.Server();

eurecaServer.attach(server);

//functions under "exports" namespace will
//be exposed to client side
eurecaServer.exports.hello = function () {
    
    console.log('Hello from client');
}


server.on('request', function (request, response) {
    var i;
    
    if (request.method === 'GET') {
        
        if (request.url.split('?')[0] === '/') {
            var filename = __dirname + '/index.html';
            fs.readFile(filename, function (err, data) {
                var text = data.toString();
                response.writeHead(200, { 'Content-Type': 'text/html' });
                response.write(text);
                response.end();
            });
        }
    }

});



console.log('\033[96mlistening on localhost:8000 \033[39m');
server.listen(8000);

server out:

eureca.io v0.8.1
listening on localhost:8000
Hello from client

client out:

eureca.io v0.8.1
ws://localhost:8000/ eureca.io
new Client Socket {
  socket:
   Primus {
     _events:
      { 'outgoing::open': [Array],
        'incoming::open': [Function: opened],
        'incoming::ping': [Function: ping],
        'incoming::error': [Function: error],
        'incoming::data': [Function: message],
        'incoming::end': [Function: end],
        'outgoing::data': [Function: write],
        'outgoing::reconnect': [Function: reconnect],
        'outgoing::end': [Function: close],
        open: [Array],
        data: [Function],
        end: [Array],
        error: [Array],
        reconnecting: [Function] },
     _eventsCount: 14,
     _maxListeners: undefined,
     buffer: [],
     writable: true,
     readable: true,
     url:
      { slashes: true,
        protocol: 'ws:',
        hash: '',
        query: '',
        pathname: '/',
        auth: '',
        host: 'localhost:8000',
        port: '8000',
        hostname: 'localhost',
        password: '',
        username: '',
        origin: 'ws://localhost:8000',
        href: 'ws://localhost:8000/' },
     readyState: 3,
     options:
      { queueSize: Infinity,
        timeout: 10000,
        reconnect: {},
        pingTimeout: false,
        strategy: 'disconnect,online,timeout',
        transport: [Object] },
     timers: Tick { timers: [Object], context: [Circular] },
     socket:
      Socket {
        secure: false,
        agent: false,
        hostname: 'localhost',
        port: 8000,
        query: [Object],
        upgrade: true,
        path: '/eureca.io/',
        forceJSONP: false,
        jsonp: true,
        forceBase64: true,
        enablesXDR: false,
        timestampParam: 't',
        timestampRequests: true,
        transports: [Array],
        transportOptions: {},
        readyState: 'open',
        writeBuffer: [],
        prevBufferLen: 0,
        policyPort: 843,
        rememberUpgrade: false,
        binaryType: null,
        onlyBinaryUpgrades: undefined,
        perMessageDeflate: [Object],
        pfx: null,
        key: null,
        passphrase: null,
        cert: null,
        ca: null,
        ciphers: null,
        rejectUnauthorized: true,
        forceNode: false,
        id: 'S-rgDVndlGJHCMkJAAAA',
        upgrades: [Array],
        pingInterval: 25000,
        pingTimeout: 5000,
        pingIntervalTimer: null,
        pingTimeoutTimer: null,
        transport: [XHR],
        _callbacks: [Object] },
     disconnect: false,
     transport:
      { slashes: true,
        protocol: 'http:',
        hash: '',
        query: '_primuscb=MFt8OAq',
        pathname: '/eureca.io',
        auth: '',
        host: 'localhost:8000',
        port: 8000,
        hostname: 'localhost',
        password: '',
        username: '',
        origin: 'ws://localhost:8000',
        href: 'ws://localhost:8000/',
        object: true,
        secure: false,
        rememberUpgrade: false,
        forceBase64: true,
        enablesXDR: false,
        timestampRequests: true,
        path: '/eureca.io',
        transports: [Array] },
     transformers: { outgoing: [], incoming: [] },
     recovery:
      Recovery {
        attempt: null,
        _fn: null,
        'reconnect timeout': 30000,
        retries: 10,
        factor: 2,
        max: Infinity,
        min: 500,
        timers: [Tick],
        _events: [Object] } },
  eureca: {},
  request: undefined,
  id: [Function: id],
  remoteAddress: undefined,
  _proxy: {},
  _events:
   { open: [ [Function] ],
     message: [ [Function] ],
     reconnecting: [ [Function] ],
     close: [ [Function] ],
     error: [ [Function] ],
     stateChange: [ [Function] ] } }
recv msg:  { __eureca__: [ 'hello' ] }
recv msg:  { s: 'ohwVjK4cgV', e: null }

then I shutdown server. there is no connectionRetry event trigger.

I want to detect Eureca Server Status on Client Side.

I have integrated eureca.io for our production server and have one issue.
Eureca client just hang when it's trying to call eureca server that is not available.
I want detect server status and return server not available message if the server is down

Asynchronous Calls

I know I asked in the recent past about async calls from the server to the client but does the same apply when calling server functions that are async?

Would I have to write client side functions to handle the return or will the return value wait until the callback is complete?

I would like to write some server functions that access MongoDB via Mongoskin to retrieve data and return it to the client over Eureca but all of the methods in Mongoskin are promises. I am just looking for info that could aid in the 2 way communications design.

Thanks!!!

WebRTC not working?

Is the WebRTC mode broken? Tried it in my app and it doesn't connect to the server. Also tried the sample 7-WebRTC app in examples and same issue there.

No errors or anything, it just doesn't connect to the backend.

project dead?

Hello Ezelia.

What are your plans for the future here? Can we expect this project becoming more active?

Desynchronization on long-running calls

This is similar/related to an issue called out prior -

Issue:
When calling a long-running async function (10+ seconds), the function never returns to the caller. No error messages are fired or exposed. (Was quite difficult to debug and distill it)

Expected:
The call would return regardless of time needed to execute

Workarounds:
I tried to apply the 'health pinger' where I start a process that continuously (and quickly) makes back and forth calls every 100ms - the longer async call still did not return.

I'm currently changing all my long-running methods to be polling based - firing off the long running process then polling to find a result, defeating the purpose of Eureca

Thanks! Much appreciated!

Messages discarded when using asynchronous returns

Multiple successive calls to an asynchronously returning method cause all but the final call to be discarded. From the client code below, only the second console.log is hit.


Client

var Eureca = require('eureca.io');
var client = new Eureca.Client({ uri: 'ws://localhost:8000/'});

client.ready(function(proxy) {
  proxy.asyncServerHello().onReady((function(result) {
    console.log(result);
  }));

  proxy.asyncServerHello().onReady((function(result) {
    console.log(result);
  }));
});

Server

var http = require('http');
var httpServer = http.createServer();
var Eureca = require('eureca.io');
var eurecaServer = new Eureca.Server();
eurecaServer.attach(httpServer);

eurecaServer.exports.asyncServerHello = function() {
  var context = this;
  context.async = true;

  setTimeout(function() {
    context.return("Async hello from server!")
  }, 2000);
}

httpServer.listen(8000);

eureca.io with typescript

will there be supports for typescript and typing definition in the future?
and where can I find an example on how to use eureca.io with socket.io?

How can I disconnect a client from serverside

I want to disconnect from the client when I notice that he is already in the lobby but in a new window. (per Lobby only one user)

Is there any solution to fix that?

best regards
Matthias

How return a promise

Hi. I would like to ask how return a promise.

example:

---- this is my server
eurecaServer.exports.getAllBooks: () => {
return bluebird.coroutine(function*() {
try {
let document = yield opp.viewAllBooks() // return a a list of books
return document
} catch (error) {

      // internal server error
      return {error: error.message}
    }
  })()
}

---- this is my client

client.ready(function (serverProxy) {

//the onReady event is triggered when the remote side finishes
//executing the called function.
//returned value is stored in result argument
serverProxy.getAllBooks().onReady(function(result) {
console.log(result);
});
});

the result is always an object: { isFulfilled: false, isRejected: false }

Access socket object during authenticate call

Hello,
I'm using the authenticate option of eureca.io. The authentication process within my project works like this:

  • User requests a token from an external login server
  • User tries to authenticate at game server with token from login server

The token is a jwt, which will be checked within the authenticate method. When the token is valid, I need to store the user id from game. This is necessary to determine the user later on, when a server side method is called from client.

Before I've started switching from socket.io to eureca.io I've stored the user token within the socket object on the server after successful authentication.

Is it possible to access the socket object within the authentication callback I set, when initializing eureca server? Or do I have to write my own authentication "middleware" for this use case?

example:
var eureca_server = new Eureca.Server( { authenticate: function( token, next ) { /** check token & store user id within socket on server for later rpc calls */ next(); } } );

Typescript definition file

Hello,
I want to use your library for a multiplayer typescript game.

Is there a typescript definition file existing for eureca.io, or can it be generated automatically when building the project via grunt manually?

callback support for calling client side functions from server

Hi,
it's a great module and it has helped me out a lot already. However I'm running into a problem:

I'm trying to call a client-function from the server and provide a callback to work with the returned data. I'll extend the http://eureca.io/ example here accordingly:

server side

//we need to allow bar() function first
var eurecaServer = new EurecaServer({allow:['bar']});

// ... server initialisation
eurecaServer.exports.foo = function () {
     //when a server side function is called
     //we can access the client connection
     //throught this.connection

     var conn = this.connection;
     var client = eurecaServer.getClient(conn.id);
     console.log('called foo()');
     client.bar(function(data){
          console.log(data); // should log 'callback executed' to the console
     });
}
//... other stuff

client side

client.exports.bar = function (callback){
     console.log('called bar()');
     callback('callback executed');
}

client.ready(function (proxy) {
     proxy.foo();
});

Is this already possible? I couldn't get that to work.

Right now I am calling an additional server-side-function inside the client's bar function to send some data back...

cannot connected to server when integrated with docker swarm

I used docker swarm to build a cluster, composed of three machines, A machine is the main node, the other two machines B, C is the secondary node, in this case, my client program cannot connected to server.

I spent three days, still failed to solve this problem, could you help me resolve this issue, please !

Cannot install to read-only directory.

Due to the line that does "primus.save()" the directory that Eureca is installed into cannot be a completely read-only directory. We install our node installation and key libraries to read-only directories for sharing. Also it seems wasteful or at least inefficient to do that all the time when the data does not change.

Thanks for listening and thanks for Eureca. Great job.

Type Error

TypeError: Class constructor Server cannot be invoked without 'new'
at new F (C:\Users\Desktop\tanks-04\node_modules\eureca.io\index.js:10:31)
at new (C:\Users\Desktop\tanks-04\node_modules\eureca.io\index.js:16:16)
at Object. (C:\Users\Desktop\tanks-04\server.js:15:20)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)

example for launching mutliple servers

its it possible to run several eureca instances on the same node instance ?
could you provide an example how to launch servers via a route, e.g.
GET /games/myroom => launches new eureca server

Cheers

when i use eureca.io with node-pool leak memory

when need destroy the connection,i use the code below:

   name     : 'rpc-eureca.io',
    create   : function(callback) {
        console.log('create');
        var client = new Eureca.Client({uri:'http://ns.xxx.com/', transport:'sockjs'});
        client.ready(function (serverProxy) {
            callback(null, {instance:client, proxy:serverProxy});
        });
    },
    destroy  : function(client) { 
        console.log('destroy');
        var instance = client.instance;
        instance.socket.close();
    }

indeed it dos not really destroy the connection, because the memory not gc.

sorry for my bad english

Pack client side javascript

Hello,
I am trying to develop a multiplayer game by using eureca. On a later state of the development, I want do deliver an executable by using electron or something familiar.

So my question is, can I pack the client side javascript of eureca also into an electron app?

Re-authenticating after server disconnect

I've run into an interesting issue where clients do not re-authenticate after disconnections when you define an authentication callback. Specifically, if you kill the server without killing the client, then RPC calls will not complete saying authentication is still required.

Client Exports

I have the following server side

eurecaServer.attach(server);
eurecaServer.onConnect(function(conn){
    console.log(conn.id);
    var c = eurecaServer.getClient(conn.id);
    if(c.playerMove)
    {
       clientId = conn.id
    }
});

eurecaServer.exports.movePlayer = function(m)
{
    eurecaServer.getClient(clientId).playerMove([m]);
};

I have on a main page (Page A)


    let client = new Eureca.Client({ uri: 'ws://localhost:8000/'});
            client.exports.playerMove = function(x)
            {
                player.move.execute(x);
            };
            client.ready(function (proxy) {

            });

i have on another page ( Page B)

var client = new Eureca.Client({ uri: 'ws://localhost:8000/' });

    client.ready(function (proxy) {
        proxy.movePlayer([x,y]);
    });

I'm trying to send a one-way directional message via 2 devices Client A and Client B

Client A uses Page A( and goes there first)

and Client B goes to Page B( and goes there second)

why does Client B give me

invoke error playerMove is not a function

?

Dynos on Heroku - synch

Do you have some experience with scaling to multiple dynos on heroku ?
I believe they do not share memory, and since we store game sessions mostly in memory, this would probably not be synchronized across dynos ?
Cheers

where is eureca.js?

Hi I'm newbie on nodejs, I check eureca.io and it is a good job, I'm trying to do a web app but your examples have a file eureca.js. where can I get this file? , thanks

Cross-domain support for SockJS transport

Running one simple express server (port 3000) that renders HTML with eureca.js fetched from another express server configured with Eureca + SockJS as transport, running on port 3001

var client = new Eureca.Client({
         uri: 'ws://localhost:3001'
       , prefix: 'live'
       , transport: 'sockjs'
       , retry: 3
});

Browser blocks a GET request to /info

The following error is displayed in the console:
XMLHttpRequest cannot load ws://localhost:3001/info. Cross origin requests are only supported for HTTP.

Seems to be part of SockJS' protocol, but the express/eureca.io server contains no such route.

Engine.io transport works fine. :)

Thanks.

Desynchronization with repeated async function calls.

I'm experiencing a desynchronization with async server calls such that the caller and callee are not always paired properly when the first call is not complete by the time the second call reaches the server. For example: if I have a server function that takes 150 ms to complete, but its invoked every 100 ms, the promise returned from the first invocation may return the result from the second invocation.

Here's a demonstration of what I'm experiencing. The client just pings the server and checks the result to verify that it got back what it sent:

server.js

var http = require('http');
var httpServer = http.createServer();
var Eureca = require('eureca.io');
var eurecaServer = new Eureca.Server();
eurecaServer.attach(httpServer);

eurecaServer.exports.ping = function(id) {
  var context = this;
  context.async = true;
  setTimeout(function() {
    context.return(id)
  }, 150)
}

console.log('Server started');
httpServer.listen(8000);

client.js

var Eureca = require('eureca.io');
var client = new Eureca.Client({ uri: 'ws://localhost:8000/'});

var id = 0;
function uniqueId() {
  return id++;
}

client.ready(function (proxy) {
    setInterval(function() {
      var expected = uniqueId()
      console.log("Sending " + expected);
      proxy.ping(expected).then(function(result) {
        if (expected === result) {
          console.log("Server ponged OK.");
        } else {
          console.log("Server ponged Error (" + expected + " != " + result +")");
        }
      })
    }, 100);
});

Client output:

$ node client.js
* using primus:engine.io
ws://localhost:8000/ eureca.io
Server ponged Error (1 != 0)
Server ponged Error (2 != 1)
Server ponged Error (3 != 2)
Server ponged Error (4 != 3)
Server ponged Error (5 != 4)
Server ponged Error (6 != 5)

It appears to return the result of the calculation to the most recently invoked call rather than the one that originally triggered the calculation. Is there something I'm doing wrong here that might trigger this behavior?

Integration with sails.js

Ok, so i have the rooms feature implemented.
To create a server browser, persistent users etc i would like to integrate this with sails, that seems to be the easiest solution in terms of having a user / room database, server browser views with search, sorting etc. Doing everything in express would be much more work, but i'm not sure how to integrate this with sails. I need the sails server to handle web pages, user signup etc, and then i need to attach the eureka sever somwhere, but what would be the best setup?

Or is there a better alternative to sails ?

client.ready not executed if client is already ready

After some debugging in my project, I found out that any client.ready callback that is added after the client is ready will not be executed. I currently have to disable autoconnect and manually call client.connect after all callbacks are added.

It would be nice if any callbacks defined "late" could just be executed immediately.

Express session support

Neat module. Please add express session support or show how to implement it in an example.

getting started with eureca.io

Finding eureca.js.

I also wondered this, and on the first example in the home page, get the error:
ReferenceError: Eureca is not defined
var client = new Eureca.Client();

Which suggests that it can't find it. Any ideas?

Edit: I have read it's generated on the fly, so it is worth mentioning that I'm running the node server on one machine and the client on another ... so the client does not have access to anything except the index.html and associated JavaScript.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.