public void OnUpdateClusterWorldsList(IClusterCoreClient _, INetPacketStream packet)
        {
            int numberOfWorldServers = packet.Read <int>();

            _clusterServer.WorldServers.Clear();

            for (var i = 0; i < numberOfWorldServers; ++i)
            {
                int    serverId        = packet.Read <int>();
                string serverHost      = packet.Read <string>();
                string serverName      = packet.Read <string>();
                int    serverPort      = packet.Read <int>();
                int    parentClusterId = packet.Read <int>();

                if (parentClusterId != _clusterServer.ClusterConfiguration.Id)
                {
                    _logger.LogCritical($"Cannot add server '{serverName}' to current cluster. Ids doesn't match.");
                    continue;
                }

                var worldServer = new WorldServerInfo(serverId, serverName, serverHost, serverPort, parentClusterId);

                _clusterServer.WorldServers.Add(worldServer);
            }
        }
        public void OnAuthenticationResult(IClusterCoreClient _, INetPacketStream packet)
        {
            var authenticationResult = (CoreAuthenticationResultType)(packet.Read <uint>());

            switch (authenticationResult)
            {
            case CoreAuthenticationResultType.Success:
                _logger.LogInformation("Cluster Core client authenticated succesfully.");
                return;

            case CoreAuthenticationResultType.FailedClusterExists:
                _logger.LogCritical("Unable to authenticate Cluster Core client. Reason: an other Cluster server (with the same id) is already connected.");
                break;

            case CoreAuthenticationResultType.FailedUnknownServer:
                _logger.LogCritical("Unable to authenticate Cluster Core client. Reason: ISC server doesn't recognize this server. You probably have to update all servers.");
                break;

            default:
                _logger.LogTrace("Core authentification result: {0}", authenticationResult);
                _logger.LogCritical("Unable to authenticate Cluster Core client. Reason: Cannot recognize Core server. You probably have to update all servers.");
                break;
            }

            if (Core.Common.OperatingSystem.IsWindows())
            {
                Console.ReadLine();
            }

            Environment.Exit((int)authenticationResult);
        }
Exemple #3
0
        /// <inheritdoc />
        public void SendAuthentication(IClusterCoreClient client, ClusterConfiguration clusterConfiguration)
        {
            using (var packet = new NetPacket())
            {
                packet.Write((uint)CorePacketType.Authenticate);
                packet.Write(clusterConfiguration.Id);
                packet.Write(clusterConfiguration.Name);
                packet.Write(clusterConfiguration.Host);
                packet.Write(clusterConfiguration.Port);
                packet.Write((byte)ServerType.Cluster);

                client.Send(packet);
            }
        }
 public void OnWelcome(IClusterCoreClient client)
 {
     _corePacketFactory.SendAuthentication(client, _clusterServer.ClusterConfiguration);
 }
 /// <summary>
 /// Creates a new <see cref="ClusterCoreClientService"/>
 /// </summary>
 /// <param name="clusterCoreClient"></param>
 public ClusterCoreClientService(IClusterCoreClient clusterCoreClient)
 {
     _clusterCoreClient = clusterCoreClient;
 }