Handler for pong message in WampSharp client

526 views Asked by At

I have a WampSharp client which successfully pings my Wamp WS server created in python every 1 minute.

I am sending a pong message from the server to the client on the receipt of the ping.

I would like to know whether there is any handler which will handle the receipt of the pong message in WampSharp client so that I could perform certain tasks at client side?

And if there isn't any separate handler for the pong message then is there any handler to handle the data received from the server like in traditional WebSocket client which is as follows?

webSocket.MessageReceived += new EventHandler<MessageReceivedEventArgs>(webSocket_MessageReceived);

Thanks in advance.

1

There are 1 answers

0
darkl On

I just uploaded to NuGet a version of WampSharp that allows you to specify the underlying WebSocket you want to use for a WampChannel.

Usage:

DefaultWampChannelFactory factory = new DefaultWampChannelFactory();
WebSocket socket = new WebSocket("ws://localhost:9090/ws", "wamp");
IWampChannel<JToken> channel = factory.CreateChannel(socket);

socket.DataReceived += OnDataReceived;

await channel.OpenAsync();

As you see, you can also subscribe to underlying WebSocket's events. I don't really like this, since this removes WampSharp's WebSocket encapsulation, but if you know what you're doing, I won't stop you.