Hi
I am using Azure pub sub forge component in my application for creating real time chat. First I was created a websocket and after using the get client access uri server action generated uri and passed to websocket for connection after connection i sent one message to the client using send to all server action after receiving the message how the client should send the reply to server?????
Thanks in Advance
regards,
Srujan.
Hi. You need to be more clear what you mean with replying to server. Azure Web PubSub knows only connected clients. The websocket connection to a PubSub hub is one connected client. You can only send to connected clients. If you mean by server your OutSystems backend then this is not possible. You cannot open a websocket connection from the backend and keep it open to receive messages sent from other connected clients.
However you can configure user event handlers in Azure Web PubSub for user events like message. https://learn.microsoft.com/en-us/azure/azure-web-pubsub/howto-develop-eventhandler. The event is forwarded to a configured webhook url (an OutSystems exposed REST API) to handle the event and respond accordingly.
I mean when publisher publish the message to all connected subscribers then Is it possible the subscriber will send the message to publisher . Possible means How?
Every connected client to a hub has a user identifier. You already defined a userid for a connection when you created the client access uri. That user identifier is sent with every message. So if you want to reply to an individual user id you would send a message to this user identifier only. (WebPubSub_SendToUser action)
That's ok you are telling how to publish the message from publisher to specified connected user(subscriber).But after recieving the message from the publisher the subscriber wants to send reply message to the publisher. Is it possible???
Thanks in advance.
See my first answer. It didn't change. The server actions of the component are not a connected client and therefore you cannot send a message directly there via websocket call. However you can use webhook event handlers.