public void CreateServer(ServerOption serverOpt) { try { bool bResult = Setup(new RootConfig(), m_Config, logFactory: new NLogLogFactory()); if (bResult == false) { MainLogger.Error("[ERROR] 서버 네트워크 설정 실패 ㅠㅠ"); return; } else { MainLogger = base.Logger; } CreateComponent(serverOpt); MainLogger.Info("서버 생성 성공"); } catch (Exception ex) { MainLogger.Error($"[ERROR] 서버 생성 실패: {ex.ToString()}"); } }
public void InitConfig(ServerOption option) { m_Config = new ServerConfig { Port = option.Port, Ip = "Any", MaxConnectionNumber = option.MaxConnectionNumber, Mode = SocketMode.Tcp, Name = option.Name }; }
public MainServer(IHostApplicationLifetime appLifetime, IOptions <ServerOption> serverConfig, ILogger <MainServer> logger) : base(new DefaultReceiveFilterFactory <ReceiveFilter, EFBinaryRequestInfo>()) { ServerOpt = serverConfig.Value; AppLogger = logger; AppLifetime = appLifetime; NewSessionConnected += new SessionHandler <NetworkSession>(OnConnected); SessionClosed += new SessionHandler <NetworkSession, CloseReason>(OnClosed); NewRequestReceived += new RequestHandler <NetworkSession, EFBinaryRequestInfo>(OnPacketReceived); }
public ERROR_CODE CreateComponent(ServerOption serverOpt) { Room.NetSendFunc = this.SendData; RoomMgr.CreateRooms(serverOpt); MainPacketProcessor = new PacketProcessor(); MainPacketProcessor.NetSendFunc = this.SendData; MainPacketProcessor.DistributePacket = this.Distribute; MainPacketProcessor.CreateAndStart(RoomMgr.GetRoomsList(), serverOpt); MainLogger.Info("CreateComponent - Success"); return(ERROR_CODE.NONE); }
public void CreateRooms(ServerOption serverOpt) { var maxRoomCount = serverOpt.RoomMaxCount; var startNumber = serverOpt.RoomStartNumber; var maxUserCount = serverOpt.RoomMaxUserCount; for (int i = 0; i < maxRoomCount; ++i) { var roomNumber = (startNumber + i); var room = new Room(); room.Init(i, roomNumber, maxUserCount); RoomsList.Add(room); } }
public void CreateAndStart(List <Room> roomList, ServerOption serverOpt) { var maxUserCount = serverOpt.RoomMaxCount * serverOpt.RoomMaxUserCount; UserMgr.Init(maxUserCount); RoomList = roomList; var minRoomNum = RoomList[0].Number; var maxRoomNum = RoomList[0].Number + RoomList.Count() - 1; RoomNumberRange = new Tuple <int, int>(minRoomNum, maxRoomNum); RegistPacketHandler(); IsThreadRunning = true; ProcessThread = new System.Threading.Thread(this.Process); ProcessThread.Start(); }