streamy icon indicating copy to clipboard operation
streamy copied to clipboard

Delay in triggering the function `emit`.

Open valentineus opened this issue 7 years ago • 0 comments

There is a noticeable delay before which the Streamy.emit function begins to work. Why does this occur and how to fix it?

Example

Client side code:

Streamy.onConnect(() => console.log('Connection completed successfully.'));
Streamy.onDisconnect(() => console.log('There was a disconnection from the server.'));
Streamy.emit('test', { data: 'Hello, World!' });

Server side code:

Streamy.onConnect((socket) => console.log('Connected:', Streamy.id(socket)));
Streamy.onDisconnect((socket) => console.log('Disconnected:', Streamy.id(socket)));
Streamy.on('test', (data, from) => console.log(data));

There is a message from the client about the successful connection, there are no other messages.

Server-side command line:

Meteor
[[[[[ ~/workspace/streaming ]]]]]             

=> Started proxy.                             
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: https://<hostname>
I20170530-19:20:21.075(3)? Connected: cg9FKWWBQcThKM5eF


Process exited with code: 0

Detecting the delay

Client side code:

var i = 0;
Meteor.setInterval(function() {
    Streamy.emit('test', {
        data: 'Hello, World!',
        timer: i++
    });
}, 3000);

Server-side command line:

Meteor
[[[[[ ~/workspace/streaming ]]]]]             

=> Started proxy.                             
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: https://<hostname>
I20170530-19:28:31.493(3)? Connected: G4Ts8HtiDs7MftDuQ
I20170530-19:28:33.639(3)? { data: 'Hello, World!', timer: 14 }
I20170530-19:28:36.639(3)? { data: 'Hello, World!', timer: 15 }
I20170530-19:28:39.639(3)? { data: 'Hello, World!', timer: 16 }


Process exited with code: 0

Working environment

An empty project created with the --bare option and remote dependencies for front-end development is used.

$ meteor --version
Meteor 1.4.4.3
$ cat ./.meteor/packages 
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

valentineus avatar May 30 '17 16:05 valentineus