예제 #1
0
        public StreamSock Connect(string ip, int port, Action connect_callback)
        {
            StreamSock sock = new StreamSock();

            sock.Connect(ip, port, connect_callback);
            this.AddSock(sock);
            return(sock);
        }
예제 #2
0
        public virtual void SockConnect(string ip, int port, int channel, Action callback, Action disconnected = null)
        {
            SockMsgRouter router = GetRouter(channel);

            StreamSock sock = sockMgr.Connect(ip, port, callback);

            sock.Router = router;
            router.ClearBuff(false);
            sock.socketDisconnection += disconnected;
        }
예제 #3
0
        public void Disconnect(StreamSock sock)
        {
            if (sock == null)
            {
                return;
            }

//            this.RemoveSock(sock);
            removeList.Add(sock);
            sock.Close();
        }
예제 #4
0
        private void RemoveSock(StreamSock sock)
        {
            if (sock == null)
            {
                return;
            }

            lock (((ICollection)sockList).SyncRoot)
            {
                if (sockList.Contains(sock))
                {
                    sockList.Remove(sock);
                }
            }
        }