public override Session OnAccept(AChannel channel)
        {
            Session session = base.OnAccept(channel);

            // 内网accept连接,一分钟检查一次,20分钟没有收到消息则断开, 主要是防止连接过来的机器宕机,导致无法超时主动断开,这里检测时间是连接方的两倍
            session.AddComponent <SessionIdleCheckerComponent, int, int, int>(60 * 1000, 1000 * 60 * 20, int.MaxValue);
            return(session);
        }
Exemple #2
0
        public virtual Session OnAccept(AChannel channel)
        {
            Session session = EntityFactory.CreateWithParent <Session, AChannel>(this, channel);

            this.Sessions.Add(session.Id, session);
            channel.Start();
            return(session);
        }
Exemple #3
0
        /// <summary>
        /// 创建一个新Session
        /// </summary>
        public Session Create(string address)
        {
            AChannel channel = this.Service.ConnectChannel(address);
            Session  session = EntityFactory.CreateWithParent <Session, AChannel>(this, channel);

            this.Sessions.Add(session.Id, session);
            channel.Start();
            return(session);
        }
Exemple #4
0
        /// <summary>
        /// 创建一个新Session
        /// </summary>
        public Session Create(IPEndPoint ipEndPoint)
        {
            AChannel channel = this.Service.ConnectChannel(ipEndPoint);
            Session  session = EntityFactory.CreateWithParent <Session, AChannel>(this, channel);

            this.Sessions.Add(session.Id, session);
            channel.Start();
            return(session);
        }
Exemple #5
0
        public KChannel GetKChannel(long id)
        {
            AChannel aChannel = this.GetChannel(id);

            if (aChannel == null)
            {
                return(null);
            }

            return((KChannel)aChannel);
        }
Exemple #6
0
        public void Awake(AChannel aChannel)
        {
            long timeNow = TimeHelper.Now();

            this.LastRecvTime = timeNow;
            this.LastSendTime = timeNow;

            this.channel = aChannel;
            this.requestCallback.Clear();
            long id = this.Id;

            channel.ErrorCallback += (c, e) =>
            {
                this.Network.Remove(id);
            };
            channel.ReadCallback += this.OnRead;
        }
Exemple #7
0
        public static void Output(IntPtr bytes, int count, IntPtr user)
        {
            if (Instance == null)
            {
                return;
            }
            AChannel aChannel = Instance.GetChannel((uint)user);

            if (aChannel == null)
            {
                Log.Error($"not found kchannel, {(uint)user}");
                return;
            }

            KChannel kChannel = aChannel as KChannel;

            kChannel.Output(bytes, count);
        }
Exemple #8
0
 protected void OnAccept(AChannel channel)
 {
     this.acceptCallback.Invoke(channel);
 }