简体   繁体   English

订阅频道的SocketIO4Net.Client

[英]SocketIO4Net.Client subscribing to a channel

I'd like to subscribe to a socket.io channel from a client that's using SocketIO4Net.Client 我想从使用SocketIO4Net.Client的客户端订阅socket.io频道

What is the best way to do that, given that there is no subscribe operation or subscribe message type implemented in the library? 考虑到库中没有实现订阅操作或订阅消息类型,最好的方法是什么?

There are 3 basic ways you can subscribe to a channel/room from within SocketIO4Net.Client: 您可以通过3种基本方法从SocketIO4Net.Client中订阅频道/房间:

[From the doc's] [来自文档的]

Registering for Socket.IO event messages in the .net client can be done several ways: 在.net客户端中注册Socket.IO事件消息的方法有几种:

Using an Action delegate Using an Action delegate with anonymous methods Using a lambda expression to an Action delegate instance in the .On(eventName, Action) method (preferred). 使用Action委托使用带有匿名方法的Action委托对.On(eventName,Action)方法中的lambda表达式使用Action委托实例(首选)。 By default, all messages received are exposed through the Message event. 默认情况下,所有收到的消息都是通过Message事件公开的。 Event messages registered via the .On() method will skip the Message event notification. 通过.On()方法注册的事件消息将跳过消息事件通知。

The general method is as: 通用方法如下:

socket.On("news", (data) =>
{
    var raw = data.RawMessage();                            
});

There is a fair amout of [documentation][1] [documentation] [1]有相当多的选择

[1]: http://socketio4net.codeplex.com/documentation , is there something in particular that isn't covered (will add if so)? [1]: http : //socketio4net.codeplex.com/documentation ,有没有特别涵盖的内容(如果有的话会添加)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM