public override void Handle(ServerClient sender, InPacket packetReader) { ushort errorCode = packetReader.ReadUshort(); if (sender.Authorized) { return; // Ignore other packets. } if (Enum.IsDefined(typeof(AuthorizationErrorCodes), errorCode)) { AuthorizationErrorCodes enumErrorCode = (AuthorizationErrorCodes)errorCode; switch (enumErrorCode) { case AuthorizationErrorCodes.OK: { sender.OnAuthorize(packetReader.ReadByte()); Console.Title = "AlterEmu - Game Server: " + Config.SERVER_NAME; break; } case AuthorizationErrorCodes.InvalidKey: { DisconnectErrorLog(sender, "Error while authorizing: the authorization key didn't match."); break; } case AuthorizationErrorCodes.Duplicate: { DisconnectErrorLog(sender, "Error while authorizing: a server with the same ip address is already online."); break; } case AuthorizationErrorCodes.MaxServersReached: { DisconnectErrorLog(sender, "Error while authorizing: maximum amount of servers reached."); break; } case AuthorizationErrorCodes.NameAlreadyUsed: { DisconnectErrorLog(sender, "Error while authorizing: the server name is already in use."); break; } default: { DisconnectErrorLog(sender, string.Concat("An unknown(", errorCode.ToString("x2"), ") error occured while authorizing the server.")); break; } } } else { // Unknown error Log.Instance.WriteLine(string.Concat("An unknown(", errorCode.ToString("x2"), ") error occured while authorizing the server.")); sender.Disconnect(true); } }
protected override void Process(Networking.ServerClient s) { ushort errorCode = GetUShort(0); if (s.Authorized) { return; // Ignore other packets. } if (Enum.IsDefined(typeof(AuthorizationErrorCodes), errorCode)) { AuthorizationErrorCodes enumErrorCode = (AuthorizationErrorCodes)errorCode; switch (enumErrorCode) { case AuthorizationErrorCodes.OK: { s.OnAuthorize(GetByte(1)); Console.Title = "AlterEmu - Game Server: " + Config.SERVER_NAME; if (!s.IsFirstConnect) { // We disconnected, sync the server! } break; } case AuthorizationErrorCodes.InvalidKey: { Log.Instance.WriteLine("Error while authorizing: the authorization key didn't match."); s.Disconnect(true); break; } case AuthorizationErrorCodes.Duplicate: { Log.Instance.WriteLine("Error while authorizing: a server with the same ip address is already online."); s.Disconnect(true); break; } case AuthorizationErrorCodes.MaxServersReached: { Log.Instance.WriteLine("Error while authorizing: maximum amount of servers reached."); s.Disconnect(true); break; } case AuthorizationErrorCodes.NameAlreadyUsed: { Log.Instance.WriteLine("Error while authorizing: the server name is already in use."); s.Disconnect(true); break; } default: { Log.Instance.WriteLine(string.Concat("An unknown(", errorCode.ToString("x2"), ") error occured while authorizing the server.")); s.Disconnect(true); break; } } } else { // Unknown error Log.Instance.WriteLine(string.Concat("An unknown(", errorCode.ToString("x2"), ") error occured while authorizing the server.")); s.Disconnect(true); } }