public NetworkSession(NetworkClient rNet, AChannel rChannel) { this.Id = mIdGenerator++; this.Error = 0; this.mChannel = rChannel; this.mRequestCallback.Clear(); this.StartRecv(); }
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); }
/// <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); } }