Here is my very simple code using the latest prerelease version of 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();
Doesn't work though, the code within the subscription never runs. Tried it with CreateJsonChannel
as well, that doesn't work either.
Any ideas what might be wrong?
Your code works fine. Just get rid of the Console.ReadLine - it blocks the WebSocket thread and therefore WampSharp can't get any further messages. You can add a Console.ReadLine to your Main instead.
See also blog post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With