public Tuple <bool, string> InitAndStartNetwork(ServerNetworkConfig netConfig, ServerAppConfig appConfig) { AppConfig = appConfig; NetConfig = new NetworkConfig() { IP = netConfig.IP, Port = netConfig.Port, EngineDllName = netConfig.EngineDllName, MaxAcceptCount = netConfig.MaxAcceptCount, ThreadCount = netConfig.ThreadCount, ProtocolOption = 0, ProtocolID = 0, MaxBufferSize = netConfig.MaxBufferSize, MaxPacketSize = netConfig.MaxPacketSize, }; var result = ServerNet.Init(NetConfig, null, null); if (result != NET_ERROR_CODE_N.SUCCESS) { return(new Tuple <bool, string>(false, result.ToString())); } if (ServerNet.Start(NetConfig.ProtocolID) == false) { return(new Tuple <bool, string>(false, NET_ERROR_CODE_N.NETWORK_START_FAIL.ToString())); } else { IsStartServerNetwork = true; } return(new Tuple <bool, string>(true, NET_ERROR_CODE_N.SUCCESS.ToString())); }
public Tuple<bool, string> InitAndStartNetwork(ServerNetworkConfig netConfig, ServerAppConfig appConfig) { AppConfig = appConfig; NetConfig = new NetworkConfig() { IP = netConfig.IP, Port = netConfig.Port, EngineDllName = netConfig.EngineDllName, MaxAcceptCount = netConfig.MaxAcceptCount, ThreadCount = netConfig.ThreadCount, ProtocolOption = 0, ProtocolID = 0, MaxBufferSize = netConfig.MaxBufferSize, MaxPacketSize = netConfig.MaxPacketSize, }; var result = ServerNet.Init(NetConfig, null, null); if (result != NET_ERROR_CODE_N.SUCCESS) { return new Tuple<bool, string>(false,result.ToString()); } if (ServerNet.Start(NetConfig.ProtocolID) == false) { return new Tuple<bool, string>(false, NET_ERROR_CODE_N.NETWORK_START_FAIL.ToString()); } else { IsStartServerNetwork = true; } return new Tuple<bool, string>(true, NET_ERROR_CODE_N.SUCCESS.ToString()); }
private void Form1_Load(object sender, EventArgs e) { workProcessTimer.Tick += new EventHandler(OnProcessTimedEvent); workProcessTimer.Interval = new TimeSpan(0, 0, 0, 0, 1); workProcessTimer.Start(); var netConfig = new ChatServerLib.ServerNetworkConfig() { IP = "127.0.0.1", Port = textBoxPort.Text.ToUInt16(), EngineDllName = "CGSFNet.dll", MaxAcceptCount = textBoxMaxUserCount.Text.ToInt32(), ThreadCount = textBoxPacketThreadCount.Text.ToInt32(), MaxBufferSize = textBoxMaxBufferSize.Text.ToInt32(), MaxPacketSize = textBoxMaxPacketSize.Text.ToInt32(), }; var appConfig = new ChatServerLib.ServerAppConfig() { MaxTotalUserCount = textBoxMaxUserCount.Text.ToInt32(), MaxLobbyCount = textBoxLobbyCount.Text.ToInt32(), MaxLobbyUserCount = textBoxMaxUserPerLobby.Text.ToInt32(), ProcessThreadCount = textBoxPacketThreadCount.Text.ToInt32(), DBThreadCount = textBoxDBThreadCount.Text.ToInt32(), }; var result = ServerLib.InitAndStartNetwork(netConfig, appConfig); if (result.Item1 == false) { DevLog.Write(string.Format("[Init] 네트워크 라이브러리 초기화 및 시작 실패. {0}", result.Item2.ToString()), LOG_LEVEL.ERROR); return; } DevLog.Write(string.Format("[Start] 네트워크 시작"), LOG_LEVEL.INFO); var errorCode = ServerLib.CreateSystem(appConfig); if (errorCode != CSCommonLib.ERROR_CODE.NONE) { DevLog.Write(string.Format("[Init] CreateSystem 실패. {0}", errorCode), LOG_LEVEL.ERROR); return; } DevLog.Write(string.Format("[Start] CreateSystem 완료"), LOG_LEVEL.INFO); }