Beispiel #1
0
 private void inSend(Package package)
 {
     try
     {
         clsSend         send = new clsSend();
         System.DateTime time = DateTime.Now;
         send = send.FromBytes(package.data);
         send.message.hour = time.Hour;
         send.message.min  = time.Minute;
         package.data      = send.ToBytes();
         ServerMain.toAllClient.Enqueue(package);
         ServerMain.oldMessage.Enqueue(send.message);
     }
     catch (Exception e)
     {
         Console.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss") + "]" + e.ToString());
     }
 }
Beispiel #2
0
        private void inLogin(Package package)
        {
            try
            {
                Console.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss") + "]" + "inLogin");

                ServerMain.uIdMax++;
                clsLogin data = new clsLogin(0, "");
                data = data.FromBytes(package.data);
                User user = new User(ServerMain.uIdMax, data.userName, package.user);

                ServerMain.allConnections.Add(package.user);
                ServerMain.allUser.Add(user.uid, user);

                data.uid     = user.uid;
                package.data = data.ToBytes();
                ServerMain.toClient.Enqueue(package);

                clsChangeUser changeUser  = new clsChangeUser(user.uid, user.name);
                Package       packageUser = new Package((uint)Protocol.ADDUSER, changeUser.ToBytes());
                ServerMain.toAllClient.Enqueue(packageUser);

                foreach (uint uid in ServerMain.allUser.Keys)
                {
                    clsChangeUser getUser        = new clsChangeUser(ServerMain.allUser[uid].uid, ServerMain.allUser[uid].name);
                    Package       packageGetUser = new Package((uint)Protocol.ADDUSER, getUser.ToBytes(), package.user);
                    ServerMain.toClient.Enqueue(packageGetUser);
                }

                foreach (Message message in ServerMain.oldMessage)
                {
                    clsSend send        = new clsSend(message);
                    Package packageSend = new Package((uint)Protocol.SEND, send.ToBytes(), package.user);
                    ServerMain.toClient.Enqueue(packageSend);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss") + "]" + e.ToString());
            }
        }