javascript - Can the socket.io client emit events locally? -
is possible utilize socket.io dispatch events client , not send them server? like:
socket.emitlocally('some event', data);
here why i'm asking:
at moment server emits events sockets.
io.sockets.emit()
while works well, there possibility of delay between user interaction , response server.
this why prefer utilize broadcast on server side , handle things immediatly in broadcasting client.
socket.broadcast.emit()
the client based on angular.js , modules don't know of each other. can't access code responsible updating client directly. have utilize kind of event dispatching service inject relevant modules.
since what doing socket.io right now wonder if not utilize scheme this.
thank input or suggestions!
assuming grab events on client side using
io.on("name",callback);
you call
callback();
i hope help! =)
javascript node.js angularjs socket.io
No comments:
Post a Comment