Beispiel #1
0
        public void ChatUsers(ClientSockets client)
        {
            var list = new LoginClass().ChatUsers();
            var data = _SM.ChatUsers(list);

            client.SendMessage(data);
        }
Beispiel #2
0
        private void AcceptCallBack(IAsyncResult ar)
        {
            var           handler = _ServerSocket.EndAccept(ar);
            ClientSockets client  = new ClientSockets(handler, "Unknown", this);

            clients.Add(client);
            frmLogin.Status = client.IPAddress + " Connected.";
            BeginAccept();
        }
Beispiel #3
0
        public void ChatMsg(BinaryReader br, ClientSockets client)
        {
            string msg   = br.ReadString().DecryptText();
            string token = br.ReadString().DecryptText();

            client.Log = "'" + token + "' token received from " + client.Port;
            Usertype utype = (Usertype)br.ReadString().DecryptText().TextToEnum <Usertype>();

            if (client.tokenValue == token)
            {
                client.Log = "Token Verified.";
                var data = _SM.ChatMsg(msg, utype);
                client.BroadcastMsg(data);
                client.SendMsgToServer(msg, utype);
            }
        }
Beispiel #4
0
        public void UserValidation(BinaryReader br, ClientSockets client)
        {
            string   uname, pwd;
            Usertype utype;

            uname = br.ReadString().DecryptText();
            pwd   = br.ReadString().DecryptText();
            utype = (Usertype)br.ReadString().DecryptText().TextToEnum <Usertype>();

            LoginClass lc = new LoginClass();

            lc.SetValues(uname, pwd, utype);
            var IsValidated = lc.CheckLogin();

            var data = _SM.UserValidation(IsValidated);

            client.SendMessage(data);
            client.Name        = lc.GetNameOfUser(uname);
            client.IsValidated = true;
        }
Beispiel #5
0
        public void ReadMemoryStream(MemoryStream ms, ClientSockets handler)
        {
            br = new BinaryReader(ms);
            MessageType command = (MessageType)br.ReadString().DecryptText().TextToEnum <MessageType>();

            switch (command)
            {
            case MessageType.UserValidation:
            {
                UserValidation(br, handler);
            }
            break;

            case MessageType.RequestToken:
            {
                RequestToken(br, handler);
            }
            break;

            case MessageType.ChatUsers:
            {
                ChatUsers(handler);
            }
            break;

            case MessageType.ChatMsg:
            {
                ChatMsg(br, handler);
            }
            break;

            default:
            {
            }
            break;
            }
        }
Beispiel #6
0
 public void RequestToken(BinaryReader br, ClientSockets client)
 {
     StaticMethods.TokensList.Add(new TokenClass(client.Port));
     client.TokenRequested = 1;
 }