Пример #1
0
        /// <summary>
        ///     Reply to a enum query from freelancer clients with our server information.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="enum_payload"></param>
        public void SendCmdEnumResponse(IPEndPoint client, ushort enum_payload)
        {
            // TODO: we could need it
            const bool password = false;
            const bool nodpnsvr = true;

            var application_data = new byte[0];

            FLMsgType.AddAsciiStringLen0(ref application_data,
                                         "1:1:" + server_version + ":-1910309061:" + server_id + ":");
            FLMsgType.AddUnicodeStringLen0(ref application_data, server_description);

            byte[] pkt = { 0x00, 0x03 };
            FLMsgType.AddUInt16(ref pkt, enum_payload);
            FLMsgType.AddUInt32(ref pkt, 0x58 + (uint)server_name.Length * 2); // ReplyOffset
            FLMsgType.AddUInt32(ref pkt, (uint)application_data.Length);       // ReplySize/ResponseSize
            FLMsgType.AddUInt32(ref pkt, 0x50);                                // ApplicationDescSize
            FLMsgType.AddUInt32(ref pkt, (password ? 0x80u : 0x00u) | (nodpnsvr ? 0x40u : 0x00u));
            // ApplicationDescFlags
            FLMsgType.AddUInt32(ref pkt, max_players + 1);                // MaxPlayers
            FLMsgType.AddUInt32(ref pkt, (uint)dplay_sessions.Count + 1); // CurrentPlayers
            FLMsgType.AddUInt32(ref pkt, 0x58);                           // SessionNameOffset
            FLMsgType.AddUInt32(ref pkt, (uint)server_name.Length * 2);   // SessionNameSize
            FLMsgType.AddUInt32(ref pkt, 0);                              // PasswordOffset
            FLMsgType.AddUInt32(ref pkt, 0);                              // PasswordSize
            FLMsgType.AddUInt32(ref pkt, 0);                              // ReservedDataOffset
            FLMsgType.AddUInt32(ref pkt, 0);                              // ReservedDataSize
            FLMsgType.AddUInt32(ref pkt, 0);                              // ApplicationReservedDataOffset
            FLMsgType.AddUInt32(ref pkt, 0);                              // ApplicationReservedDataSize
            FLMsgType.AddArray(ref pkt, ApplicationInstanceGUID);         // ApplicationInstanceGUID
            FLMsgType.AddArray(ref pkt, ApplicationGUID);                 // ApplicationGUID
            FLMsgType.AddUnicodeStringLen0(ref pkt, server_name);         // SessionName
            FLMsgType.AddArray(ref pkt, application_data);                // ApplicationData

            TxStart(pkt, client);
        }