private void MessageHandlerOnJoinGameFailedReceived(JoinGameResultMessageHandler sender, JoinGameFailedReason args) { string reasonText = string.Empty; switch (args) { case JoinGameFailedReason.CharacterInUse: reasonText = "Der character wird bereits verwendet"; break; case JoinGameFailedReason.Timeout: reasonText = "Der Server hat zu lange nicht geantwortet"; break; case JoinGameFailedReason.MessageHandlingError: reasonText = "Die Antwort des Servers war fehlerhaft."; break; default: throw new ArgumentOutOfRangeException(nameof(args), args, null); } JoinGameFailed?.Invoke(this, new JoinGameFailedArgs(args, reasonText)); }
public JoinGameSender(IPacketWriterFactory packetWriterFactory, ScriptMessageSender messageSender, JoinGameResultMessageHandler messageHandler) { _PacketWriterFactory = packetWriterFactory ?? throw new ArgumentNullException(nameof(packetWriterFactory)); _MessageSender = messageSender ?? throw new ArgumentNullException(nameof(messageSender)); messageHandler.JoinGameSuccessReceived += sender => JoinGameRequestSuccessful?.Invoke(this); messageHandler.JoinGameFailedReceived += MessageHandlerOnJoinGameFailedReceived; }