Esempio n. 1
0
        // 这个channelId是由CreateAcceptChannelId生成的
        public static void OnAccept(this NetInnerComponent self, long channelId, IPEndPoint ipEndPoint)
        {
            Session session = EntityFactory.CreateWithParentAndId <Session, AService>(self, channelId, self.Service);

            session.RemoteAddress = ipEndPoint;
            //session.AddComponent<SessionIdleCheckerComponent, int, int, int>(NetThreadComponent.checkInteral, NetThreadComponent.recvMaxIdleTime, NetThreadComponent.sendMaxIdleTime);
        }
Esempio n. 2
0
        // 这个channelId是由CreateConnectChannelId生成的
        public static Session Create(this NetInnerComponent self, IPEndPoint ipEndPoint)
        {
            uint    localConn = self.Service.CreateRandomLocalConn();
            long    channelId = self.Service.CreateConnectChannelId(localConn);
            Session session   = self.CreateInner(channelId, ipEndPoint);

            return(session);
        }
Esempio n. 3
0
        public static void OnError(this NetInnerComponent self, long channelId, int error)
        {
            Session session = self.GetChild <Session>(channelId);

            if (session == null)
            {
                return;
            }

            session.Error = error;
            session.Dispose();
        }
Esempio n. 4
0
        public static void OnRead(this NetInnerComponent self, long channelId, MemoryStream memoryStream)
        {
            Session session = self.GetChild <Session>(channelId);

            if (session == null)
            {
                return;
            }

            session.LastRecvTime = TimeHelper.ClientNow();
            self.MessageDispatcher.Dispatch(session, memoryStream);
        }
Esempio n. 5
0
        // 内网actor session,channelId是进程号
        public static Session Get(this NetInnerComponent self, long channelId)
        {
            Session session = self.GetChild <Session>(channelId);

            if (session == null)
            {
                IPEndPoint ipEndPoint = StartProcessConfigCategory.Instance.Get((int)channelId).InnerIPPort;
                session = self.CreateInner(channelId, ipEndPoint);
            }

            return(session);
        }
Esempio n. 6
0
        private static Session CreateInner(this NetInnerComponent self, long channelId, IPEndPoint ipEndPoint)
        {
            Session session = EntityFactory.CreateWithParentAndId <Session, AService>(self, channelId, self.Service);

            session.RemoteAddress = ipEndPoint;

            self.Service.GetOrCreate(channelId, ipEndPoint);

            //session.AddComponent<InnerPingComponent>();
            //session.AddComponent<SessionIdleCheckerComponent, int, int, int>(NetThreadComponent.checkInteral, NetThreadComponent.recvMaxIdleTime, NetThreadComponent.sendMaxIdleTime);

            return(session);
        }