Friday, 6 September 2013

Running code from Socket.io notification

Running code from Socket.io notification

I'm running a NodeJS server which is sending notification to the clients
when sombody does something, for example, when a client deletes a row from
a grid, Socket.io informs the rest of the clients that a row got deleted.
In that example, I could add something like actionType: rowdeleted to the
socket.io message and then just detect the actionType on the client side
and refresh the grid. Anyways, the problem is that there can be infinte
number of actions (and new one can be added), so I can't code a function
for each action type on the client side.
Then I thought maybe I can send some code via socket.io and make the
client run it, but I'm not sure if that is the best way for doing what I
want. Also, how are the clients going to run that code? Via eval?
I'm open to any suggestion :)

No comments:

Post a Comment