Пример #1
0
        public void OnDisconnect(ICoreServerClient client)
        {
            switch (client.ServerInfo)
            {
            case ClusterServerInfo cluster:
                _logger.LogInformation($"Cluster server '{cluster.Name}' disconnected from core server.");
                cluster.Worlds.Clear();
                break;

            case WorldServerInfo world:
                _logger.LogInformation($"World server '{world.Name}' disconnected from core server.");
                ICoreServerClient clusterClient = _coreServer.GetClusterServer(world.ParentClusterId);
                var clusterServerInfo           = clusterClient.ServerInfo as ClusterServerInfo;

                if (clusterServerInfo != null)
                {
                    clusterServerInfo.Worlds.Remove(world);
                    _corePacketFactory.SendUpdateWorldList(clusterClient, clusterServerInfo.Worlds);
                }

                break;

            default:
                _logger.LogInformation("Unknown server disconnected from core server.");
                break;
            }
        }
Пример #2
0
 /// <inheritdoc />
 public void SendWelcome(ICoreServerClient client)
 {
     using (var packet = new NetPacket())
     {
         packet.Write((uint)CorePacketType.Welcome);
         client.Send(packet);
     }
 }
Пример #3
0
 /// <inheritdoc />
 public void SendAuthenticationResult(ICoreServerClient client, CoreAuthenticationResultType authenticationResultType)
 {
     using (var packet = new NetPacket())
     {
         packet.Write((uint)CorePacketType.AuthenticationResult);
         packet.Write((uint)authenticationResultType);
         client.Send(packet);
     }
 }
Пример #4
0
        /// <inheritdoc />
        public void SendUpdateWorldList(ICoreServerClient client, IEnumerable <WorldServerInfo> worldServers)
        {
            if (!(client.ServerInfo is ClusterServerInfo))
            {
                return;
            }

            using (var packet = new NetPacket())
            {
                packet.Write((uint)CorePacketType.UpdateClusterWorldsList);
                packet.Write(worldServers.Count());

                foreach (WorldServerInfo world in worldServers)
                {
                    packet.Write(world.Id);
                    packet.Write(world.Host);
                    packet.Write(world.Name);
                    packet.Write(world.Port);
                    packet.Write(world.ParentClusterId);
                }

                client.Send(packet);
            }
        }