pusher / pusher-websocket-dotnet

Pusher Channels Client Library for .NET
MIT License
112 stars 113 forks source link

It works, just once. #14

Closed Mittchel closed 3 years ago

Mittchel commented 8 years ago

Hi,

I've been trying to port this library for Xamarin and to be honest it's pretty easy since WebSocket4Net also Supports Xamarin. Only thing I had to do was remove the Settings since Xamarin doesn't have System.Configuration.

So, I subscribed to a private channel with the following code:

      var _chatChannel = pusher.Subscribe ("channelname");
        _chatChannel.Subscribed += _chatChannel_Subscribed;
        _chatChannel.Bind("NEW_MESSAGE", (data) =>
            {
                Console.WriteLine("[" + data.name + "] " + data.message);
            });

It seems to work.. the event fires when I send a message with event name NEW_MESSAGE. But as soon as I send another one it doesn't come into the Bind anymore so the event is not caught..

Any ideas what this might be?

erichedstrom commented 7 years ago

@Mittchel Hi, have you had any luck getting past this? I just ran into the same problem in a Xamarin Android app.

Thanks!

erichedstrom commented 7 years ago

If anyone else runs into this and ends up here, I got it to work by binding my channel to an async action:

            channel.Bind("data-change", async data =>
            {
                var jsonData = data as JObject;

                if (jsonData != null)
                {
                     // .... do stuff
                     await MyAsyncTask();
                }
            });
stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you'd like this issue to stay open please leave a comment indicating how this issue is affecting you. Thank you.