Ejemplo n.º 1
0
 public NetworkSession(NetworkClient rNet, AChannel rChannel)
 {
     this.Id       = mIdGenerator++;
     this.Error    = 0;
     this.mChannel = rChannel;
     this.mRequestCallback.Clear();
     this.StartRecv();
 }
Ejemplo n.º 2
0
        public virtual async Task <NetworkSession> Accept()
        {
            AChannel rChannel = await this.mService.AcceptChannel();

            NetworkSession rSession = new NetworkSession(this, rChannel);

            rSession.Parent         = this;
            rChannel.ErrorCallback += (c, e) =>
            {
                rSession.Error = e;
                this.Remove(rSession.Id);
            };
            this.mSessions.Add(rSession.Id, rSession);
            return(rSession);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 创建一个新Session
 /// </summary>
 public virtual NetworkSession Create(IPEndPoint rIpEndPoint)
 {
     try
     {
         AChannel       rChannel = this.mService.ConnectChannel(rIpEndPoint);
         NetworkSession rSession = new NetworkSession(this, rChannel);
         rSession.Parent         = this;
         rChannel.ErrorCallback += (c, e) =>
         {
             rSession.Error = e;
             this.Remove(rSession.Id);
         };
         this.mSessions.Add(rSession.Id, rSession);
         return(rSession);
     }
     catch (Exception e)
     {
         Debug.LogError(e);
         return(null);
     }
 }