Example #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);
        }
Example #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;
        }
Example #3
0
        public void Disconnect(StreamSock sock)
        {
            if (sock == null)
            {
                return;
            }

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

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