Пример #1
0
        public void AddServer(string remoteHost, int remotePort)
        {
            IPEndPoint serverHost = GetEndPoint(remoteHost, remotePort);

            server = new NetworkPeer(this);
            server.AddEndpoint(serverHost);
        }
Пример #2
0
        public NetworkPeer RegisterPeer(ushort id, EndPoint ep)
        {
            NetworkPeer identity = null;


            if (peersById.ContainsKey(id))
            {
                identity = peersById[id];
                return(identity);
            }

            string endpoint = ep.ToString();

            if (peersByEndpoint.ContainsKey(endpoint))
            {
                return(peersByEndpoint[endpoint]);
            }

            identity    = new NetworkPeer(protocol);
            identity.id = id;
            identity.AddEndpoint(ep);

            peersById.Add(id, identity);
            peersByEndpoint.Add(endpoint, identity);

            return(identity);
        }