/// <summary> /// 所有连接到服务器的客户端的会话 都会从这个方法中得到 /// </summary> /// <param name="channel">Channel.</param> public void OnAccept(AChannel channel) { Session session = ComponentFactory.CreateWithParent <Session, AChannel>(this, channel); this.sessions.Add(session.Id, session); session.Start(); }
public void OnAccept(AChannel channel) { Session session = new Session(this, channel); this.sessions.Add(session.Id, session); session.Start(); }
/// <summary> /// 创建一个新Session 这个才是客户端用到的 /// </summary> public Session Create(string address) { AChannel channel = this.Service.ConnectChannel(address); Session session = ComponentFactory.CreateWithParent <Session, AChannel>(this, channel); this.sessions.Add(session.Id, session); session.Start(); return(session); }
/// <summary> /// 创建一个新Session 这个才是客户端用到的 /// </summary> public Session Create(IPEndPoint ipEndPoint) { AChannel channel = this.Service.ConnectChannel(ipEndPoint); Session session = ComponentFactory.CreateWithParent <Session, AChannel>(this, channel); this.sessions.Add(session.Id, session); session.Start(); return(session); }
/// <summary> /// 创建一个新Session /// </summary> public Session Create(string address) { AChannel channel = this.Service.ConnectChannel(address); Session session = new Session(this, channel); this.sessions.Add(session.Id, session); session.Start(); return(session); }
/// <summary> /// 创建一个新Session /// </summary> public Session Create(IPEndPoint ipEndPoint, Action <bool> OnConnnect = null) { if (this.Service == null) { return(null); } AChannel channel = this.Service.ConnectChannel(ipEndPoint); Session session = new Session(this, channel, OnConnnect); this.sessions.Add(session.Id, session); session.Start(); return(session); }
/// <summary> /// 创建一个Session /// </summary> public Session Create(string address) { //这里以TCP为例注释: //TCP的话 是调用TService的ConnectChannel 内部进行构建一个TChannel //注意:TChannel是对Socket的第一层封装,包括:连接、接收、发送、构建报文、拆解报文...为外部提供Socket交互的接口 AChannel channel = this.Service.ConnectChannel(address); //创建session会话实体 将自身作为session的父物体 并且把TChannel传递进去 Session session = ComponentFactory.CreateWithParent <Session, AChannel>(this, channel); //注意:框架会调用到session的Awake方法,并且将TChannel传递给Awake方法,然后才继续往下执行 //管理该会话实体 this.sessions.Add(session.Id, session); //调用会话实体的Start方法 session.Start(); return(session); }