public static void HandleSetServerStatus(SetServerStatusMessage message, TransitionClient client) { var server = ServerRecord.GetWorldServer(client.ServerId); ServersManager.Instance.SetServerStatus(client.ServerId, message.Status); logger.White("Server " + server.Name + " status is now " + message.Status.ToString()); }
public bool DisconnectClient(AuthClient newClient) { bool succes = false; AuthClient client = AuthServer.Instance.GetClients().Find(x => x.Account != null && x.Account.Id == newClient.Account.Id); if (client != null) { client.Disconnect(); succes = true; } else { if (newClient.Account.LastSelectedServerId != 0) { TransitionClient server = TransitionServer.Instance.GetServerClient(newClient.Account.LastSelectedServerId); var serverData = ServerRecord.GetWorldServer(newClient.Account.LastSelectedServerId); if (server != null && server.IsConnected && serverData != null && serverData.Status != ServerStatusEnum.STARTING) // Online { MessagePool.SendRequest <DisconnectClientResultMessage>(server, new DisconnectClientRequestMessage { AccountId = newClient.Account.Id, }, delegate(DisconnectClientResultMessage message) { succes = message.IsSucces; }, delegate() { this.OnTransitionFailed(newClient); }); } else { succes = false; } } } return(succes); }
public void UnregisterWorld(ushort serverId) { ServerRecord world = ServerRecord.GetWorldServer(serverId); if (world != null) { this.SetServerStatus(serverId, ServerStatusEnum.OFFLINE); logger.White("Server Unregistred (" + world.Name + ")"); } }
/// <summary> /// Methode appelée lorsque le client est authentifié avec succès. /// </summary> /// <param name="client"></param> /// <param name="autoconnect"></param> private static void Login(AuthClient client, bool autoconnect) { bool wasConnected = ServersManager.Instance.DisconnectClient(client); AuthServer.Instance.AddClient(client); bool hasRights = client.Account.Role > ServerRoleEnum.Player ? true : false; client.Send(new IdentificationSuccessMessage(hasRights, wasConnected, client.Account.Username, client.Account.Nickname, client.Account.Id, 0, string.Empty, 0, 0, DateTime.Now.DateTimeToUnixTimestamp(), 0)); if (!autoconnect) { client.SendServerList(); return; } else { if (client.Account.LastSelectedServerId != 0) { ServerRecord server = ServerRecord.GetWorldServer(client.Account.LastSelectedServerId); if (server != null && server.Status == ServerStatusEnum.ONLINE) { client.ProcessServerSelection(server); } else { client.SendServerList(); } } else { client.SendServerList(); } } }
public void RegisterWorld(ushort serverId, string name, sbyte type, string host, int port) { ServerRecord world = ServerRecord.GetWorldServer(serverId); if (world != null) { if (world.Host != host || world.Port != port || world.Name != name || world.Type != type) { world.Host = host; world.Port = port; world.Name = name; world.Type = type; logger.White("Updating server informations...(" + name + ")"); world.UpdateInstantElement(); } this.SetServerStatus(serverId, ServerStatusEnum.STARTING); logger.White(string.Format("Server Registred : {0} ({1}:{2})", world.Name, world.Host, world.Port)); } else { var newWorld = new ServerRecord(serverId, name, type, host, port); if (ServerRecord.CanBeAdded(newWorld)) { ServerRecord.AddWorldServer(newWorld); this.SetServerStatus(serverId, ServerStatusEnum.STARTING); logger.White(string.Format("New server added : {0} ({1}:{2})", newWorld.Name, newWorld.Host, newWorld.Port)); } else { logger.Alert("A new server try to join Auth but he is not allowed (Id or Ip and Port are reserved)"); } } }
public static void HandleServerSelection(ServerSelectionMessage message, AuthClient client) { lock (Locker) client.ProcessServerSelection(ServerRecord.GetWorldServer(message.serverId)); }