示例#1
0
        public async Task OnLoginOk(Client client, DbUser user)
        {
            // Notice packet. Might be unused in 2014 kTO?
            // Usually would contain a URL and version ID.
            // The client will open that URL if it's:
            // 1) Enabled (a flag)
            // 2) A new version ID (?)
            new OutPacket(OutOpcode.NoticeInfo, client)
            .WriteBytePadding(0x415)
            .Send();

            // Send server select
            var serverList = new OutPacket(OutOpcode.ServerListInfo, client)
                             .WriteInt32(user.Id)         // User ID
                             .WriteInt64(user.AuthToken); // User authentication token for LoginServer

            var worlds = WorldState.GetWorlds();

            lock (worlds)
            {
                serverList.WriteByte((byte)worlds.Sum(x => x.Islands.Count)); // Number of islands.

                // We'll get the data from the worlds. Trickster wants all of the islands.
                foreach (var world in worlds)
                {
                    foreach (var island in world.Islands)
                    {
                        serverList.WriteBoolean(island.Active) // Is server online?
                        .WriteUInt16((ushort)world.Id)         // World number
                        .WriteUInt16((ushort)island.Id)        // Island code
                        .WriteString(world.Name, 32)
                        .WriteString(island.Name, 32)
                        .WriteUInt16((ushort)island.MaxUsers)      // Max users
                        .WriteUInt16((ushort)island.CurrentUsers); // Current users
                    }
                }
            }

            serverList.Send();

            Log.Verbose("Sent notice and server list packet to {0}.", client.Socket.RemoteEndPoint);
        }