コード例 #1
0
        public static byte[] HandleMessage(ClientInfo client, byte[] data)
        {
            List <byte[]> msgs;

            Log.WriteLine(1, "[DO] Handling DO_FetchRequestMessage...");
            MemoryStream m = new MemoryStream(data);

            m.Seek(3, 0);
            uint dupObj = Helper.ReadU32(m);

            switch (dupObj)
            {
            case 0x5C00001:
                msgs = new List <byte[]>();
                if (!client.bootStrapDone)
                {
                    foreach (DupObj obj in DO_Session.DupObjs)
                    {
                        msgs.Add(DO_CreateDuplicaMessage.Create(obj, 2));
                    }
                    client.bootStrapDone = true;
                }
                msgs.Add(DO_MigrationMessage.Create(client.callCounterDO_RMC++, new DupObj(DupObjClass.Station, 1), new DupObj(DupObjClass.Station, client.stationID), new DupObj(DupObjClass.Station, client.stationID), 3, new List <uint>()
                {
                    new DupObj(DupObjClass.Station, client.stationID)
                }));
                return(DO_BundleMessage.Create(client, msgs));

            default:
                Log.WriteLine(1, "[DO] Handling DO_FetchRequest unknown dupObj 0x" + dupObj.ToString("X8") + "!");
                return(new byte[0]);
            }
        }
コード例 #2
0
        public static byte[] HandleMessage(ClientInfo client, byte[] data, byte sessionID)
        {
            Log.WriteLine(1, "[DO] Handling DO_JoinRequestMessage...");
            SendConnectionRequest(client, sessionID);
            List <byte[]> msgs = new List <byte[]>();

            InitSession(client);
            DupObj          clientStation = new DupObj(DupObjClass.Station, client.stationID, 1);
            Payload_Station ps            = new Payload_Station();

            ps.connectionInfo.m_strStationURL1 = "prudp:/address=255.0.0.0;port=4";
            ps.stationState       = STATIONSTATE.JoiningSession;
            clientStation.Payload = ps;
            DO_Session.DupObjs.Add(clientStation);
            msgs.Add(DO_JoinResponseMessage.Create(1, new DupObj(DupObjClass.Station, client.stationID, 1)));
            msgs.Add(DO_CreateAndPromoteDuplicaMessage.Create(client.callCounterDO_RMC++, clientStation, 2));
            msgs.Add(DO_MigrationMessage.Create(client.callCounterDO_RMC++, new DupObj(DupObjClass.Station, 1), new DupObj(DupObjClass.Station, client.stationID), new DupObj(DupObjClass.Station, client.stationID), 3, new List <uint>()));
            clientStation.Master.ID = client.stationID;
            return(DO_BundleMessage.Create(client, msgs));
        }
コード例 #3
0
        public static byte[] HandleMessage(ClientInfo client, byte[] data)
        {
            Log.WriteLine(1, "[DO] Handling DO_MigrationMessage");
            MemoryStream m = new MemoryStream(data);

            m.Seek(1, 0);
            ushort callID = Helper.ReadU16(m);
            DupObj from   = new DupObj(Helper.ReadU32(m));
            DupObj obj    = new DupObj(Helper.ReadU32(m));

            obj.Master = from;
            DupObj to   = new DupObj(Helper.ReadU32(m));
            DupObj fobj = DO_Session.FindObj(obj);

            if (fobj == null)
            {
                Log.WriteLine(1, "[DO] DupObj " + obj.getDesc() + " not found!", Color.Red);
            }
            else if (fobj.Master == (uint)to)
            {
                Log.WriteLine(1, "[DO] Master of DupObj " + fobj.getDesc() + " alread set, ignored!", Color.Orange);
            }
            else
            {
                fobj.Master = to;
            }
            List <byte[]> msgs = new List <byte[]>();

            msgs.Add(DO_Outcome.Create(callID, 0x60001));
            if (fobj != null && fobj.Class == DupObjClass.SES_cl_Player_NetZ && fobj.ID == 257 && !client.matchStartSent)
            {
                /*
                 * msgs.Add(DO_RMCRequestMessage.Create(client.callCounterDO_RMC++,
                 *  0x1006,
                 *  new DupObj(DupObjClass.Station, 1),
                 *  new DupObj(DupObjClass.SES_cl_Player_NetZ, 257),
                 *  (ushort)DO_RMCRequestMessage.DOC_METHOD.SetPlayerState,
                 *  new byte[] { 0x34, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0xC0, 0x05, 0x00, 0x10, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
                 *  ));
                 * msgs.Add(DO_RMCRequestMessage.Create(client.callCounterDO_RMC++,
                 *  0x1006,
                 *  new DupObj(DupObjClass.Station, 1),
                 *  new DupObj(DupObjClass.SES_cl_Player_NetZ, 257),
                 *  (ushort)DO_RMCRequestMessage.DOC_METHOD.SetPlayerRDVInfo,
                 *  new byte[] { 0x01, 0x00, 0x00, 0x00 }
                 *  ));
                 */
                SessionInfosParameter p = new SessionInfosParameter();
                p.sParams.byte25 = 1;
                m = new MemoryStream();
                m.WriteByte(2); //update
                Helper.WriteU32(m, new DupObj(DupObjClass.SES_cl_SessionInfos, 2));
                m.WriteByte(2); //part
                p.toBuffer(m);
                msgs.Add(m.ToArray());

                p.sParams.byte25 = 2;
                m = new MemoryStream();
                m.WriteByte(2); //update
                Helper.WriteU32(m, new DupObj(DupObjClass.SES_cl_SessionInfos, 2));
                m.WriteByte(2); //part
                p.toBuffer(m);
                msgs.Add(m.ToArray());

                msgs.Add(DO_RMCRequestMessage.Create(client.callCounterDO_RMC++,
                                                     0x806,
                                                     new DupObj(DupObjClass.Station, 1),
                                                     new DupObj(DupObjClass.SES_cl_SessionInfos, 2),
                                                     (ushort)DO_RMCRequestMessage.DOC_METHOD.OnStartMatch,
                                                     new byte[] { }
                                                     ));
                client.matchStartSent = true;
            }
            return(DO_BundleMessage.Create(client, msgs));
        }
