示例#1
0
 // Service disconnected from the message bus.
 private void OnServiceDisconnected(object sender, ResponseReceiverEventArgs e)
 {
     using (EneterTrace.Entering())
     {
         UnregisterService(e.ResponseReceiverId);
     }
 }
示例#2
0
        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);
            }
        }
示例#3
0
 // Connection with the client was closed.
 private void OnClientDisconnected(object sender, ResponseReceiverEventArgs e)
 {
     using (EneterTrace.Entering())
     {
         UnregisterClient(e.ResponseReceiverId, true, false);
     }
 }
示例#4
0
 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);
            }
        }
示例#7
0
        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);
                }
            }
        }
示例#8
0
 protected override void OnResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e)
 {
     if (ResponseReceiverDisconnected != null)
     {
         ResponseReceiverDisconnected(sender, e);
     }
 }
示例#9
0
 protected override void OnResponseReceiverDisconnected(object sender, ResponseReceiverEventArgs e)
 {
     using (EneterTrace.Entering())
     {
         IEnumerable <string> anUnsubscribedMessages = Unsubscribe(e.ResponseReceiverId, null);
         RaiseClientUnsubscribed(e.ResponseReceiverId, anUnsubscribedMessages);
     }
 }
示例#10
0
 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);
     }
 }
示例#12
0
 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);
         }
     }
 }
示例#17
0
 // 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);
 }
示例#18
0
        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);
         }
     }
 }
示例#21
0
 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);
             }
         }
     }
 }
示例#23
0
 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);
             }
         }
     }
 }
示例#24
0
            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);
                }
            }
        }
示例#27
0
        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));
                        }
                    }
                }
            }
        }
示例#30
0
        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 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);
 }
示例#32
0
 // 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);
 }
示例#33
0
 // 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);
     });
 }
示例#34
0
 // 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));
 }