Exemplo n.º 1
0
        private void OnChannelClosed(object sender, EventArgs e)
        {
            IMasterServerCallback hCb  = sender as IMasterServerCallback;
            NodeReference         hRef = HandleDisconnection(hCb);

            ChannelFaulted?.Invoke(hRef);
        }
Exemplo n.º 2
0
        public void Register(int iPort)
        {
            IMasterServerCallback         hCb           = OperationContext.Current.GetCallbackChannel <IMasterServerCallback>();
            RemoteEndpointMessageProperty hEndPointProp = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;

            NodeReference hNewNode = new NodeReference(hCb, new IPEndPoint(IPAddress.Parse(hEndPointProp.Address), iPort));

            (hNewNode as ICommunicationObject).Faulted += OnChannelFaulted;
            (hNewNode as ICommunicationObject).Closed  += OnChannelClosed;

            m_hKnownPeers.TryAdd(hNewNode.RemoteEndPoint, hNewNode);
        }
Exemplo n.º 3
0
        private NodeReference HandleDisconnection(IMasterServerCallback hCb)
        {
            KeyValuePair <IPEndPoint, NodeReference> hRef = (from c in m_hKnownPeers where c.Value.Node == hCb select c).FirstOrDefault();
            NodeReference hRes;

            if (hRef.Key != null && m_hKnownPeers.TryRemove(hRef.Key, out hRes))
            {
                (hRef.Value as ICommunicationObject).Faulted -= OnChannelFaulted;
                (hRef.Value as ICommunicationObject).Closed  -= OnChannelClosed;

                return(hRes);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
 public NodeReference(IMasterServerCallback hCb, IPEndPoint hEp)
 {
     Node           = hCb;
     RemoteEndPoint = hEp;
 }