示例#1
0
        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));
            }
        }
示例#2
0
        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));
        }
示例#3
0
        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));
            }
        }