mardi 1 mars 2016

Planning how to implement project using websocket

First off, I apologize for my bad english. here is what I want to ask you:

I have web project, where happens several event, when users should be get notification about these events, for example events are:

voting - user gives vote to another user. recipient user gets notification.

messaging - user sends message to another user. recipient user gets notification.

and few events also.

For notifications, I use websocket.

So, my question is how to planning this? I mean, I think about 2 ways for doing this:

First way: Do All In "socket_server.php file". that is, for example, when user gives vote to another user, then - do all necessary server side things (checking/validating incoming data, changing data in database (update /insert table), etc ) and finally, sent notification to recipient user. That is, we do all these in socket_server.php.

Second way: use websocket JUST for sending notifications. that is, Do all server side things in another php file, then return result to browser, then send just "ok" request to socket_server.php file for doing notification. that is, in this case, we use socket file only for sending notification, not for anything else.

Which way is recommended?

I never used websockets until now, so any advice will be very helpful.




Aucun commentaire:

Enregistrer un commentaire