/// <summary> /// Goes through the queue, pulling out clients for the number of slots available at the time. /// </summary> /// <param name="state">the timer object</param> private static void ProcessQueuedClients(object state) { var acceptedClients = new List <IRealmClient>(); try { var clientAccepts = RealmServerConfiguration.MaxClientCount - RealmServer.Instance.AcceptedClients; IRealmClient client; while (clientAccepts != 0) { if (s_queuedClients.TryDequeue(out client)) { acceptedClients.Add(client); clientAccepts--; } else { break; } } int clientPosition = 0; using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUTH_RESPONSE)) { packet.Write((byte)LoginErrorCode.AUTH_WAIT_QUEUE); packet.Write(0); foreach (var waitingClient in s_queuedClients) { packet.InsertIntAt(clientPosition++, 5, false); waitingClient.Send(packet); } } } catch (Exception e) { LogUtil.ErrorException(e, "AuthQueue raised an Exception."); } finally { PerformanceCounters.NumbersOfClientsInAuthQueue.RawValue = s_queuedClients.Count; foreach (var acceptedClient in acceptedClients) { acceptedClient.Account.IsEnqueued = false; LoginHandler.InviteToRealm(acceptedClient); } } }
/// <summary> /// Goes through the queue, pulling out clients for the number of slots available at the time. /// </summary> /// <param name="state">the timer object</param> private static void ProcessQueuedClients(object state) { List <IRealmClient> realmClientList = new List <IRealmClient>(); try { IRealmClient realmClient; for (int index = RealmServerConfiguration.MaxClientCount - ServerApp <RealmServer> .Instance.AcceptedClients; index != 0 && s_queuedClients.TryDequeue(out realmClient); --index) { realmClientList.Add(realmClient); } int num = 0; using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUTH_RESPONSE)) { packet.Write((byte)27); packet.Write(0); foreach (IRealmClient queuedClient in s_queuedClients) { packet.InsertIntAt(num++, 5L, false); queuedClient.Send(packet, false); } } } catch (Exception ex) { LogUtil.ErrorException(ex, "AuthQueue raised an Exception."); } finally { foreach (IRealmClient client in realmClientList) { client.Account.IsEnqueued = false; LoginHandler.InviteToRealm(client); } } }
/// <summary> /// Goes through the queue, pulling out clients for the number of slots available at the time. /// </summary> /// <param name="state">the timer object</param> private static void ProcessQueuedClients(object state) { var acceptedClients = new List<IRealmClient>(); try { var clientAccepts = RealmServerConfiguration.MaxClientCount - RealmServer.Instance.AcceptedClients; IRealmClient client; while (clientAccepts != 0) { if (s_queuedClients.TryDequeue(out client)) { acceptedClients.Add(client); clientAccepts--; } else { break; } } int clientPosition = 0; using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUTH_RESPONSE)) { packet.Write((byte)LoginErrorCode.AUTH_WAIT_QUEUE); packet.Write(0); foreach (var waitingClient in s_queuedClients) { packet.InsertIntAt(clientPosition++, 5, false); waitingClient.Send(packet); } } } catch (Exception e) { LogUtil.ErrorException(e, "AuthQueue raised an Exception."); } finally { PerformanceCounters.NumbersOfClientsInAuthQueue.RawValue = s_queuedClients.Count; foreach (var acceptedClient in acceptedClients) { acceptedClient.Account.IsEnqueued = false; LoginHandler.InviteToRealm(acceptedClient); } } }