예제 #1
0
        public static Session CreateSession(NetworkProxy net, AChannel c)
        {
            Session session = new Session {
                Id = IdGenerater.GenerateId()
            };

            session.Awake(net, c);
            return(session);
        }
예제 #2
0
        public virtual async Task <Session> Accept()
        {
            AChannel channel = await this.Service.AcceptChannel();

            Session session = CreateSession(this, channel);

            channel.ErrorCallback += (c, e) => { this.Remove(session.Id); };
            this.sessions.Add(session.Id, session);
            session.Start();
            return(session);
        }
예제 #3
0
 /// <summary>
 /// 创建一个新Session
 /// </summary>
 public virtual Session Create(IPEndPoint ipEndPoint)
 {
     try {
         AChannel channel = this.Service.ConnectChannel(ipEndPoint);
         Session  session = CreateSession(this, channel);
         channel.ErrorCallback += (c, e) => { this.Remove(session.Id); };
         this.sessions.Add(session.Id, session);
         return(session);
     }
     catch (Exception e) {
         Log.Error(e.ToString());
         return(null);
     }
 }
예제 #4
0
 public void Awake(NetworkProxy net, AChannel c)
 {
     this.Network = net;
     this.channel = c;
     this.requestCallback.Clear();
 }