Esempio n. 1
0
        static void handleRequestEnter(InputPacket ip, User u)
        {
            Console.WriteLine("handlerE");
            OutputPacket op1 = new OutputPacket(512, Protocol.RESPONSE_ENTER);

            u.setUserName(ip.readBytes());
            op1.writeUser(u);

            op1.writeInt32(usrList.Count);

            foreach (User otherUsr in usrList)
            {
                op1.writeUser(otherUsr);
            }
            u.sendPacketAsync(op1);

            OutputPacket op2 = new OutputPacket(512, Protocol.BROADCAST_ENTER);

            op2.writeUser(u);
            foreach (User otherUsr in usrList)
            {
                otherUsr.sendPacketAsync(op2);
            }

            usrList.Add(u);
            //Console.WriteLine("HEOS");
        }
Esempio n. 2
0
        static void handleRequestChangeDestination(InputPacket ip, User u)
        {
            OutputPacket op  = new OutputPacket(512, Protocol.BROADCAST_CHANGE_DESTINATION);
            int          key = u.getKey();

            op.writeInt32(key);
            op.writeVector2(u.posVec);
            Vector2 newDestinaton = ip.readVector2();

            op.writeVector2(newDestinaton);
            u.destinationVec = newDestinaton;

            //Console.WriteLine(key + u.posVec.x + ", " + u.posVec.y + " " + newDestinaton.x + "," + newDestinaton.y);
            foreach (User otherUsr in usrList)
            {
                otherUsr.sendPacketAsync(op);
            }
        }