internal static void Start(int serverPort) { mClient = new TcpBsonClient(new IPEndPoint(IPAddress.Loopback, serverPort)); mClient.OnReceiveCommand(OnReceiveCommand); // DO FORGOT START IT mClient.Start(); }
private static void OnClientStoped(TcpBsonClient obj) { Console.WriteLine($"SERVER Client {obj.Cookies["ID"]} Disconnection."); if (!mServer.Clients.Any()) { Console.WriteLine($"SERVER All client has gone."); Environment.Exit(0); } }
private static UserLoginResponse OnUserLoginRequest(UserLoginRequest request, TcpBsonClient client) { try { Console.WriteLine($"SERVER Client({client.Cookies["ID"]}) try login by user {request.UserName}"); // test password only if (request.Password != "123456") { throw new Exception("The password is incorrect"); } return(new UserLoginResponse { Success = true, ErrMessage = "OK", LoginTime = DateTime.Now, UserName = request.UserName }); } catch (Exception e) { return(new UserLoginResponse { Success = false, ErrMessage = e.Message }); } }