private void OnLocalUnsubscribe(object sender, UnsubscribeMessage message) { // TODO: remove client. //throw new NotImplementedException(); }
public override void HandleUnsubscriptionMessage(UnsubscribeMessage message) { this.PublishMessage(new ActorUnsubscribedMessage(message.Unsubscriber, false)); _unsubscribeMessages++; base.HandleUnsubscriptionMessage(message); }
/// <summary> /// Unsubscribe from an ephemeral subscription. /// </summary> /// <param name="topics"></param> /// <returns></returns> public async Task UnsubscribeAsync(IEnumerable <string> topics) { try { UnsubscribeMessage msg = new UnsubscribeMessage(session.NewId(), topics); //if (channel.RequireBlocking) //{ // Task t = channel.SendAsync(msg.Encode()); // Task.WaitAll(t); //} //else //{ await channel.SendAsync(msg.Encode()); //} foreach (var topic in topics) { dispatcher.Unregister(topic); } } catch (Exception ex) { OnChannelError?.Invoke(this, new ChannelErrorEventArgs(channel.Id, ex)); } }
public async Task UnsubscribeAsync(string topic) { UnsubscribeMessage msg = new UnsubscribeMessage(session.NewId(), new[] { topic }); await channel.SendAsync(msg.Encode()); dispatcher.Unregister(topic); }
private void Unsubscribe(UnsubscribeMessage msg) { if (_subscribersMap.ContainsKey(msg.SubdcriberGuid)) { _subscribersMap.Remove(msg.SubdcriberGuid); } Broadcast(msg); }
public void Unsubscribe(string topic) { var msg = new UnsubscribeMessage(); msg.FixedHeader.Qos = Qos.AtLeastOnce; msg.Unsubscribe(topic); conn.SendMessage(msg); }
public async Task UnsubscribeAsync(IEnumerable <string> topics) { UnsubscribeMessage msg = new UnsubscribeMessage(session.NewId(), topics); await channel.SendAsync(msg.Encode()); foreach (string topic in topics) { dispatcher.Unregister(topic); } }
public HttpResponseMessage Unsubscribe([FromBody] UnsubscribeMessage message) { if (!String.IsNullOrEmpty(message.callbackUrl)) { if (InMemoryTriggerStore.Instance.GetStore().ContainsKey(message.callbackUrl)) { InMemoryTriggerStore.Instance.UnregisterTrigger(message.callbackUrl); } } return(Request.CreateResponse()); }
public async Task <UnsubscribedMessage> Unsubscribe(UnsubscribeMessage message) { // TODO check for valid device id this.logger.LogDebug($"[{this.Context.ConnectionId}] Unsubscribe {message?.DeviceId ?? "none"}"); await this.Groups.RemoveFromGroupAsync(this.Context.ConnectionId, message.DeviceId); //await this.Clients.Caller.Unsubscribed(new UnsubscribedMessage() { DeviceId = message.DeviceId }); return(new UnsubscribedMessage() { DeviceId = message.DeviceId }); }
private void OnUnsubscribe(object sender, UnsubscribeMessage message) { if (subscriptions.ContainsValue(message.SubscriptionId)) { var topic = subscriptions.Single(s => s.Value == message.SubscriptionId).Key; cache.UnsubscribeAsync(topic); subscriptions.Remove(topic); } Send(new UnsubscribedMessage { RequestId = message.RequestId }); }
public async Task UnsubscribeAsync(string topic) { try { UnsubscribeMessage msg = new UnsubscribeMessage(session.NewId(), new[] { topic }); await Channel.SendAsync(msg.Encode()); dispatcher.Unregister(topic); } catch (Exception ex) { OnChannelError?.Invoke(this, new ChannelErrorEventArgs(Channel.Id, ex)); } }
public OperationResult <string> Unsubscribe(string pairName, int period, int channelId) { if (string.IsNullOrWhiteSpace(pairName) || period <= 0) { return(OperationResult <string> .Failure($"Параметры отписки на прослушку пары {nameof(pairName)}, {nameof(period)} не могут быть пустыми или null")); } var message = new UnsubscribeMessage { Event = MessageType.Unsubscribe, ChannelName = "candles", Key = $"trade:{period}m:t{pairName.ToUpper()}", ChannelId = channelId }; return(OperationResult <string> .Success(JsonConvert.SerializeObject(message, _bitfinexJsonSettings))); }
public async Task UnsubscribeAsync(IEnumerable <string> topics) { try { UnsubscribeMessage msg = new UnsubscribeMessage(session.NewId(), topics); await Channel.SendAsync(msg.Encode()); foreach (string topic in topics) { dispatcher.Unregister(topic); } } catch (Exception ex) { OnChannelError?.Invoke(this, new ChannelErrorEventArgs(Channel.Id, ex)); } }
private void Session_OnUnsubscribe(object sender, MqttMessageEventArgs args) { try { UnsubscribeMessage msg = (UnsubscribeMessage)args.Message; foreach (var item in msg.Topics) { MqttUri uri = new MqttUri(item.ToLowerInvariant()); if (adapter.CanSubscribeAsync(uri.Resource, Channel.IsEncrypted).GetAwaiter().GetResult()) { adapter.UnsubscribeAsync(uri.Resource).GetAwaiter(); } } } catch (Exception ex) { logger.LogError(ex, $"MQTT adapter Session_OnUnsubscribe error on channel '{Channel.Id}'."); OnError?.Invoke(this, new ProtocolAdapterErrorEventArgs(Channel.Id, ex)); } }
public void TestUnsubscribeMessageRaisesOnUnsubscribe(string message) { var e = new ManualResetEvent(false); var wasCalled = false; UnsubscribeMessage unsubscribeMessage = null; _wampCommsHandler.Start(config => { config.OnUnsubscribe = m => { e.Set(); unsubscribeMessage = m; wasCalled = true; }; }); _connMock.Object.OnMessage(message); e.WaitOne(1000); Assert.True(wasCalled); Assert.IsNotNull(unsubscribeMessage); }
private void Session_OnUnsubscribe(object sender, MqttMessageEventArgs args) { try { UnsubscribeMessage msg = (UnsubscribeMessage)args.Message; foreach (var item in msg.Topics) { MqttUri uri = new MqttUri(item.ToLowerInvariant()); if (EventValidator.Validate(false, uri.Resource, Channel, graphManager, context).Validated) { adapter.UnsubscribeAsync(uri.Resource).GetAwaiter(); logger?.LogInformationAsync($"MQTT adapter unsubscribed {uri.ToString()}"); } } } catch (Exception ex) { logger?.LogErrorAsync(ex, $"MQTT adapter Session_OnUnsubscribe error on channel '{Channel.Id}'.").GetAwaiter(); OnError?.Invoke(this, new ProtocolAdapterErrorEventArgs(Channel.Id, ex)); } }
static void Main(string[] args) { while (true) { //System.Environment.Exit(-1); Console.WriteLine("Please enter your email:"); var email = Console.ReadLine(); using (var queue = new System.Messaging.MessageQueue(@".\private$\email-unsubscribe")) { var unsubscribeMessage = new UnsubscribeMessage() { Email = email }; var message = new Message(); var jsonBody = JsonConvert.SerializeObject(unsubscribeMessage); message.BodyStream = new MemoryStream(Encoding.Default.GetBytes(jsonBody)); queue.Send(message); } Console.WriteLine("Message sent"); } }
private void OnUnsubscribe(object sender, UnsubscribeMessage message) { subscriptionThreads[message.SubscriptionId].Abort(); subscriptionThreads.Remove(message.SubscriptionId); subscriptionClients[message.SubscriptionId].Close(); var topic = subscriptionClients[message.SubscriptionId].TopicPath; subscriptionClients.Remove(message.SubscriptionId); namespaceManager.DeleteSubscription(topic, message.SubscriptionId.ToString()); if (namespaceManager.GetTopic(topic).SubscriptionCount <= 0) { namespaceManager.DeleteTopic(topic); topicClients.Remove(topic); } Send(new UnsubscribedMessage { RequestId = message.RequestId }); }
/// <summary> /// Unsubscribe from an ephemeral subscription. /// </summary> /// <param name="topic"></param> /// <returns></returns> public async Task UnsubscribeAsync(string topic) { try { UnsubscribeMessage msg = new UnsubscribeMessage(session.NewId(), new string[] { topic }); //if (channel.RequireBlocking) //{ // Task t = channel.SendAsync(msg.Encode()); // Task.WaitAll(t); //} //else //{ await channel.SendAsync(msg.Encode()); //} dispatcher.Unregister(topic); } catch (Exception ex) { OnChannelError?.Invoke(this, new ChannelErrorEventArgs(channel.Id, ex)); } }
public static async Task Unsubscribe(UnsubscribeMessage message) { foreach (var client in Clients) await client.Unsubscribe(message.SubscriptionId); }
/// <summary> /// Processes the message, updating our internal state and then invokes the events. /// </summary> /// <param name="message"></param> private void ProcessMessage(IMessage message) { if (message == null) { return; } switch (message.Type) { //We got a update, so we will update our current presence case MessageType.PresenceUpdate: lock (_sync) { PresenceMessage pm = message as PresenceMessage; if (pm != null) { //We need to merge these presences together if (CurrentPresence == null) { CurrentPresence = pm.Presence; } else if (pm.Presence == null) { CurrentPresence = null; } else { CurrentPresence.Merge(pm.Presence); } //Update the message pm.Presence = CurrentPresence; } } break; //Update our configuration case MessageType.Ready: ReadyMessage rm = message as ReadyMessage; if (rm != null) { lock (_sync) { Configuration = rm.Configuration; CurrentUser = rm.User; } //Resend our presence and subscription SynchronizeState(); } break; //Update the request's CDN for the avatar helpers case MessageType.JoinRequest: if (Configuration != null) { //Update the User object within the join request if the current Cdn JoinRequestMessage jrm = message as JoinRequestMessage; if (jrm != null) { jrm.User.SetConfiguration(Configuration); } } break; case MessageType.Subscribe: lock (_sync) { SubscribeMessage sub = message as SubscribeMessage; Subscription |= sub.Event; } break; case MessageType.Unsubscribe: lock (_sync) { UnsubscribeMessage unsub = message as UnsubscribeMessage; Subscription &= ~unsub.Event; } break; //We got a message we dont know what to do with. default: break; } //Invoke the appropriate methods switch (message.Type) { case MessageType.Ready: if (OnReady != null) { OnReady.Invoke(this, message as ReadyMessage); } break; case MessageType.Close: if (OnClose != null) { OnClose.Invoke(this, message as CloseMessage); } break; case MessageType.Error: if (OnError != null) { OnError.Invoke(this, message as ErrorMessage); } break; case MessageType.PresenceUpdate: if (OnPresenceUpdate != null) { OnPresenceUpdate.Invoke(this, message as PresenceMessage); } break; case MessageType.Subscribe: if (OnSubscribe != null) { OnSubscribe.Invoke(this, message as SubscribeMessage); } break; case MessageType.Unsubscribe: if (OnUnsubscribe != null) { OnUnsubscribe.Invoke(this, message as UnsubscribeMessage); } break; case MessageType.Join: if (OnJoin != null) { OnJoin.Invoke(this, message as JoinMessage); } break; case MessageType.Spectate: if (OnSpectate != null) { OnSpectate.Invoke(this, message as SpectateMessage); } break; case MessageType.JoinRequest: if (OnJoinRequested != null) { OnJoinRequested.Invoke(this, message as JoinRequestMessage); } break; case MessageType.ConnectionEstablished: if (OnConnectionEstablished != null) { OnConnectionEstablished.Invoke(this, message as ConnectionEstablishedMessage); } break; case MessageType.ConnectionFailed: if (OnConnectionFailed != null) { OnConnectionFailed.Invoke(this, message as ConnectionFailedMessage); } break; default: //This in theory can never happen, but its a good idea as a reminder to update this part of the library if any new messages are implemented. Logger.Error("Message was queued with no appropriate handle! {0}", message.Type); break; } }
private void Unsubscribe(UnsubscribeMessage msg) { var eraseMessage = new EraseMessage(_clientState.CurrentX, _clientState.CurrentY); _gameRenderActor.Tell(eraseMessage); }
private void OnUnsubscribe(object sender, UnsubscribeMessage args) { _controlPanel.ChangeStatus = $"Unsubscribed: {args.Event}"; }
private static void OnUnsubscribe(object sender, UnsubscribeMessage args) { //This is called when the unsubscription has been made succesfully. It will return the event you unsubscribed from. Console.WriteLine("Unsubscribed: {0}", args.Event); }
public void Init() { message = new UnsubscribeMessage(topicUri); }
public void unsubscribe(String topic, Callback cb) //throws IOException { UnsubscribeMessage msg = new UnsubscribeMessage(topic, this); sendCallbackMessage(msg, cb); }
private static void OnUnsubscribe(object sender, UnsubscribeMessage args) { Console.WriteLine("Unsubscribed: {0}", args.Event); }
public static void Unsubscribe(object sender, UnsubscribeMessage message) { // TODO: implement this. //throw new NotImplementedException(); }
private void OnUnsubscribe(object sender, UnsubscribeMessage args) { Logger.Log($"Discord: Unsubscribed: {args.Event}"); }