public void UpdateWorldServer(string name, Uri location, RealmFlags flags, RealmCategory category, RealmType type, RealmStatus status, int characterCount, int characterCapacity, Version clientVersion) { var id = OperationContext.Current.SessionId; Contract.Assume(!string.IsNullOrEmpty(id)); Realm realm = null; RealmManager.Instance.PostWait(mgr => realm = mgr.GetRealm(id)).Wait(); if (realm == null) { throw new InvalidOperationException("A realm has not registered before updating itself."); } RealmManager.Instance.PostAsync(() => { realm.Name = name; realm.Location = location; realm.Flags = flags; realm.Category = category; realm.Type = type; realm.Status = status; realm.Population = characterCount; realm.Capacity = characterCapacity; realm.ClientVersion = clientVersion; }); }
public void UpdateWorldServer(string name, Uri location, RealmFlags flags, RealmCategory category, RealmType type, RealmStatus status, int characterCount, int characterCapacity, Version clientVersion) { var id = OperationContext.Current.SessionId; Contract.Assume(!string.IsNullOrEmpty(id)); Realm realm = null; RealmManager.Instance.PostWait(mgr => realm = mgr.GetRealm(id)).Wait(); if (realm == null) throw new InvalidOperationException("A realm has not registered before updating itself."); RealmManager.Instance.PostAsync(() => { realm.Name = name; realm.Location = location; realm.Flags = flags; realm.Category = category; realm.Type = type; realm.Status = status; realm.Population = characterCount; realm.Capacity = characterCapacity; realm.ClientVersion = clientVersion; }); }
public void UpdateWorldServer(string name, Uri location, RealmFlags flags, RealmCategory category, RealmType type, RealmStatus status, int characterCount, int characterCapacity, Version clientVersion) { Contract.Requires(!string.IsNullOrEmpty(name)); Contract.Requires(location != null); Contract.Requires(characterCount >= 0); Contract.Requires(characterCapacity >= 0); Contract.Requires(clientVersion != null); }
public byte[] GetRealmList(uint build, string subRegion) { var realmList = new RealmListUpdates(); foreach (var realm in _realms) { if (realm.Value.Id.GetSubRegionAddress() != subRegion) { continue; } RealmFlags flag = realm.Value.Flags; if (realm.Value.Build != build) { flag |= RealmFlags.VersionMismatch; } RealmListUpdate realmListUpdate = new RealmListUpdate(); realmListUpdate.Update.WowRealmAddress = (int)realm.Value.Id.GetAddress(); realmListUpdate.Update.CfgTimezonesID = 1; realmListUpdate.Update.PopulationState = (realm.Value.Flags.HasAnyFlag(RealmFlags.Offline) ? 0 : Math.Max((int)realm.Value.PopulationLevel, 1)); realmListUpdate.Update.CfgCategoriesID = realm.Value.Timezone; RealmBuildInfo buildInfo = GetBuildInfo(realm.Value.Build); if (buildInfo != null) { realmListUpdate.Update.Version.Major = (int)buildInfo.MajorVersion; realmListUpdate.Update.Version.Minor = (int)buildInfo.MinorVersion; realmListUpdate.Update.Version.Revision = (int)buildInfo.BugfixVersion; realmListUpdate.Update.Version.Build = (int)buildInfo.Build; } else { realmListUpdate.Update.Version.Major = 7; realmListUpdate.Update.Version.Minor = 1; realmListUpdate.Update.Version.Revision = 0; realmListUpdate.Update.Version.Build = (int)realm.Value.Build; } realmListUpdate.Update.CfgRealmsID = (int)realm.Value.Id.Realm; realmListUpdate.Update.Flags = (int)flag; realmListUpdate.Update.Name = realm.Value.Name; realmListUpdate.Update.CfgConfigsID = (int)realm.Value.GetConfigId(); realmListUpdate.Update.CfgLanguagesID = 1; realmListUpdate.Deleting = false; realmList.Updates.Add(realmListUpdate); } return(Json.Deflate("JSONRealmListUpdates", realmList)); }
/// <summary> /// Updates this Realm's status at the AuthServer. /// </summary> /// <param name="serverName"></param> /// <param name="serverType"></param> /// <param name="flags"></param> /// <param name="serverCategory"></param> /// <param name="serverStatus"></param> /// <returns></returns> public bool UpdateRealmServer(string serverName, int chrCount, int capacity, RealmServerType serverType, RealmFlags flags, RealmCategory serverCategory, RealmStatus serverStatus) { try { return(Channel.UpdateRealmServer(serverName, chrCount, capacity, serverType, flags, serverCategory, serverStatus)); } catch (Exception e) { OnError(e); return(false); } }
public void RegisterRealmServer(string realmName, string addr, int port, int chrCount, int capacity, RealmServerType serverType, RealmFlags flags, RealmCategory serverCategory, RealmStatus serverStatus, ClientVersion version) { try { Channel.RegisterRealmServer(realmName, addr, port, chrCount, capacity, serverType, flags, serverCategory, serverStatus, version); } catch (Exception e) { OnError(e); } }
public void RegisterWorldServer(string name, Uri location, RealmFlags flags, RealmCategory category, RealmType type, RealmStatus status, int characterCount, int characterCapacity, Version clientVersion) { var id = OperationContext.Current.SessionId; Contract.Assume(!string.IsNullOrEmpty(id)); RealmManager.Instance.PostAsync(mgr => mgr.AddRealm(new Realm(id, name, location, clientVersion) { Flags = flags, Category = category, Type = type, Status = status, Population = characterCount, Capacity = characterCapacity, })); }
/// <summary> /// Updates a realm server's entry in the realm list /// </summary> /// <param name="serverName">the name of the server</param> /// <param name="serverType">the type of the server</param> /// <param name="flags">the up/down status of the serer (green/red)</param> /// <param name="serverCategory">the timezone the server is in</param> /// <param name="serverStatus">the status of the server (locked or not)</param> public bool UpdateRealmServer(string serverName, int chrCount, int capacity, RealmServerType serverType, RealmFlags flags, RealmCategory serverCategory, RealmStatus serverStatus) { var realm = GetCurrentRealm(); if (realm == null) { return(false); } realm.Name = serverName; realm.Flags = flags; realm.Status = serverStatus; realm.ServerType = serverType; realm.Category = serverCategory; realm.CharCount = chrCount; realm.CharCapacity = capacity; realm.LastUpdate = DateTime.Now; //log.Debug(Resources.RealmUpdated, realm.Name); return(true); }
/// <inheritdoc /> public DefaultRealmInformation(RealmFlags flags, [NotNull] string realmString, [NotNull] RealmEndpoint realmAddress, float populationLevel, byte characterCount, byte realmTimeZone, byte realmId) { if (realmAddress == null) { throw new ArgumentNullException(nameof(realmAddress)); } if (!Enum.IsDefined(typeof(RealmFlags), flags)) { throw new ArgumentOutOfRangeException(nameof(flags), "Value should be defined in the RealmFlags enum."); } if (string.IsNullOrWhiteSpace(realmString)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(realmString)); } Flags = flags; RealmString = realmString; RealmAddress = realmAddress; PopulationLevel = populationLevel; CharacterCount = characterCount; RealmTimeZone = realmTimeZone; RealmId = realmId; }
/// <summary> /// Updates a realm server's entry in the realm list /// </summary> /// <param name="serverName">the name of the server</param> /// <param name="serverType">the type of the server</param> /// <param name="flags">the up/down status of the serer (green/red)</param> /// <param name="serverCategory">the timezone the server is in</param> /// <param name="serverStatus">the status of the server (locked or not)</param> public bool UpdateRealmServer(string serverName, int chrCount, int capacity, RealmServerType serverType, RealmFlags flags, RealmCategory serverCategory, RealmStatus serverStatus) { var realm = GetCurrentRealm(); if (realm == null) { return false; } realm.Name = serverName; realm.Flags = flags; realm.Status = serverStatus; realm.ServerType = serverType; realm.Category = serverCategory; realm.CharCount = chrCount; realm.CharCapacity = capacity; realm.LastUpdate = DateTime.Now; //log.Debug(Resources.RealmUpdated, realm.Name); return true; }
/// <summary> /// Registers a realm server with the authentication server /// </summary> /// <param name="serverName">the name of the server</param> /// <param name="serverType">the type of the server</param> /// <param name="flags">the up/down status of the serer (green/red)</param> /// <param name="serverCategory">the timezone the server is in</param> /// <param name="serverStatus">the status of the server (locked or not)</param> public void RegisterRealmServer(string serverName, string addr, int port, int chrCount, int capacity, RealmServerType serverType, RealmFlags flags, RealmCategory serverCategory, RealmStatus serverStatus, ClientVersion clientVersion) { var context = OperationContext.Current; if (context == null) { return; } var channel = context.Channel; if (channel == null) { return; } var id = GetCurrentId(); var realm = AuthenticationServer.GetRealmById(id); var ep = GetCurrentEndPoint(); // find out whether this server is just re-registering (came back online) var isNew = realm == null; if (isNew) { realm = AuthenticationServer.GetRealmByName(serverName); if (isNew = (realm == null)) { if (!AuthServerConfiguration.RealmIPs.Contains(ep.Address)) { // Ignore unknown realms log.Warn("Unallowed Realm (\"{0}\") tried to register from: {1}", serverName, ep.Address); var chan = OperationContext.Current.Channel; if (chan != null) { try { chan.Close(); } catch (Exception) {} } return; } realm = new RealmEntry(); } realm.ChannelId = id; } if (string.IsNullOrEmpty(addr)) { // no host given addr = ep.Address; } realm.Name = serverName; realm.Address = addr; realm.Port = port; realm.Flags = flags; realm.Status = serverStatus; realm.ServerType = serverType; realm.Category = serverCategory; realm.CharCount = chrCount; realm.CharCapacity = capacity; realm.ClientVersion = clientVersion; realm.Channel = channel; realm.ChannelAddress = ep.Address; realm.ChannelPort = ep.Port; if (isNew) { // register after setting all infos lock (AuthenticationServer.Realms) { realm.ChannelId = id; AuthenticationServer.Realms.Add(id, realm); } } log.Info(Resources.RealmRegistered, realm); //realm.ChannelAddress); }
/// <summary> /// Registers a realm server with the authentication server /// </summary> /// <param name="realmName">the name of the server</param> /// <param name="serverType">the type of the server</param> /// <param name="flags">the up/down status of the serer (green/red)</param> /// <param name="serverCategory">the timezone the server is in</param> /// <param name="serverStatus">the status of the server (locked or not)</param> public void RegisterRealmServer(string realmName, string addr, int port, int chrCount, int capacity, RealmServerType serverType, RealmFlags flags, RealmCategory serverCategory, RealmStatus serverStatus, ClientVersion clientVersion) { var context = OperationContext.Current; if (context == null) { return; } var channel = context.Channel; if (channel == null) { return; } var id = GetCurrentId(); var realm = AuthenticationServer.GetRealmById(id); var ep = GetCurrentEndPoint(); string epAddress = ""; if(ep == null) { epAddress = channel.RemoteAddress.Uri.Host; log.Warn("IPC::RegisterRealmServer Endpoint is null, falling back to: {0}", channel.RemoteAddress.Uri.Host); } else { epAddress = ep.Address; log.Info("IPC::RegisterRealmServer Endpoint address is: {0}", ep.Address); } // find out whether this server is just re-registering (came back online) var isNew = realm == null; if (isNew) { realm = AuthenticationServer.GetRealmByName(realmName); if (realm == null) { if (!AuthServerConfiguration.RealmIPs.Contains(epAddress)) { // Ignore unknown realms log.Warn("Unallowed Realm (\"{0}\") tried to register from: {1} (For more info, see the <RealmIPs> entry in your configuration)", realmName, epAddress, AuthServerConfiguration.Instance.FilePath); var chan = OperationContext.Current.Channel; if (chan != null) { try { chan.Close(); } catch (Exception) {} } return; } realm = new RealmEntry(); } else { lock (AuthenticationServer.Realms) { AuthenticationServer.RemoveRealmByName(realmName); } } } if (string.IsNullOrEmpty(addr)) { // no host given addr = epAddress; } realm.ChannelId = id; realm.Name = realmName; realm.Address = addr; realm.Port = port; realm.Flags = flags; realm.Status = serverStatus; realm.ServerType = serverType; realm.Category = serverCategory; realm.CharCount = chrCount; realm.CharCapacity = capacity; realm.ClientVersion = clientVersion; realm.Channel = channel; realm.ChannelAddress = epAddress; realm.ChannelPort = ep == null ? channel.RemoteAddress.Uri.Port : ep.Port; if (isNew) { // register after setting all infos lock (AuthenticationServer.Realms) { AuthenticationServer.AddRealm(realm); } } log.Info(resources.RealmRegistered, realm); //realm.ChannelAddress); }
/// <summary> /// Registers a realm server with the authentication server /// </summary> /// <param name="realmName">the name of the server</param> /// <param name="serverType">the type of the server</param> /// <param name="flags">the up/down status of the serer (green/red)</param> /// <param name="serverCategory">the timezone the server is in</param> /// <param name="serverStatus">the status of the server (locked or not)</param> public void RegisterRealmServer(string realmName, string addr, int port, int chrCount, int capacity, RealmServerType serverType, RealmFlags flags, RealmCategory serverCategory, RealmStatus serverStatus, ClientVersion clientVersion) { var context = OperationContext.Current; if (context == null) { return; } var channel = context.Channel; if (channel == null) { return; } var id = GetCurrentId(); var realm = AuthenticationServer.GetRealmById(id); var ep = GetCurrentEndPoint(); // find out whether this server is just re-registering (came back online) var isNew = realm == null; if (isNew) { realm = AuthenticationServer.GetRealmByName(realmName); if (realm == null) { if (!AuthServerConfiguration.RealmIPs.Contains(ep.Address)) { // Ignore unknown realms log.Warn("Unallowed Realm (\"{0}\") tried to register from: {1} (For more info, see the <RealmIPs> entry in your configuration)", realmName, ep.Address, AuthServerConfiguration.Instance.FilePath); var chan = OperationContext.Current.Channel; if (chan != null) { try { chan.Close(); } catch (Exception) {} } return; } realm = new RealmEntry(); } else { lock (AuthenticationServer.Realms) { AuthenticationServer.RemoveRealmByName(realmName); } } } if (string.IsNullOrEmpty(addr)) { // no host given addr = ep.Address; } realm.ChannelId = id; realm.Name = realmName; realm.Address = addr; realm.Port = port; realm.Flags = flags; realm.Status = serverStatus; realm.ServerType = serverType; realm.Category = serverCategory; realm.CharCount = chrCount; realm.CharCapacity = capacity; realm.ClientVersion = clientVersion; realm.Channel = channel; realm.ChannelAddress = ep.Address; realm.ChannelPort = ep.Port; if (isNew) { // register after setting all infos lock (AuthenticationServer.Realms) { AuthenticationServer.AddRealm(realm); } } log.Info(resources.RealmRegistered, realm); //realm.ChannelAddress); }