I am a C# newbie trying to implement SignalR in my Xamarin IOS app.
My code is quite simple:
_connection = new Microsoft.AspNet.SignalR.Client.Hubs.HubConnection (Common.signalRAddress);
feedHub = _connection.CreateHubProxy ("feedHub");
_connection.Received += data => { OnReceiveData (data); };
_connection.Start ();
my question is how can I remove my delegate? Is it enough to write?
_connection.Received -= data => { OnReceiveData (data); };
Any help would be really appreciated.
You're using a hub, why not use the built in on/off for method invocations?
aka:
var doSomething = feeHub.On<int>("doSomething", val => {
// Do something with int val
});
Then to remove it you can do:
doSomething.Dispose();
If you truly want to listen to ALL data that flows through the hub then using Received is the correct approach and @Dracanus' answer will work.
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