private void OnSignUpRequest(ClientManager clientManager, Message message) { var data = Encoding.ASCII.GetString(message.Value).Split(';'); var login = data[0]; var password = data[1]; var success = DbConnection.Instance().SignUp(login, password); if (!success) { clientManager.SendMessage(MessageFactory(MessageType.SignUpUnsuccessful, null)); } else { clientManager.SendMessage(MessageFactory(MessageType.SignUpSuccessful, null)); } }
private void OnSaveRequest(ClientManager clientManager, Message message) { var texts = Encoding.Unicode.GetString(message.Value).Split(';'); try { DbConnection.Instance().SaveRequest(texts[0], texts[1], DateTime.Now, clientManager.User); } catch (Exception e) { ConsoleMessenger.Log(ConsoleMessenger.Prefix.Error, "Couldn't save changes\n" + e.Message); clientManager.SendMessage(MessageFactory(MessageType.SaveUnsuccessful, null)); return; } ConsoleMessenger.Log(ConsoleMessenger.Prefix.Message, "Saved new request"); clientManager.SendMessage(MessageFactory(MessageType.SaveSuccessful, null)); }
private void OnLoginRequest(ClientManager clientManager, Message message) { var data = Encoding.ASCII.GetString(message.Value).Split(';'); var login = data[0]; var password = data[1]; byte[] requests; requests = DbConnection.Instance().GetRequests(login, password); if (requests != null) { clientManager.User = login; ConsoleMessenger.Log(ConsoleMessenger.Prefix.Message, "Logged in " + login); clientManager.SendMessage(MessageFactory(MessageType.LoginSuccessful, requests)); } else { clientManager.SendMessage(MessageFactory(MessageType.LoginUnsuccessful, null)); } }