コード例 #4
0
        public static byte[] HandleMessage(ClientInfo client, QPacket p, byte[] data)
        {
            Log.WriteLine(1, "[DO] Handling DO_RMCRequestMessage...");
            MemoryStream m = new MemoryStream(data);

            m.Seek(1, 0);
            ushort     callID       = Helper.ReadU16(m);
            uint       flags        = Helper.ReadU32(m);
            uint       station      = Helper.ReadU32(m);
            uint       targetObject = Helper.ReadU32(m);
            DOC_METHOD method       = (DOC_METHOD)Helper.ReadU16(m);

            Log.WriteLine(2, "[DO] RMC Call ID      : 0x" + callID.ToString("X4"));
            Log.WriteLine(2, "[DO] RMC Call Flags   : 0x" + flags.ToString("X8"));
            Log.WriteLine(2, "[DO] RMC Call Station : 0x" + station.ToString("X8"));
            Log.WriteLine(2, "[DO] RMC Call DupObj  : 0x" + targetObject.ToString("X8") + " " + new DupObj(targetObject).getDesc());
            byte[]        buff;
            MemoryStream  m2;
            List <byte[]> msgs;

            switch (method)
            {
            case DOC_METHOD.SyncRequest:
                Log.WriteLine(1, "[DO] Handling SyncRequest...");
                ulong time = Helper.ReadU64(m);
                buff = Create(client.callCounterDO_RMC++, 0x83C, new DupObj(DupObjClass.Station, 1), new DupObj(DupObjClass.SessionClock, 1), 6, new Payload_SyncResponse(time).toBuffer());
                m2   = new MemoryStream();
                Helper.WriteU32(m2, (uint)buff.Length);
                m2.Write(buff, 0, buff.Length);
                m2.WriteByte((byte)QPacket.MakeChecksum(m2.ToArray(), 0));
                p.payload       = m2.ToArray();
                p.payloadSize   = (ushort)p.payload.Length;
                p.m_uiSignature = client.IDsend;
                DO.Send(p, client);
                return(null);

            case DOC_METHOD.RequestIDRangeFromMaster:
                Log.WriteLine(1, "[DO] Handling RequestIDRangeFromMaster...");
                return(DO_RMCResponseMessage.Create(callID, 0x60001, new byte[] { 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00 }));

            case DOC_METHOD.IncreasePlayerNb:
                Log.WriteLine(1, "[DO] Handling IncreasePlayerNb...");
                msgs = new List <byte[]>();
                msgs.Add(new byte[] { 0x02, 0x02, 0x00, 0x40, 0x05, 0x01, 0x01, 0x00, 0x00, 0x00 });
                msgs.Add(DO_RMCResponseMessage.Create(callID, 0x60001, new byte[] { 0x00 }));
                return(DO_BundleMessage.Create(client, msgs));

            case DOC_METHOD.AskForSettingPlayerParameters:
                Log.WriteLine(1, "[DO] Handling AskForSettingPlayerParameters...");
                int len = (int)(data.Length - m.Position);
                buff = new byte[len];
                m.Read(buff, 0, len);
                client.settings = buff;
                msgs            = new List <byte[]>();
                msgs.Add(DO_RMCRequestMessage.Create(client.callCounterDO_RMC++,
                                                     0x1006,
                                                     new DupObj(DupObjClass.Station, 1),
                                                     new DupObj(DupObjClass.SES_cl_Player_NetZ, 257),
                                                     (ushort)DO_RMCRequestMessage.DOC_METHOD.SetPlayerParameters,
                                                     client.settings
                                                     ));
                msgs.Add(DO_RMCResponseMessage.Create(callID, 0x60001, new byte[] { 0x00 }));
                return(DO_BundleMessage.Create(client, msgs));

            case DOC_METHOD.AskForSettingPlayerState:
                Log.WriteLine(1, "[DO] Handling AskForSettingPlayerState...");
                msgs = new List <byte[]>();
                msgs.Add(DO_RMCRequestMessage.Create(client.callCounterDO_RMC++,
                                                     0x1006,
                                                     new DupObj(DupObjClass.Station, 1),
                                                     new DupObj(DupObjClass.SES_cl_Player_NetZ, 257),
                                                     (ushort)DO_RMCRequestMessage.DOC_METHOD.SetPlayerState,
                                                     BitConverter.GetBytes(Helper.ReadU32(m))
                                                     ));
                msgs.Add(DO_RMCResponseMessage.Create(callID, 0x60001, new byte[] { 0x00 }));
                return(DO_BundleMessage.Create(client, msgs));

            default:
                Log.WriteLine(1, "[DO] Error: Unhandled DOC method: " + method + "!");
                return(null);
            }
        }