// Service disconnected from the message bus. private void OnServiceDisconnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { UnregisterService(e.ResponseReceiverId); } }
private void OnClientDisconnected(object sender, ResponseReceiverEventArgs e) { // Remove the client from the listbox. // Note: we can directly access the listbox because we set threading mode of // InputChannelThreading to the main UI thread. //ConnectedClientsListBox.Items.Remove(e.ResponseReceiverId); Client temp = null; foreach (Client client in clients) { if (client.id == e.ResponseReceiverId) { client.Disconnect(); temp = client; SenDisconnectedClient?.Invoke(sender, e); break; } } if (temp != null) { clients.Remove(temp); } }
// Connection with the client was closed. private void OnClientDisconnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { UnregisterClient(e.ResponseReceiverId, true, false); } }
private void OnClientDisconnected(object sender, ResponseReceiverEventArgs e) { // Remove the client from the listbox. // Note: we can directly access the listbox because we set threading mode of // InputChannelThreading to the main UI thread. ConnectedClientsListBox.Items.Remove(e.ResponseReceiverId); }
// A client was connected the load balancer. protected override void OnResponseReceiverConnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { Notify(ResponseReceiverConnected, e); } }
// A client was disconnected from the load balancer. protected override void OnResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { using (ThreadLock.Lock(myReceiverManipulatorLock)) { myOpenConnections.RemoveWhere(x => { if (x.ResponseReceiverId == e.ResponseReceiverId) { try { x.DuplexOutputChannel.CloseConnection(); } catch (Exception err) { EneterTrace.Warning(TracedObject + ErrorHandler.FailedToCloseConnection, err); } x.DuplexOutputChannel.ResponseMessageReceived -= OnResponseMessageReceived; x.DuplexOutputChannel.ConnectionClosed -= OnRequestReceiverClosedConnection; return(true); } return(false); }); } Notify(ResponseReceiverDisconnected, e); } }
protected override void OnResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { if (mySingletonService != null) { mySingletonService.UnsubscribeClientFromEvents(e.ResponseReceiverId); } else { // If per client mode then remove service stub for the disconnected client. using (ThreadLock.Lock(myPerConnectionServices)) { // Unsubscribe disconnected client from all events. ServiceStub <TServiceInterface> aServiceStub; myPerConnectionServices.TryGetValue(e.ResponseReceiverId, out aServiceStub); if (aServiceStub != null) { aServiceStub.UnsubscribeClientFromEvents(e.ResponseReceiverId); aServiceStub.DetachInputChannel(); myPerConnectionServices.Remove(e.ResponseReceiverId); } } } if (ResponseReceiverDisconnected != null) { ResponseReceiverDisconnected(this, e); } } }
protected override void OnResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e) { if (ResponseReceiverDisconnected != null) { ResponseReceiverDisconnected(sender, e); } }
protected override void OnResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { IEnumerable <string> anUnsubscribedMessages = Unsubscribe(e.ResponseReceiverId, null); RaiseClientUnsubscribed(e.ResponseReceiverId, anUnsubscribedMessages); } }
void Receiver_ResponseReceiverConnected(object sender, ResponseReceiverEventArgs e) { if (Receiver_ResponseReceiverConnectedEvent != null) { YZXResponseReceiverEventArgs ye = new YZXResponseReceiverEventArgs(e); Receiver_ResponseReceiverConnectedEvent(sender, ye); } }
private void Notify(EventHandler <ResponseReceiverEventArgs> handler, string responseReceiverId, string senderAddress) { using (EneterTrace.Entering()) { ResponseReceiverEventArgs anEventArgs = new ResponseReceiverEventArgs(responseReceiverId, senderAddress); NotifyGeneric <ResponseReceiverEventArgs>(handler, anEventArgs, false); } }
void OnResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e) { lock (myConnectedClients) { EneterTrace.Info("Client connection removed " + e.ResponseReceiverId); myConnectedClients.Remove(e.ResponseReceiverId); } }
private void OnResponseReceiverConnected(object sender, ResponseReceiverEventArgs e) { if (ResponseReceiverConnected != null) { ResponseReceiverConnected(sender, e); } serializers_by_receiver_id_.Add(e.ResponseReceiverId, serializer_factory_(e.ResponseReceiverId)); }
private void OnResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e) { if (ResponseReceiverDisconnected != null) { ResponseReceiverDisconnected(sender, e); } serializers_by_receiver_id_.Remove(e.ResponseReceiverId); }
// The method is called when a client is disconnected. // The Silverlight client is disconnected if the web page is closed. private void ClientDisconnected(object sender, ResponseReceiverEventArgs e) { // Remove the disconnected client from the listbox. Dispatcher.InvokeAsync(() => { ConnectedClientsListBox.Items.Remove(e.ResponseReceiverId); }); Logger.Info("ResponseReceiverId : " + e.ResponseReceiverId); Logger.Info("SenderAddress : " + e.SenderAddress); }
private void OnResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { if (ResponseReceiverDisconnected != null) { ResponseReceiverDisconnected(this, e); } } }
// The method is called when a client is connected. // The Silverlight client is connected when the client attaches the output duplex channel. private void ClientConnected(object sender, ResponseReceiverEventArgs e) { // Add the connected client to the listbox. Dispatcher.InvokeAsync(() => { ConnectedClientsListBox.Items.Add(e.ResponseReceiverId); }); Logger.Info("Connected " + e.ResponseReceiverId); //Logger.Info("ResponseReceiverId : " + e.ResponseReceiverId); //Logger.Info("SenderAddress : " + e.SenderAddress); }
private void OnClientConnected(object sender, ResponseReceiverEventArgs e) { // Add the client id to the listbox. // Note: we can directly access the listbox because we set threading mode of // InputChannelThreading to the main UI thread. //ConnectedClientsListBox.Items.Add(e.ResponseReceiverId); Client client = new Client(e.ResponseReceiverId, e.SenderAddress); clients.Add(client); SendConnectedClient?.Invoke(sender, e); }
/// <summary> /// It is called when the client actively closed the connection with this backup router. /// It will close the associated connection with the service. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void OnResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { using (ThreadLock.Lock(myConnectionsLock)) { TConnection aConnetion = myOpenConnections.FirstOrDefault(x => x.ResponseReceiverId == e.ResponseReceiverId); CloseConnection(aConnetion); myOpenConnections.Remove(aConnetion); } } }
/// <summary> /// It is called when a client opens the connection to this backup router. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void OnResponseReceiverConnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { using (ThreadLock.Lock(myConnectionsLock)) { // Open the associated connection with the service for the incoming client. TConnection aConnection = OpenConnection(e.ResponseReceiverId); myOpenConnections.Add(aConnection); } } }
public void Disconnect(string aClientId) { if (!string.IsNullOrEmpty(aClientId)) { myReceiver.AttachedDuplexInputChannel.DisconnectResponseReceiver(aClientId); Client temp = GetClient(aClientId); if (temp != null) { clients.Remove(temp); ResponseReceiverEventArgs e = new ResponseReceiverEventArgs(aClientId, ""); SenDisconnectedClient?.Invoke(null, e); } } }
private void OnDuplexInputChannelResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { using (ThreadLock.Lock(myDuplexInputChannelContextManipulatorLock)) { foreach (TDuplexInputChannelContext aDuplexInputChannelContext in myDuplexInputChannelContexts) { IEnumerable <TConnection> aConnections = aDuplexInputChannelContext.OpenConnections.Where(x => x.ResponseReceiverId == e.ResponseReceiverId); CloseConnections(aConnections); aDuplexInputChannelContext.OpenConnections.RemoveWhere(x => x.ResponseReceiverId == e.ResponseReceiverId); } } } }
protected override void OnResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { using (ThreadLock.Lock(myClientConnectionLock)) { TClient aClient; myConnectedClients.TryGetValue(e.ResponseReceiverId, out aClient); if (aClient != null) { aClient.CloseOutpuConnections(); myConnectedClients.Remove(e.ResponseReceiverId); } } } }
protected override void OnResponseReceiverConnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { TClient aNewClient = new TClient(AttachedDuplexInputChannel, e.ResponseReceiverId); IEnumerable <string> anOutputChannelIds = myGetOutputChannelIds(); using (ThreadLock.Lock(myClientConnectionLock)) { // Opens connections to all available outputs. aNewClient.OpenOutputConnections(myMessaging, anOutputChannelIds); myConnectedClients[e.ResponseReceiverId] = aNewClient; } } }
protected override void OnResponseReceiverConnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { if (ResponseReceiverConnected != null) { try { ResponseReceiverConnected(this, e); } catch (Exception err) { EneterTrace.Warning(TracedObject + ErrorHandler.DetectedException, err); } } } }
private void OnResponseReceiverConnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { bool aPendingResponseReceicerConnectedEvent = false; bool aNewResponseReceiverFlag = false; TBufferedResponseReceiver aResponseReciever; using (ThreadLock.Lock(myResponseReceivers)) { aResponseReciever = GetResponseReceiver(e.ResponseReceiverId); if (aResponseReciever == null) { aResponseReciever = CreateResponseReceiver(e.ResponseReceiverId, e.SenderAddress, false); aNewResponseReceiverFlag = true; } aResponseReciever.IsOnline = true; if (aResponseReciever.PendingResponseReceiverConnectedEvent) { aResponseReciever.ClientAddress = e.SenderAddress; aPendingResponseReceicerConnectedEvent = aResponseReciever.PendingResponseReceiverConnectedEvent; aResponseReciever.PendingResponseReceiverConnectedEvent = false; } if (aNewResponseReceiverFlag) { // This is a fresh new response receiver. Therefore broadcast messages were not sent to it yet. foreach (TBroadcast aBroadcastMessage in myBroadcasts) { aResponseReciever.SendResponseMessage(aBroadcastMessage.Message); } } // Send all buffered messages. aResponseReciever.SendMessagesFromQueue(); } Notify(ResponseReceiverOnline, e, false); if (aNewResponseReceiverFlag || aPendingResponseReceicerConnectedEvent) { Notify(ResponseReceiverConnected, e, false); } } }
private void OnResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { int aNumberOfRemoved; using (ThreadLock.Lock(myResponseReceiverContexts)) { aNumberOfRemoved = myResponseReceiverContexts.RemoveWhere(x => x.ResponseReceiverId == e.ResponseReceiverId); } if (aNumberOfRemoved > 0) { // Notify response receiver disconnected. Dispatcher.Invoke(() => NotifyGeneric(ResponseReceiverDisconnected, e, false)); } } }
private void Notify(EventHandler <ResponseReceiverEventArgs> handler, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { if (handler != null) { try { handler(this, e); } catch (Exception err) { EneterTrace.Warning(TracedObject + ErrorHandler.DetectedException, err); } } } }
public void SendResponseMessage(string responseReceiverId, object message) { using (EneterTrace.Entering()) { // If it is a broadcast response message. if (responseReceiverId == "*") { using (ThreadLock.Lock(myResponseReceivers)) { TBroadcast aBroadcastMessage = new TBroadcast(message); myBroadcasts.Add(aBroadcastMessage); foreach (TBufferedResponseReceiver aResponseReceiver in myResponseReceivers) { // Note: it does not throw exception. aResponseReceiver.SendResponseMessage(message); } } } else { bool aNotifyOffline = false; using (ThreadLock.Lock(myResponseReceivers)) { TBufferedResponseReceiver aResponseReciever = GetResponseReceiver(responseReceiverId); if (aResponseReciever == null) { aResponseReciever = CreateResponseReceiver(responseReceiverId, "", true); aNotifyOffline = true; } aResponseReciever.SendResponseMessage(message); if (aNotifyOffline) { ResponseReceiverEventArgs anEvent = new ResponseReceiverEventArgs(responseReceiverId, ""); Dispatcher.Invoke(() => Notify(ResponseReceiverOffline, anEvent, false)); } } } } }
private void OnResponseReceiverConnected(object sender, ResponseReceiverEventArgs e) { using (EneterTrace.Entering()) { lock (myConnectedResponseReceivers) { myConnectedResponseReceivers.Add(e); if (myConnectedResponseReceivers.Count == myNumberOfExpectedReceivers) { myResponseReceiversAreConnectedEvent.Set(); } if (myDoOnResponseReceiverConnected != null) { myDoOnResponseReceiverConnected(sender, e); } } } }
// The method is called when a client is connected. // The Silverlight client is connected when the client attaches the output duplex channel. private void ClientConnected(object sender, ResponseReceiverEventArgs e) { // Add the connected client to the listbox. //InvokeInUIThread(() => Dispatcher.InvokeAsync(() => { ConnectedClientsListBox.Items.Add(e.ResponseReceiverId); }); }
// The method is called when a client is disconnected. // The Silverlight client is disconnected if the web page is closed. private void ClientDisconnected(object sender, ResponseReceiverEventArgs e) { // Remove the disconnected client from the listbox. //InvokeInUIThread(() => Dispatcher.InvokeAsync(() => { ConnectedClientsListBox.Items.Remove(e.ResponseReceiverId); }); }
private void OnClientDisconnected(object sender, ResponseReceiverEventArgs e) { LogMessage(String.Format("OnClientDisconnected: ResponseReceiverId = {0}, SenderAddress = {1}", e.ResponseReceiverId, e.SenderAddress)); }