Example #1
0
        private void OnRegisterServer(InPacket packet)
        {
            var    serverType = (ServerType)packet.Decode <byte>();
            string serverName;

            ServerType = serverType;

            switch (serverType)
            {
            case ServerType.Login:
                var loginInformation = new LoginInformation();

                loginInformation.Decode(packet);
                ServerID   = loginInformation.ID;
                serverName = loginInformation.Name;
                break;

            case ServerType.Game:
                var channelInformation = new ChannelInformation();

                channelInformation.Decode(packet);
                _wvsCenter.WorldInformation.Channels.Add(channelInformation);
                ServerID   = channelInformation.ID;
                serverName = channelInformation.Name;
                break;

            default:
                using (var p = new OutPacket(InteropSendOperations.ServerRegisterResult))
                {
                    p.Encode <bool>(true);
                    SendPacket(p);
                }

                return;
            }

            using (var p = new OutPacket(InteropSendOperations.ServerRegisterResult))
            {
                p.Encode <bool>(false);
                _wvsCenter.WorldInformation.Encode(p);
                SendPacket(p);
            }

            using (var p = new OutPacket(InteropSendOperations.ServerInformation))
            {
                _wvsCenter.WorldInformation.Encode(p);
                _wvsCenter.InteropServer.BroadcastPacket(p, new EveryOneBut(Channel.Id));
            }

            Logger.Info($"Registered {Enum.GetName(typeof(ServerType), serverType)} server, {serverName}");
        }