Пример #1
0
        public USocket NewSocket(SocketListner listener, Protocal protocal)
        {
            ShortUSocket socket = null;

            if (_lstPool.Count == 0)
            {
                socket    = new ShortUSocket(listener, protocal);
                socket.ID = _nIDIndex++;
                Debug.Log("<color=cyan>" + "创建" + socket.ID + "号Socket" + "</color>");
            }
            else
            {
                socket = _lstPool.Dequeue();
                socket.setLister(listener);
                socket.setProtocal(protocal);
                Debug.Log("<color=cyan>" + "直接使用" + socket.ID + "号Socket" + "</color>");
            }
            socket.IsInPool     = false;
            socket._actionClose = OnShortSocketClose;
            return(socket);
        }
Пример #2
0
 /**
  * 装入一个监听器
  */
 public void setLister(SocketListner listner)
 {
     this.listner = listner;
 }
Пример #3
0
 public ShortUSocket(SocketListner listner, Protocal protocal) : base(listner, protocal)
 {
 }
Пример #4
0
 /**
  * 构造
  */
 public USocket(SocketListner listner, Protocal protocal)
 {
     this.listner  = listner;
     this.protocal = protocal;
     buf           = new byte[1024 * 4];
 }