/// <summary> /// Sends a failed <see cref="AuthResponsePacket"/> to a connection. /// </summary> /// <param name="connectionId">Recipient's connection ID</param> /// <param name="failureReason">Failure reason enum</param> /// <param name="failureMessage">Failure reason message</param> private void sendFailedAuthResponsePacket(string connectionId, AuthFailureReason failureReason, string failureMessage) { RaiseLogEntry(new LogEventArgs(string.Format("Sending failed AuthResponsePacket to connection {0}", connectionId.Highlight(HighlightType.ConnectionID)), LogLevel.DEBUG)); // Construct an AuthResponsePacket in failure configuration AuthResponsePacket response = new AuthResponsePacket { Success = false, FailureReason = failureReason, FailureMessage = failureMessage }; // Pack it into an Any for transmission Any packedResponse = ProtobufPacketHelper.Pack(response); // Send it if (!netServer.TrySend(connectionId, MODULE_NAME, packedResponse.ToByteArray())) { RaiseLogEntry(new LogEventArgs("Failed to send AuthResponsePacket to connection " + connectionId.Highlight(HighlightType.ConnectionID), LogLevel.ERROR)); } }
/// <summary> /// Creates a new failed <see cref="AuthenticationEventArgs"/> instance with the given reason and message. /// </summary> /// <param name="failureReason">Field that caused failure</param> /// <param name="failureMessage">Message provided by server</param> public AuthenticationEventArgs(AuthFailureReason failureReason, string failureMessage) { this.Success = false; this.FailureReason = failureReason; this.FailureMessage = failureMessage; }