public static Session CreateSession(NetworkProxy net, AChannel c) { Session session = new Session { Id = IdGenerater.GenerateId() }; session.Awake(net, c); return(session); }
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); }
/// <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); } }
public void Awake(NetworkProxy net, AChannel c) { this.Network = net; this.channel = c; this.requestCallback.Clear(); }