MWS - Send message to a specific user
The "MWS":https://developer.qtcloudservices.com/mws/key-concepts page says:
bq. It is possible to send messages to a list of receivers which may consist of socket ids or delivery groups, tags.
How tags works? Do I need to set a tag of a websocket instance?
Is there any example sending messages to a list of or to a specific receiver?
Do I need to use Pub/Sub protocol to do this?
Thanks in Advance
You can specify tags array in message payload, when you create a WebSocket for a client,
You have to add also your MWS Gateway's Security Token as Authorization header:
"Authorization": "Bearer SECURITY_TOKEN"
Related API Documentation: https://developer.qtcloudservices.com/mws/rest/v1/post_sockets
When you send a WebSocket message, you can specify tags array there as well.
MWS will send the message to all WebSockets that have "players" tag attached.
Related API Documentation: https://developer.qtcloudservices.com/mws/rest/v1/post_messages
You can see Node.js example in "qtc-todo-tutorial":https://github.com/qtcloudservices/qtc-tutorial-todo/blob/master/server/api/routes.js#L91, where tags are used for sending and receiving WebSocket messages
I just tested this and for some reason, when i send message, even if I dont have the tag id that is specified by the payload, I still receives the message? What am I doing wrong.
Ok nvm I had "sockets":"[*]", instead of null.