1

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.

4

1 回答 1

3

我刚刚向 NuGet 上传了一个 WampSharp 版本,它允许您指定要用于 WampChannel 的底层 WebSocket。

用法:

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();

如您所见,您还可以订阅底层 WebSocket 的事件。我不是很喜欢这个,因为这移除了 WampSharp 的 WebSocket 封装,但是如果你知道你在做什么,我不会阻止你。

于 2014-08-14T12:42:01.130 回答