下面是我使用最新预发行版WampSharp的非常简单的代码:
var channelFactory = new DefaultWampChannelFactory();
var channel = channelFactory.CreateMsgpackChannel("wss://api.poloniex.com", "realm1");
await channel.Open();
var realmProxy = channel.RealmProxy;
Console.WriteLine("Connection established");
int received = 0;
IDisposable subscription = null;
subscription =
realmProxy.Services.GetSubject("ticker")
.Subscribe(x =>
{
Console.WriteLine("Got Event: " + x);
received++;
if (received > 5)
{
Console.WriteLine("Closing ..");
subscription.Dispose();
}
});
Console.ReadLine();不起作用,订阅中的代码永远不会运行。我在CreateJsonChannel上也试过了,但也不起作用。
你知道可能出了什么问题吗?
发布于 2016-07-24 01:26:36
您的代码运行良好。只需去掉Console.ReadLine -它会阻塞WebSocket线程,因此WampSharp无法获得任何进一步的消息。您可以将Console.ReadLine添加到Main中。
另请参见blog post。
https://stackoverflow.com/questions/38537120
复制相似问题