// 这个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); }
// 这个channelId是由CreateAcceptChannelId生成的 public static void OnAccept(this NetKcpComponent self, long channelId, IPEndPoint ipEndPoint) { Session session = EntityFactory.CreateWithParentAndId <Session, AService>(self, channelId, self.Service); session.RemoteAddress = ipEndPoint; session.AddComponent <SessionAcceptTimeoutComponent>(); // 客户端连接,2秒检查一次recv消息,10秒没有消息则断开 session.AddComponent <SessionIdleCheckerComponent, int>(NetThreadComponent.checkInteral); }
public static Session Create(this NetKcpComponent self, IPEndPoint realIPEndPoint) { long channelId = RandomHelper.RandInt64(); Session session = EntityFactory.CreateWithParentAndId <Session, AService>(self, channelId, self.Service); session.RemoteAddress = realIPEndPoint; session.AddComponent <SessionIdleCheckerComponent, int>(NetThreadComponent.checkInteral); self.Service.GetOrCreate(session.Id, realIPEndPoint); return(session); }
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); }
private static ActorLocationSender GetOrCreate(this ActorLocationSenderComponent self, long id) { if (id == 0) { throw new Exception($"actor id is 0"); } if (self.Children.TryGetValue(id, out Entity actorLocationSender)) { return((ActorLocationSender)actorLocationSender); } actorLocationSender = EntityFactory.CreateWithParentAndId <ActorLocationSender>(self, id); return((ActorLocationSender)actorLocationSender); }