예제 #1
0
        // ルーム一覧取得コールバック
        public static int ReqRoomListCallback(object callbackArg, long argc, object p2, object p3)
        {
            String[] argv  = (String[])p2;
            String[] name = (String[])p3;

            RoomListPacket packet = new RoomListPacket();
            for (long n = 0; n < argc; ++n)
            {
                if (argv[n] != null)
                {
                    if (name[n].CompareTo("name") == 0)
                    {
                        packet.name = argv[n];
                    }
                    else if (name[n].CompareTo("comment") == 0)
                    {
                        packet.comment = argv[n];
                    }
                    else if (name[n].CompareTo("member_num") == 0)
                    {
                        packet.numMenber = uint.Parse(argv[n]);
                    }
                    else if (name[n].CompareTo("member_max") == 0)
                    {
                        packet.maxMenber = uint.Parse(argv[n]);
                    }
                }
            }

            // パケットを追加
            List<RoomListPacket> list = (List<RoomListPacket>)callbackArg;
            list.Add(packet);

            return Sqlite3.SQLITE_OK;
        }
예제 #2
0
        public static bool GetRoomListPacket(ref RoomListPacket packet, byte[] bytes)
        {
            if (IsCmdV1(bytes) && GetCmd(bytes) == Cmd.CMD_USER_INFO)
            {
                packet.numMenber = (uint)bytes[9] << 24;
                packet.numMenber |= (uint)bytes[10] << 16;
                packet.numMenber |= (uint)bytes[11] << 8;
                packet.numMenber |= (uint)bytes[12];

                packet.maxMenber = (uint)bytes[14] << 24;
                packet.maxMenber |= (uint)bytes[15] << 16;
                packet.maxMenber |= (uint)bytes[16] << 8;
                packet.maxMenber |= (uint)bytes[17];

                uint nameLen;
                nameLen = (uint)bytes[19] << 24;
                nameLen |= (uint)bytes[20] << 16;
                nameLen |= (uint)bytes[21] << 8;
                nameLen |= (uint)bytes[22];

                uint commentLen;
                commentLen = (uint)bytes[19 + nameLen + 2] << 24;
                commentLen |= (uint)bytes[20 + nameLen + 2] << 16;
                commentLen |= (uint)bytes[21 + nameLen + 2] << 8;
                commentLen |= (uint)bytes[22 + nameLen + 2];

                byte[] nameBytes = new byte[nameLen];
                Array.Copy(bytes, 24, nameBytes, 0, nameLen);
                byte[] commentBytes = new byte[commentLen];
                Array.Copy(bytes, 24 + nameLen + 2, commentBytes, 0, commentLen);

                packet.name = Encoding.Unicode.GetString(nameBytes);
                packet.comment = Encoding.Unicode.GetString(commentBytes);

                return true;
            }
            return false;
        }
예제 #3
0
 // BEGIN_ROOM_LISTパケット生成
 public static byte[] CreateRoomListPacket(uint num, ref RoomListPacket packet)
 {
     return CreateRoomListPacket(num, packet.name, packet.comment, packet.numMenber, packet.maxMenber);
 }