diff --git a/CliDiscordPacketDump/CliDiscordPacketDump.csproj b/CliDiscordPacketDump/CliDiscordPacketDump.csproj deleted file mode 100644 index d0e6054..0000000 --- a/CliDiscordPacketDump/CliDiscordPacketDump.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - - - - - - - - - - - PreserveNewest - - - - diff --git a/CliDiscordPacketDump/NLog.config b/CliDiscordPacketDump/NLog.config deleted file mode 100644 index ed6c603..0000000 --- a/CliDiscordPacketDump/NLog.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/CliDiscordPacketDump/NLog.xsd b/CliDiscordPacketDump/NLog.xsd deleted file mode 100644 index e2b7858..0000000 --- a/CliDiscordPacketDump/NLog.xsd +++ /dev/null @@ -1,3483 +0,0 @@ - - - - - - - - - - - - - - - Watch config file for changes and reload automatically. - - - - - Print internal NLog messages to the console. Default value is: false - - - - - Print internal NLog messages to the console error output. Default value is: false - - - - - Write internal NLog messages to the specified file. - - - - - Log level threshold for internal log messages. Default value is: Info. - - - - - Global log level threshold for application log messages. Messages below this level won't be logged. - - - - - Throw an exception when there is an internal error. Default value is: false. Not recommend to set to true in production! - - - - - Throw an exception when there is a configuration error. If not set, determined by throwExceptions. - - - - - Gets or sets a value indicating whether Variables should be kept on configuration reload. Default value is: false. - - - - - Write internal NLog messages to the System.Diagnostics.Trace. Default value is: false. - - - - - Write timestamps for internal NLog messages. Default value is: true. - - - - - Use InvariantCulture as default culture instead of CurrentCulture. Default value is: false. - - - - - Perform message template parsing and formatting of LogEvent messages (true = Always, false = Never, empty = Auto Detect). Default value is: empty. - - - - - - - - - - - - - - Make all targets within this section asynchronous (creates additional threads but the calling thread isn't blocked by any target writes). - - - - - - - - - - - - - - - - - Prefix for targets/layout renderers/filters/conditions loaded from this assembly. - - - - - Load NLog extensions from the specified file (*.dll) - - - - - Load NLog extensions from the specified assembly. Assembly name should be fully qualified. - - - - - - - - - - Filter on the name of the logger. May include wildcard characters ('*' or '?'). - - - - - Comma separated list of levels that this rule matches. - - - - - Minimum level that this rule matches. - - - - - Maximum level that this rule matches. - - - - - Level that this rule matches. - - - - - Comma separated list of target names. - - - - - Ignore further rules if this one matches. - - - - - Enable this rule. Note: disabled rules aren't available from the API. - - - - - Rule identifier to allow rule lookup with Configuration.FindRuleByName and Configuration.RemoveRuleByName. - - - - - Loggers matching will be restricted to specified minimum level for following rules. - - - - - - - - - - - - - - - Default action if none of the filters match. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the file to be included. You could use * wildcard. The name is relative to the name of the current config file. - - - - - Ignore any errors in the include file. - - - - - - - - Variable value. Note, the 'value' attribute has precedence over this one. - - - - - - Variable name. - - - - - Variable value. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Action to be taken when the lazy writer thread request queue count exceeds the set limit. - - - - - Limit on the number of requests in the lazy writer thread request queue. - - - - - Number of log events that should be processed in a batch by the lazy writer thread. - - - - - Whether to use the locking queue, instead of a lock-free concurrent queue - - - - - Number of batches of P:NLog.Targets.Wrappers.AsyncTargetWrapper.BatchSize to write before yielding into P:NLog.Targets.Wrappers.AsyncTargetWrapper.TimeToSleepBetweenBatches - - - - - Time in milliseconds to sleep between batches. (1 or less means trigger on new activity) - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Delay the flush until the LogEvent has been confirmed as written - - - - - Condition expression. Log events who meet this condition will cause a flush on the wrapped target. - - - - - Only flush when LogEvent matches condition. Ignore explicit-flush, config-reload-flush and shutdown-flush - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Number of log events to be buffered. - - - - - Action to take if the buffer overflows. - - - - - Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes. - - - - - Indicates whether to use sliding timeout. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Separator for T:NLog.ScopeContext operation-states-stack. - - - - - Stack separator for log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Renderer for log4j:event logger-xml-attribute (Default ${logger}) - - - - - Whether to include the contents of the T:NLog.ScopeContext properties-dictionary. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Indicates whether to include source info (file name and line number) in the information sent over the network. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Option to include all properties from the log events - - - - - Indicates whether to include call site (class and method name) in the information sent over the network. - - - - - AppInfo field. By default it's the friendly name of the current AppDomain. - - - - - Instance of T:NLog.Layouts.Log4JXmlEventLayout that is used to format log messages. - - - - - Indicates whether to include NLog-specific extensions to log4j schema. - - - - - Action that should be taken, when more connections than P:NLog.Targets.NetworkTarget.MaxConnections. - - - - - SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - - - - - Action that should be taken, when more pending messages than P:NLog.Targets.NetworkTarget.MaxQueueSize. - - - - - Action that should be taken if the message is larger than P:NLog.Targets.NetworkTarget.MaxMessageSize - - - - - Maximum queue size for a single connection. Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Network address. - - - - - Indicates whether to keep connection open whenever possible. - - - - - The number of seconds a connection will remain idle before the first keep-alive probe is sent - - - - - Size of the connection cache (number of connections which are kept alive). Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Maximum simultaneous connections. Requires P:NLog.Targets.NetworkTarget.KeepConnection = false - - - - - Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - - - - - Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - - - - - Maximum message size in bytes. On limit breach then P:NLog.Targets.NetworkTarget.OnOverflow action is activated. - - - - - Encoding to be used. - - - - - End of line value if a newline is appended at the end of log message P:NLog.Targets.NetworkTarget.NewLine. - - - - - Indicates whether to append newline at the end of log message. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Viewer parameter name. - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Whether an attribute with empty value should be included in the output - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether to auto-check if the console is available. - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) - - - - - Enables output using ANSI Color Codes - - - - - The encoding for writing messages to the T:System.Console. - - - - - Indicates whether to send the log messages to the standard error instead of the standard output. - - - - - Indicates whether to auto-flush after M:System.Console.WriteLine - - - - - Indicates whether to auto-check if the console has been redirected to file - Disables coloring logic when System.Console.IsOutputRedirected = true - - - - - Indicates whether to use default row highlighting rules. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Background color. - - - - - Condition that must be met in order to set the specified foreground and background color. - - - - - Foreground color. - - - - - - - - - - - - - - - - - Background color. - - - - - Compile the P:NLog.Targets.ConsoleWordHighlightingRule.Regex? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used. - - - - - Condition that must be met before scanning the row for highlight of words - - - - - Foreground color. - - - - - Indicates whether to ignore case when comparing texts. - - - - - Regular expression to be matched. You must specify either text or regex. - - - - - Text to be matched. You must specify either text or regex. - - - - - Indicates whether to match whole words only. - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether to auto-flush after M:System.Console.WriteLine - - - - - Indicates whether to auto-check if the console is available - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) - - - - - The encoding for writing messages to the T:System.Console. - - - - - Indicates whether to send the log messages to the standard error instead of the standard output. - - - - - Whether to activate internal buffering to allow batch writing, instead of using M:System.Console.WriteLine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string. - - - - - Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string. - - - - - Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string. - - - - - Name of the connection string (as specified in <connectionStrings> configuration section. - - - - - Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string. - - - - - Indicates whether to keep the database connection open between the log events. - - - - - Name of the database provider. - - - - - Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase. - - - - - Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used. - - - - - Configures isolated transaction batch writing. If supported by the database, then it will improve insert performance. - - - - - Text of the SQL command to be run on each log level. - - - - - Type of the SQL command to be run on each log level. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Convert format of the property value - - - - - Culture used for parsing property string-value for type-conversion - - - - - Value to assign on the object-property - - - - - Name for the object-property - - - - - Type of the object-property - - - - - - - - - - - - - - Type of the command. - - - - - Connection string to run the command against. If not provided, connection string from the target is used. - - - - - Indicates whether to ignore failures. - - - - - Command text. - - - - - - - - - - - - - - - - - - - - Database parameter name. - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Database parameter DbType. - - - - - Database parameter size. - - - - - Database parameter precision. - - - - - Database parameter scale. - - - - - Type of the parameter. - - - - - Fallback value when result value is not available - - - - - Convert format of the database parameter value. - - - - - Culture used for parsing parameter string-value for type-conversion - - - - - Whether empty value should translate into DbNull. Requires database column to allow NULL values. - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Layout that renders event Category. - - - - - Optional entry type. When not set, or when not convertible to T:System.Diagnostics.EventLogEntryType then determined by T:NLog.LogLevel - - - - - Layout that renders event ID. - - - - - Name of the Event Log to write to. This can be System, Application or any user-defined name. - - - - - Name of the machine on which Event Log service is running. - - - - - Maximum Event log size in kilobytes. - - - - - Message length limit to write to the Event Log. - - - - - Value to be used as the event Source. - - - - - Action to take if the message is larger than the P:NLog.Targets.EventLogTarget.MaxMessageLength option. - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Indicates whether to return to the first target after any successful write. - - - - - Whether to enable batching, but fallback will be handled individually - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Name of the file to write to. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether the footer should be written only when the file is archived. - - - - - Maximum number of archive files that should be kept. - - - - - Maximum days of archive files that should be kept. - - - - - Value of the file size threshold to archive old log file on startup. - - - - - Indicates whether to archive old log file on startup. - - - - - Indicates whether to compress archive files into the zip archive format. - - - - - Name of the file to be used for an archive. - - - - - Is the P:NLog.Targets.FileTarget.ArchiveFileName an absolute or relative path? - - - - - Indicates whether to automatically archive log files every time the specified time passes. - - - - - Value specifying the date format to use when archiving files. - - - - - Size in bytes above which log files will be automatically archived. - - - - - Way file archives are numbered. - - - - - Indicates whether to create directories if they do not exist. - - - - - Indicates whether file creation calls should be synchronized by a system global mutex. - - - - - Gets or set a value indicating whether a managed file stream is forced, instead of using the native implementation. - - - - - Is the P:NLog.Targets.FileTarget.FileName an absolute or relative path? - - - - - File attributes (Windows only). - - - - - Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong. - - - - - Indicates whether to write BOM (byte order mark) in created files. Defaults to true for UTF-16 and UTF-32 - - - - - Indicates whether to enable log file(s) to be deleted. - - - - - Indicates whether to delete old log file on startup. - - - - - File encoding. - - - - - Indicates whether to replace file contents on each write instead of appending log message at the end. - - - - - Line ending mode. - - - - - Number of times the write is appended on the file before NLog discards the log message. - - - - - Delay in milliseconds to wait before attempting to write to the file again. - - - - - Maximum number of seconds before open files are flushed. Zero or negative means disabled. - - - - - Maximum number of seconds that files are kept open. Zero or negative means disabled. - - - - - Indicates whether concurrent writes to the log file by multiple processes on different network hosts. - - - - - Log file buffer size in bytes. - - - - - Indicates whether to automatically flush the file buffers after each log message. - - - - - Indicates whether to keep log file open instead of opening and closing it on each logging event. - - - - - Indicates whether concurrent writes to the log file by multiple processes on the same host. - - - - - Whether or not this target should just discard all data that its asked to write. Mostly used for when testing NLog Stack except final write - - - - - Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Condition expression. Log events who meet this condition will be forwarded to the wrapped target. - - - - - - - - - - - - - - - Name of the target. - - - - - Identifier to perform group-by - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Windows domain name to change context to. - - - - - Required impersonation level. - - - - - Type of the logon provider. - - - - - Logon Type. - - - - - User account password. - - - - - Indicates whether to revert to the credentials of the process instead of impersonating another user. - - - - - Username to change context to. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Interval in which messages will be written up to the P:NLog.Targets.Wrappers.LimitingTargetWrapper.MessageLimit number of messages. - - - - - Maximum allowed number of messages written per P:NLog.Targets.Wrappers.LimitingTargetWrapper.Interval. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether NewLine characters in the body should be replaced with tags. - - - - - Priority used for sending mails. - - - - - Encoding to be used for sending e-mail. - - - - - BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - Indicates whether to add new lines between log entries. - - - - - Indicates whether to send message as HTML instead of plain text. - - - - - Sender's email address (e.g. joe@domain.com). - - - - - Mail message body (repeated for each log message send in one mail). - - - - - Mail subject. - - - - - Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - Specifies how outgoing email messages will be handled. - - - - - SMTP Server to be used for sending. - - - - - SMTP Authentication mode. - - - - - Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic"). - - - - - Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic"). - - - - - Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server. - - - - - Port number that SMTP Server is listening on. - - - - - Indicates whether the default Settings from System.Net.MailSettings should be used. - - - - - Folder where applications save mail messages to be processed by the local SMTP server. - - - - - Indicates the SMTP client timeout. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Max number of items to have in memory - - - - - - - - - - - - - - - - - Name of the target. - - - - - Class name. - - - - - Method name. The method must be public and static. Use the AssemblyQualifiedName , https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx e.g. - - - - - - - - - - - - - - - Name of the parameter. - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Fallback value when result value is not available - - - - - Type of the parameter. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - - - - - Action that should be taken, when more pending messages than P:NLog.Targets.NetworkTarget.MaxQueueSize. - - - - - Action that should be taken if the message is larger than P:NLog.Targets.NetworkTarget.MaxMessageSize - - - - - Maximum queue size for a single connection. Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Action that should be taken, when more connections than P:NLog.Targets.NetworkTarget.MaxConnections. - - - - - Indicates whether to keep connection open whenever possible. - - - - - The number of seconds a connection will remain idle before the first keep-alive probe is sent - - - - - Size of the connection cache (number of connections which are kept alive). Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Network address. - - - - - Maximum simultaneous connections. Requires P:NLog.Targets.NetworkTarget.KeepConnection = false - - - - - Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - - - - - Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - - - - - Maximum message size in bytes. On limit breach then P:NLog.Targets.NetworkTarget.OnOverflow action is activated. - - - - - Encoding to be used. - - - - - End of line value if a newline is appended at the end of log message P:NLog.Targets.NetworkTarget.NewLine. - - - - - Indicates whether to append newline at the end of log message. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Separator for T:NLog.ScopeContext operation-states-stack. - - - - - Stack separator for log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Renderer for log4j:event logger-xml-attribute (Default ${logger}) - - - - - Whether to include the contents of the T:NLog.ScopeContext properties-dictionary. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Indicates whether to include source info (file name and line number) in the information sent over the network. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Option to include all properties from the log events - - - - - Indicates whether to include call site (class and method name) in the information sent over the network. - - - - - AppInfo field. By default it's the friendly name of the current AppDomain. - - - - - Instance of T:NLog.Layouts.Log4JXmlEventLayout that is used to format log messages. - - - - - Indicates whether to include NLog-specific extensions to log4j schema. - - - - - Action that should be taken, when more connections than P:NLog.Targets.NetworkTarget.MaxConnections. - - - - - SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - - - - - Action that should be taken, when more pending messages than P:NLog.Targets.NetworkTarget.MaxQueueSize. - - - - - Action that should be taken if the message is larger than P:NLog.Targets.NetworkTarget.MaxMessageSize - - - - - Maximum queue size for a single connection. Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Network address. - - - - - Indicates whether to keep connection open whenever possible. - - - - - The number of seconds a connection will remain idle before the first keep-alive probe is sent - - - - - Size of the connection cache (number of connections which are kept alive). Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Maximum simultaneous connections. Requires P:NLog.Targets.NetworkTarget.KeepConnection = false - - - - - Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - - - - - Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - - - - - Maximum message size in bytes. On limit breach then P:NLog.Targets.NetworkTarget.OnOverflow action is activated. - - - - - Encoding to be used. - - - - - End of line value if a newline is appended at the end of log message P:NLog.Targets.NetworkTarget.NewLine. - - - - - Indicates whether to append newline at the end of log message. - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Indicates whether to perform layout calculation. - - - - - - - - - - - - - - - - Name of the target. - - - - - Default filter to be applied when no specific rule matches. - - - - - - - - - - - - - Condition to be tested. - - - - - Resulting filter to be applied when the condition matches. - - - - - - - - - - - - Name of the target. - - - - - - - - - - - - - - - Name of the target. - - - - - Number of times to repeat each log message. - - - - - - - - - - - - - - - - - Name of the target. - - - - - Whether to enable batching, and only apply single delay when a whole batch fails - - - - - Number of retries that should be attempted on the wrapped target in case of a failure. - - - - - Time to wait between retries in milliseconds. - - - - - - - - - - - - - - Name of the target. - - - - - - - - - - - - - - Name of the target. - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Forward F:NLog.LogLevel.Fatal to M:System.Diagnostics.Trace.Fail(System.String) (Instead of M:System.Diagnostics.Trace.TraceError(System.String)) - - - - - Force use M:System.Diagnostics.Trace.WriteLine(System.String) independent of T:NLog.LogLevel - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Indicates whether to pre-authenticate the HttpWebRequest (Requires 'Authorization' in P:NLog.Targets.WebServiceTarget.Headers parameters) - - - - - Value whether escaping be done according to Rfc3986 (Supports Internationalized Resource Identifiers - IRIs) - - - - - Value whether escaping be done according to the old NLog style (Very non-standard) - - - - - Value of the User-agent HTTP header. - - - - - Web service URL. - - - - - Proxy configuration when calling web service - - - - - Custom proxy address, include port separated by a colon - - - - - Protocol to be used when calling web service. - - - - - Web service namespace. Only used with Soap. - - - - - Web service method name. Only used with Soap. - - - - - Should we include the BOM (Byte-order-mark) for UTF? Influences the P:NLog.Targets.WebServiceTarget.Encoding property. This will only work for UTF-8. - - - - - Encoding. - - - - - Name of the root XML element, if POST of XML document chosen. If so, this property must not be null. (see P:NLog.Targets.WebServiceTarget.Protocol and F:NLog.Targets.WebServiceProtocol.XmlPost). - - - - - (optional) root namespace of the XML document, if POST of XML document chosen. (see P:NLog.Targets.WebServiceTarget.Protocol and F:NLog.Targets.WebServiceProtocol.XmlPost). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom'). - - - - - Column delimiter. - - - - - Footer layout. - - - - - Header layout. - - - - - Body layout (can be repeated multiple times). - - - - - Quote Character. - - - - - Quoting mode. - - - - - Indicates whether CVS should include header. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the column. - - - - - Layout of the column. - - - - - Override of Quoting mode - - - - - - - - - - - - - - Option to render the empty object value {} - - - - - Option to suppress the extra spaces in the output json - - - - - - - - - - - - - - - - - - - - - - - Option to include all properties from the log event (as JSON) - - - - - Indicates whether to include contents of the T:NLog.GlobalDiagnosticsContext dictionary. - - - - - Whether to include the contents of the T:NLog.ScopeContext dictionary. - - - - - Should forward slashes be escaped? If true, / will be converted to \/ - - - - - Option to exclude null/empty properties from the log event (as JSON) - - - - - List of property names to exclude when P:NLog.Layouts.JsonLayout.IncludeAllProperties is true - - - - - How far should the JSON serializer follow object references before backing off - - - - - Option to render the empty object value {} - - - - - Option to suppress the extra spaces in the output json - - - - - - - - - - - - - - - - - - - Name of the attribute. - - - - - Layout that will be rendered as the attribute's value. - - - - - Fallback value when result value is not available - - - - - Determines whether or not this attribute will be Json encoded. - - - - - Should forward slashes be escaped? If true, / will be converted to \/ - - - - - Indicates whether to escape non-ascii characters - - - - - Whether an attribute with empty value should be included in the output - - - - - Result value type, for conversion of layout rendering output - - - - - - - - - - - - - - Footer layout. - - - - - Header layout. - - - - - Body layout (can be repeated multiple times). - - - - - - - - - - - - - - - - - - - - - - - Option to include all properties from the log events - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Whether to include the contents of the T:NLog.ScopeContext properties-dictionary. - - - - - AppInfo field. By default it's the friendly name of the current AppDomain. - - - - - Indicates whether to include call site (class and method name) in the information sent over the network. - - - - - Indicates whether to include source info (file name and line number) in the information sent over the network. - - - - - Log4j:event logger-xml-attribute (Default ${logger}) - - - - - Whether the log4j:throwable xml-element should be written as CDATA - - - - - - - - - - - - - - Layout text. - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the root XML element - - - - - Value inside the root XML element - - - - - Whether to include the contents of the T:NLog.ScopeContext dictionary. - - - - - Determines whether or not this attribute will be Xml encoded. - - - - - List of property names to exclude when P:NLog.Layouts.XmlElementBase.IncludeAllProperties is true - - - - - Whether a ElementValue with empty value should be included in the output - - - - - Auto indent and create new lines - - - - - How far should the XML serializer follow object references before backing off - - - - - XML element name to use for rendering IList-collections items - - - - - XML attribute name to use when rendering property-key When null (or empty) then key-attribute is not included - - - - - XML element name to use when rendering properties - - - - - XML attribute name to use when rendering property-value When null (or empty) then value-attribute is not included and value is formatted as XML-element-value - - - - - Option to include all properties from the log event (as XML) - - - - - - - - - - - - - - - - - Name of the attribute. - - - - - Layout that will be rendered as the attribute's value. - - - - - Fallback value when result value is not available - - - - - Determines whether or not this attribute will be Xml encoded. - - - - - Whether an attribute with empty value should be included in the output - - - - - Result value type, for conversion of layout rendering output - - - - - - - - - - - - - - - - - - - - - - - - Name of the element - - - - - Whether to include the contents of the T:NLog.ScopeContext dictionary. - - - - - Value inside the element - - - - - Determines whether or not this attribute will be Xml encoded. - - - - - List of property names to exclude when P:NLog.Layouts.XmlElementBase.IncludeAllProperties is true - - - - - Whether a ElementValue with empty value should be included in the output - - - - - Auto indent and create new lines - - - - - How far should the XML serializer follow object references before backing off - - - - - XML element name to use for rendering IList-collections items - - - - - XML attribute name to use when rendering property-key When null (or empty) then key-attribute is not included - - - - - XML element name to use when rendering properties - - - - - XML attribute name to use when rendering property-value When null (or empty) then value-attribute is not included and value is formatted as XML-element-value - - - - - Option to include all properties from the log event (as XML) - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Condition expression. - - - - - - - - - - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - Substring to be matched. - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - String to compare the layout to. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - Substring to be matched. - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - String to compare the layout to. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - - - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Append FilterCount to the P:NLog.LogEventInfo.Message when an event is no longer filtered - - - - - Insert FilterCount value into P:NLog.LogEventInfo.Properties when an event is no longer filtered - - - - - Applies the configured action to the initial logevent that starts the timeout period. Used to configure that it should ignore all events until timeout. - - - - - Layout to be used to filter log messages. - - - - - Max length of filter values, will truncate if above limit - - - - - How long before a filter expires, and logging is accepted again - - - - - Default number of unique filter values to expect, will automatically increase if needed - - - - - Max number of unique filter values to expect simultaneously - - - - - Default buffer size for the internal buffers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/CliDiscordPacketDump/Program.cs b/CliDiscordPacketDump/Program.cs deleted file mode 100644 index 067e36a..0000000 --- a/CliDiscordPacketDump/Program.cs +++ /dev/null @@ -1,13 +0,0 @@ -// This new template sucks - -using NLog; - -var logger = LogManager.GetCurrentClassLogger(); -logger.Info("Starting up"); -var token = "authorization token!"; -var proxy = "socks5://whatever:1080"; -var discord = new KfChatDotNetBot.Services.DiscordService(token, proxy); -discord.StartWsClient().Wait(); -logger.Info("Started"); -var exitEvent = new ManualResetEvent(false); -exitEvent.WaitOne(); \ No newline at end of file diff --git a/KfChatDotNet.sln b/KfChatDotNet.sln index fd74c27..cbc3734 100644 --- a/KfChatDotNet.sln +++ b/KfChatDotNet.sln @@ -2,20 +2,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KfChatDotNetWsClient", "KfChatDotNetWsClient\KfChatDotNetWsClient.csproj", "{B3BC806A-7FFC-47BD-9C18-45CD2B99F9F8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KfChatDotNetCli", "KfChatDotNetCli\KfChatDotNetCli.csproj", "{A4D19F8E-5A1F-4A66-BC42-214DB9D5429B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KfChatDotNetGui", "KfChatDotNetGui\KfChatDotNetGui.csproj", "{B2A5D4EE-5EB6-4F0B-BB5E-2B87AAFBFB5B}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KickWsClient", "KickWsClient\KickWsClient.csproj", "{DECBB95C-2C9F-44C2-AFA3-3741986FBA38}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KfChatDotNetBot", "KfChatDotNetBot\KfChatDotNetBot.csproj", "{4734E0A4-150E-4915-B905-928BB4BE3FF6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThreeXplWsClient", "ThreeXplWsClient\ThreeXplWsClient.csproj", "{3D72D70A-48AD-4EE8-89DC-C78153EEA879}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThreeXplCliClient", "ThreeXplCliClient\ThreeXplCliClient.csproj", "{D098E281-5535-4A07-9514-57AF78704B0C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CliDiscordPacketDump", "CliDiscordPacketDump\CliDiscordPacketDump.csproj", "{792ECCCD-FAC3-4CE5-A760-988080960BB9}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,14 +16,6 @@ Global {B3BC806A-7FFC-47BD-9C18-45CD2B99F9F8}.Debug|Any CPU.Build.0 = Debug|Any CPU {B3BC806A-7FFC-47BD-9C18-45CD2B99F9F8}.Release|Any CPU.ActiveCfg = Release|Any CPU {B3BC806A-7FFC-47BD-9C18-45CD2B99F9F8}.Release|Any CPU.Build.0 = Release|Any CPU - {A4D19F8E-5A1F-4A66-BC42-214DB9D5429B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A4D19F8E-5A1F-4A66-BC42-214DB9D5429B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A4D19F8E-5A1F-4A66-BC42-214DB9D5429B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A4D19F8E-5A1F-4A66-BC42-214DB9D5429B}.Release|Any CPU.Build.0 = Release|Any CPU - {B2A5D4EE-5EB6-4F0B-BB5E-2B87AAFBFB5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B2A5D4EE-5EB6-4F0B-BB5E-2B87AAFBFB5B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B2A5D4EE-5EB6-4F0B-BB5E-2B87AAFBFB5B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B2A5D4EE-5EB6-4F0B-BB5E-2B87AAFBFB5B}.Release|Any CPU.Build.0 = Release|Any CPU {DECBB95C-2C9F-44C2-AFA3-3741986FBA38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DECBB95C-2C9F-44C2-AFA3-3741986FBA38}.Debug|Any CPU.Build.0 = Debug|Any CPU {DECBB95C-2C9F-44C2-AFA3-3741986FBA38}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -42,17 +24,5 @@ Global {4734E0A4-150E-4915-B905-928BB4BE3FF6}.Debug|Any CPU.Build.0 = Debug|Any CPU {4734E0A4-150E-4915-B905-928BB4BE3FF6}.Release|Any CPU.ActiveCfg = Release|Any CPU {4734E0A4-150E-4915-B905-928BB4BE3FF6}.Release|Any CPU.Build.0 = Release|Any CPU - {3D72D70A-48AD-4EE8-89DC-C78153EEA879}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3D72D70A-48AD-4EE8-89DC-C78153EEA879}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3D72D70A-48AD-4EE8-89DC-C78153EEA879}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3D72D70A-48AD-4EE8-89DC-C78153EEA879}.Release|Any CPU.Build.0 = Release|Any CPU - {D098E281-5535-4A07-9514-57AF78704B0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D098E281-5535-4A07-9514-57AF78704B0C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D098E281-5535-4A07-9514-57AF78704B0C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D098E281-5535-4A07-9514-57AF78704B0C}.Release|Any CPU.Build.0 = Release|Any CPU - {792ECCCD-FAC3-4CE5-A760-988080960BB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {792ECCCD-FAC3-4CE5-A760-988080960BB9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {792ECCCD-FAC3-4CE5-A760-988080960BB9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {792ECCCD-FAC3-4CE5-A760-988080960BB9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/KfChatDotNetCli/ChatCliMain.cs b/KfChatDotNetCli/ChatCliMain.cs deleted file mode 100644 index 26ee86f..0000000 --- a/KfChatDotNetCli/ChatCliMain.cs +++ /dev/null @@ -1,90 +0,0 @@ -using KfChatDotNetWsClient; -using KfChatDotNetWsClient.Models; -using KfChatDotNetWsClient.Models.Events; -using KfChatDotNetWsClient.Models.Json; -using NLog; -using Spectre.Console; -using Websocket.Client; - -namespace KfChatDotNetCli; - -public class ChatCliMain -{ - private ChatClient _client; - private Logger _logger = LogManager.GetCurrentClassLogger(); - private int _roomId; - - public ChatCliMain(string xfSessionToken, int roomId) - { - _roomId = roomId; - _client = new ChatClient(new ChatClientConfigModel - { - WsUri = new Uri("wss://kiwifarms.st:9443/chat.ws"), - XfSessionToken = xfSessionToken - }); - - _client.OnMessages += OnMessages; - _client.OnDeleteMessages += OnDeleteMessages; - _client.OnUsersJoined += OnUsersJoined; - _client.OnUsersParted += OnUsersParted; - _client.OnWsReconnect += OnWsReconnected; - - _client.StartWsClient().Wait(); - if (_roomId != int.MaxValue) - { - _logger.Debug($"Joining room {_roomId}"); - _client.JoinRoom(_roomId); - } - - while (true) - { - var input = AnsiConsole.Prompt(new TextPrompt("Enter Message:")); - _client.SendMessage(input); - } - // ReSharper disable once FunctionNeverReturns - } - - private void OnMessages(object sender, List messages, MessagesJsonModel jsonPayload) - { - _logger.Debug($"Received {messages.Count} message(s)"); - foreach (var message in messages) - { - AnsiConsole.MarkupLine($"<{message.Author.Username}> {message.Message.EscapeMarkup()} ({message.MessageDate.LocalDateTime.ToShortTimeString()})"); - } - } - - private void OnDeleteMessages(object sender, List messageIds) - { - _logger.Debug($"Received delete event for {messageIds}"); - foreach (var id in messageIds) - { - AnsiConsole.MarkupLine($"[red]{id} message deleted![/]"); - } - } - - private void OnUsersJoined(object sender, List users, UsersJsonModel jsonPayload) - { - _logger.Debug($"Received {users.Count} user join events"); - foreach (var user in users) - { - AnsiConsole.MarkupLine($"[green]{user.Username.EscapeMarkup()} joined![/]"); - } - } - - private void OnUsersParted(object sender, List userIds) - { - _logger.Debug($"Received {userIds.Count} user part events"); - foreach (var id in userIds) - { - AnsiConsole.MarkupLine($"[red]{id} left the chat...[/]"); - } - } - - private void OnWsReconnected(object sender, ReconnectionInfo reconnectionInfo) - { - AnsiConsole.MarkupLine($"[red]Reconnected due to {reconnectionInfo.Type}[/]"); - if (_roomId == int.MaxValue) return; - AnsiConsole.MarkupLine($"[green]Rejoining {_roomId}[/]"); - _client.JoinRoom(_roomId); - } -} \ No newline at end of file diff --git a/KfChatDotNetCli/KfChatDotNetCli.csproj b/KfChatDotNetCli/KfChatDotNetCli.csproj deleted file mode 100644 index 3f30cc1..0000000 --- a/KfChatDotNetCli/KfChatDotNetCli.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - Exe - net8.0 - enable - enable - default - - - - - - - - - - - - - diff --git a/KfChatDotNetCli/NLog.config b/KfChatDotNetCli/NLog.config deleted file mode 100644 index e255848..0000000 --- a/KfChatDotNetCli/NLog.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/KfChatDotNetCli/NLog.xsd b/KfChatDotNetCli/NLog.xsd deleted file mode 100644 index e2b7858..0000000 --- a/KfChatDotNetCli/NLog.xsd +++ /dev/null @@ -1,3483 +0,0 @@ - - - - - - - - - - - - - - - Watch config file for changes and reload automatically. - - - - - Print internal NLog messages to the console. Default value is: false - - - - - Print internal NLog messages to the console error output. Default value is: false - - - - - Write internal NLog messages to the specified file. - - - - - Log level threshold for internal log messages. Default value is: Info. - - - - - Global log level threshold for application log messages. Messages below this level won't be logged. - - - - - Throw an exception when there is an internal error. Default value is: false. Not recommend to set to true in production! - - - - - Throw an exception when there is a configuration error. If not set, determined by throwExceptions. - - - - - Gets or sets a value indicating whether Variables should be kept on configuration reload. Default value is: false. - - - - - Write internal NLog messages to the System.Diagnostics.Trace. Default value is: false. - - - - - Write timestamps for internal NLog messages. Default value is: true. - - - - - Use InvariantCulture as default culture instead of CurrentCulture. Default value is: false. - - - - - Perform message template parsing and formatting of LogEvent messages (true = Always, false = Never, empty = Auto Detect). Default value is: empty. - - - - - - - - - - - - - - Make all targets within this section asynchronous (creates additional threads but the calling thread isn't blocked by any target writes). - - - - - - - - - - - - - - - - - Prefix for targets/layout renderers/filters/conditions loaded from this assembly. - - - - - Load NLog extensions from the specified file (*.dll) - - - - - Load NLog extensions from the specified assembly. Assembly name should be fully qualified. - - - - - - - - - - Filter on the name of the logger. May include wildcard characters ('*' or '?'). - - - - - Comma separated list of levels that this rule matches. - - - - - Minimum level that this rule matches. - - - - - Maximum level that this rule matches. - - - - - Level that this rule matches. - - - - - Comma separated list of target names. - - - - - Ignore further rules if this one matches. - - - - - Enable this rule. Note: disabled rules aren't available from the API. - - - - - Rule identifier to allow rule lookup with Configuration.FindRuleByName and Configuration.RemoveRuleByName. - - - - - Loggers matching will be restricted to specified minimum level for following rules. - - - - - - - - - - - - - - - Default action if none of the filters match. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the file to be included. You could use * wildcard. The name is relative to the name of the current config file. - - - - - Ignore any errors in the include file. - - - - - - - - Variable value. Note, the 'value' attribute has precedence over this one. - - - - - - Variable name. - - - - - Variable value. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Action to be taken when the lazy writer thread request queue count exceeds the set limit. - - - - - Limit on the number of requests in the lazy writer thread request queue. - - - - - Number of log events that should be processed in a batch by the lazy writer thread. - - - - - Whether to use the locking queue, instead of a lock-free concurrent queue - - - - - Number of batches of P:NLog.Targets.Wrappers.AsyncTargetWrapper.BatchSize to write before yielding into P:NLog.Targets.Wrappers.AsyncTargetWrapper.TimeToSleepBetweenBatches - - - - - Time in milliseconds to sleep between batches. (1 or less means trigger on new activity) - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Delay the flush until the LogEvent has been confirmed as written - - - - - Condition expression. Log events who meet this condition will cause a flush on the wrapped target. - - - - - Only flush when LogEvent matches condition. Ignore explicit-flush, config-reload-flush and shutdown-flush - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Number of log events to be buffered. - - - - - Action to take if the buffer overflows. - - - - - Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes. - - - - - Indicates whether to use sliding timeout. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Separator for T:NLog.ScopeContext operation-states-stack. - - - - - Stack separator for log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Renderer for log4j:event logger-xml-attribute (Default ${logger}) - - - - - Whether to include the contents of the T:NLog.ScopeContext properties-dictionary. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Indicates whether to include source info (file name and line number) in the information sent over the network. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Option to include all properties from the log events - - - - - Indicates whether to include call site (class and method name) in the information sent over the network. - - - - - AppInfo field. By default it's the friendly name of the current AppDomain. - - - - - Instance of T:NLog.Layouts.Log4JXmlEventLayout that is used to format log messages. - - - - - Indicates whether to include NLog-specific extensions to log4j schema. - - - - - Action that should be taken, when more connections than P:NLog.Targets.NetworkTarget.MaxConnections. - - - - - SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - - - - - Action that should be taken, when more pending messages than P:NLog.Targets.NetworkTarget.MaxQueueSize. - - - - - Action that should be taken if the message is larger than P:NLog.Targets.NetworkTarget.MaxMessageSize - - - - - Maximum queue size for a single connection. Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Network address. - - - - - Indicates whether to keep connection open whenever possible. - - - - - The number of seconds a connection will remain idle before the first keep-alive probe is sent - - - - - Size of the connection cache (number of connections which are kept alive). Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Maximum simultaneous connections. Requires P:NLog.Targets.NetworkTarget.KeepConnection = false - - - - - Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - - - - - Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - - - - - Maximum message size in bytes. On limit breach then P:NLog.Targets.NetworkTarget.OnOverflow action is activated. - - - - - Encoding to be used. - - - - - End of line value if a newline is appended at the end of log message P:NLog.Targets.NetworkTarget.NewLine. - - - - - Indicates whether to append newline at the end of log message. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Viewer parameter name. - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Whether an attribute with empty value should be included in the output - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether to auto-check if the console is available. - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) - - - - - Enables output using ANSI Color Codes - - - - - The encoding for writing messages to the T:System.Console. - - - - - Indicates whether to send the log messages to the standard error instead of the standard output. - - - - - Indicates whether to auto-flush after M:System.Console.WriteLine - - - - - Indicates whether to auto-check if the console has been redirected to file - Disables coloring logic when System.Console.IsOutputRedirected = true - - - - - Indicates whether to use default row highlighting rules. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Background color. - - - - - Condition that must be met in order to set the specified foreground and background color. - - - - - Foreground color. - - - - - - - - - - - - - - - - - Background color. - - - - - Compile the P:NLog.Targets.ConsoleWordHighlightingRule.Regex? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used. - - - - - Condition that must be met before scanning the row for highlight of words - - - - - Foreground color. - - - - - Indicates whether to ignore case when comparing texts. - - - - - Regular expression to be matched. You must specify either text or regex. - - - - - Text to be matched. You must specify either text or regex. - - - - - Indicates whether to match whole words only. - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether to auto-flush after M:System.Console.WriteLine - - - - - Indicates whether to auto-check if the console is available - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) - - - - - The encoding for writing messages to the T:System.Console. - - - - - Indicates whether to send the log messages to the standard error instead of the standard output. - - - - - Whether to activate internal buffering to allow batch writing, instead of using M:System.Console.WriteLine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string. - - - - - Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string. - - - - - Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string. - - - - - Name of the connection string (as specified in <connectionStrings> configuration section. - - - - - Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string. - - - - - Indicates whether to keep the database connection open between the log events. - - - - - Name of the database provider. - - - - - Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase. - - - - - Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used. - - - - - Configures isolated transaction batch writing. If supported by the database, then it will improve insert performance. - - - - - Text of the SQL command to be run on each log level. - - - - - Type of the SQL command to be run on each log level. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Convert format of the property value - - - - - Culture used for parsing property string-value for type-conversion - - - - - Value to assign on the object-property - - - - - Name for the object-property - - - - - Type of the object-property - - - - - - - - - - - - - - Type of the command. - - - - - Connection string to run the command against. If not provided, connection string from the target is used. - - - - - Indicates whether to ignore failures. - - - - - Command text. - - - - - - - - - - - - - - - - - - - - Database parameter name. - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Database parameter DbType. - - - - - Database parameter size. - - - - - Database parameter precision. - - - - - Database parameter scale. - - - - - Type of the parameter. - - - - - Fallback value when result value is not available - - - - - Convert format of the database parameter value. - - - - - Culture used for parsing parameter string-value for type-conversion - - - - - Whether empty value should translate into DbNull. Requires database column to allow NULL values. - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Layout that renders event Category. - - - - - Optional entry type. When not set, or when not convertible to T:System.Diagnostics.EventLogEntryType then determined by T:NLog.LogLevel - - - - - Layout that renders event ID. - - - - - Name of the Event Log to write to. This can be System, Application or any user-defined name. - - - - - Name of the machine on which Event Log service is running. - - - - - Maximum Event log size in kilobytes. - - - - - Message length limit to write to the Event Log. - - - - - Value to be used as the event Source. - - - - - Action to take if the message is larger than the P:NLog.Targets.EventLogTarget.MaxMessageLength option. - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Indicates whether to return to the first target after any successful write. - - - - - Whether to enable batching, but fallback will be handled individually - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Name of the file to write to. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether the footer should be written only when the file is archived. - - - - - Maximum number of archive files that should be kept. - - - - - Maximum days of archive files that should be kept. - - - - - Value of the file size threshold to archive old log file on startup. - - - - - Indicates whether to archive old log file on startup. - - - - - Indicates whether to compress archive files into the zip archive format. - - - - - Name of the file to be used for an archive. - - - - - Is the P:NLog.Targets.FileTarget.ArchiveFileName an absolute or relative path? - - - - - Indicates whether to automatically archive log files every time the specified time passes. - - - - - Value specifying the date format to use when archiving files. - - - - - Size in bytes above which log files will be automatically archived. - - - - - Way file archives are numbered. - - - - - Indicates whether to create directories if they do not exist. - - - - - Indicates whether file creation calls should be synchronized by a system global mutex. - - - - - Gets or set a value indicating whether a managed file stream is forced, instead of using the native implementation. - - - - - Is the P:NLog.Targets.FileTarget.FileName an absolute or relative path? - - - - - File attributes (Windows only). - - - - - Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong. - - - - - Indicates whether to write BOM (byte order mark) in created files. Defaults to true for UTF-16 and UTF-32 - - - - - Indicates whether to enable log file(s) to be deleted. - - - - - Indicates whether to delete old log file on startup. - - - - - File encoding. - - - - - Indicates whether to replace file contents on each write instead of appending log message at the end. - - - - - Line ending mode. - - - - - Number of times the write is appended on the file before NLog discards the log message. - - - - - Delay in milliseconds to wait before attempting to write to the file again. - - - - - Maximum number of seconds before open files are flushed. Zero or negative means disabled. - - - - - Maximum number of seconds that files are kept open. Zero or negative means disabled. - - - - - Indicates whether concurrent writes to the log file by multiple processes on different network hosts. - - - - - Log file buffer size in bytes. - - - - - Indicates whether to automatically flush the file buffers after each log message. - - - - - Indicates whether to keep log file open instead of opening and closing it on each logging event. - - - - - Indicates whether concurrent writes to the log file by multiple processes on the same host. - - - - - Whether or not this target should just discard all data that its asked to write. Mostly used for when testing NLog Stack except final write - - - - - Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Condition expression. Log events who meet this condition will be forwarded to the wrapped target. - - - - - - - - - - - - - - - Name of the target. - - - - - Identifier to perform group-by - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Windows domain name to change context to. - - - - - Required impersonation level. - - - - - Type of the logon provider. - - - - - Logon Type. - - - - - User account password. - - - - - Indicates whether to revert to the credentials of the process instead of impersonating another user. - - - - - Username to change context to. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Interval in which messages will be written up to the P:NLog.Targets.Wrappers.LimitingTargetWrapper.MessageLimit number of messages. - - - - - Maximum allowed number of messages written per P:NLog.Targets.Wrappers.LimitingTargetWrapper.Interval. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether NewLine characters in the body should be replaced with tags. - - - - - Priority used for sending mails. - - - - - Encoding to be used for sending e-mail. - - - - - BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - Indicates whether to add new lines between log entries. - - - - - Indicates whether to send message as HTML instead of plain text. - - - - - Sender's email address (e.g. joe@domain.com). - - - - - Mail message body (repeated for each log message send in one mail). - - - - - Mail subject. - - - - - Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - Specifies how outgoing email messages will be handled. - - - - - SMTP Server to be used for sending. - - - - - SMTP Authentication mode. - - - - - Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic"). - - - - - Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic"). - - - - - Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server. - - - - - Port number that SMTP Server is listening on. - - - - - Indicates whether the default Settings from System.Net.MailSettings should be used. - - - - - Folder where applications save mail messages to be processed by the local SMTP server. - - - - - Indicates the SMTP client timeout. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Max number of items to have in memory - - - - - - - - - - - - - - - - - Name of the target. - - - - - Class name. - - - - - Method name. The method must be public and static. Use the AssemblyQualifiedName , https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx e.g. - - - - - - - - - - - - - - - Name of the parameter. - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Fallback value when result value is not available - - - - - Type of the parameter. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - - - - - Action that should be taken, when more pending messages than P:NLog.Targets.NetworkTarget.MaxQueueSize. - - - - - Action that should be taken if the message is larger than P:NLog.Targets.NetworkTarget.MaxMessageSize - - - - - Maximum queue size for a single connection. Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Action that should be taken, when more connections than P:NLog.Targets.NetworkTarget.MaxConnections. - - - - - Indicates whether to keep connection open whenever possible. - - - - - The number of seconds a connection will remain idle before the first keep-alive probe is sent - - - - - Size of the connection cache (number of connections which are kept alive). Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Network address. - - - - - Maximum simultaneous connections. Requires P:NLog.Targets.NetworkTarget.KeepConnection = false - - - - - Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - - - - - Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - - - - - Maximum message size in bytes. On limit breach then P:NLog.Targets.NetworkTarget.OnOverflow action is activated. - - - - - Encoding to be used. - - - - - End of line value if a newline is appended at the end of log message P:NLog.Targets.NetworkTarget.NewLine. - - - - - Indicates whether to append newline at the end of log message. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Separator for T:NLog.ScopeContext operation-states-stack. - - - - - Stack separator for log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Renderer for log4j:event logger-xml-attribute (Default ${logger}) - - - - - Whether to include the contents of the T:NLog.ScopeContext properties-dictionary. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Indicates whether to include source info (file name and line number) in the information sent over the network. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Option to include all properties from the log events - - - - - Indicates whether to include call site (class and method name) in the information sent over the network. - - - - - AppInfo field. By default it's the friendly name of the current AppDomain. - - - - - Instance of T:NLog.Layouts.Log4JXmlEventLayout that is used to format log messages. - - - - - Indicates whether to include NLog-specific extensions to log4j schema. - - - - - Action that should be taken, when more connections than P:NLog.Targets.NetworkTarget.MaxConnections. - - - - - SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - - - - - Action that should be taken, when more pending messages than P:NLog.Targets.NetworkTarget.MaxQueueSize. - - - - - Action that should be taken if the message is larger than P:NLog.Targets.NetworkTarget.MaxMessageSize - - - - - Maximum queue size for a single connection. Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Network address. - - - - - Indicates whether to keep connection open whenever possible. - - - - - The number of seconds a connection will remain idle before the first keep-alive probe is sent - - - - - Size of the connection cache (number of connections which are kept alive). Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Maximum simultaneous connections. Requires P:NLog.Targets.NetworkTarget.KeepConnection = false - - - - - Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - - - - - Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - - - - - Maximum message size in bytes. On limit breach then P:NLog.Targets.NetworkTarget.OnOverflow action is activated. - - - - - Encoding to be used. - - - - - End of line value if a newline is appended at the end of log message P:NLog.Targets.NetworkTarget.NewLine. - - - - - Indicates whether to append newline at the end of log message. - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Indicates whether to perform layout calculation. - - - - - - - - - - - - - - - - Name of the target. - - - - - Default filter to be applied when no specific rule matches. - - - - - - - - - - - - - Condition to be tested. - - - - - Resulting filter to be applied when the condition matches. - - - - - - - - - - - - Name of the target. - - - - - - - - - - - - - - - Name of the target. - - - - - Number of times to repeat each log message. - - - - - - - - - - - - - - - - - Name of the target. - - - - - Whether to enable batching, and only apply single delay when a whole batch fails - - - - - Number of retries that should be attempted on the wrapped target in case of a failure. - - - - - Time to wait between retries in milliseconds. - - - - - - - - - - - - - - Name of the target. - - - - - - - - - - - - - - Name of the target. - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Forward F:NLog.LogLevel.Fatal to M:System.Diagnostics.Trace.Fail(System.String) (Instead of M:System.Diagnostics.Trace.TraceError(System.String)) - - - - - Force use M:System.Diagnostics.Trace.WriteLine(System.String) independent of T:NLog.LogLevel - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Indicates whether to pre-authenticate the HttpWebRequest (Requires 'Authorization' in P:NLog.Targets.WebServiceTarget.Headers parameters) - - - - - Value whether escaping be done according to Rfc3986 (Supports Internationalized Resource Identifiers - IRIs) - - - - - Value whether escaping be done according to the old NLog style (Very non-standard) - - - - - Value of the User-agent HTTP header. - - - - - Web service URL. - - - - - Proxy configuration when calling web service - - - - - Custom proxy address, include port separated by a colon - - - - - Protocol to be used when calling web service. - - - - - Web service namespace. Only used with Soap. - - - - - Web service method name. Only used with Soap. - - - - - Should we include the BOM (Byte-order-mark) for UTF? Influences the P:NLog.Targets.WebServiceTarget.Encoding property. This will only work for UTF-8. - - - - - Encoding. - - - - - Name of the root XML element, if POST of XML document chosen. If so, this property must not be null. (see P:NLog.Targets.WebServiceTarget.Protocol and F:NLog.Targets.WebServiceProtocol.XmlPost). - - - - - (optional) root namespace of the XML document, if POST of XML document chosen. (see P:NLog.Targets.WebServiceTarget.Protocol and F:NLog.Targets.WebServiceProtocol.XmlPost). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom'). - - - - - Column delimiter. - - - - - Footer layout. - - - - - Header layout. - - - - - Body layout (can be repeated multiple times). - - - - - Quote Character. - - - - - Quoting mode. - - - - - Indicates whether CVS should include header. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the column. - - - - - Layout of the column. - - - - - Override of Quoting mode - - - - - - - - - - - - - - Option to render the empty object value {} - - - - - Option to suppress the extra spaces in the output json - - - - - - - - - - - - - - - - - - - - - - - Option to include all properties from the log event (as JSON) - - - - - Indicates whether to include contents of the T:NLog.GlobalDiagnosticsContext dictionary. - - - - - Whether to include the contents of the T:NLog.ScopeContext dictionary. - - - - - Should forward slashes be escaped? If true, / will be converted to \/ - - - - - Option to exclude null/empty properties from the log event (as JSON) - - - - - List of property names to exclude when P:NLog.Layouts.JsonLayout.IncludeAllProperties is true - - - - - How far should the JSON serializer follow object references before backing off - - - - - Option to render the empty object value {} - - - - - Option to suppress the extra spaces in the output json - - - - - - - - - - - - - - - - - - - Name of the attribute. - - - - - Layout that will be rendered as the attribute's value. - - - - - Fallback value when result value is not available - - - - - Determines whether or not this attribute will be Json encoded. - - - - - Should forward slashes be escaped? If true, / will be converted to \/ - - - - - Indicates whether to escape non-ascii characters - - - - - Whether an attribute with empty value should be included in the output - - - - - Result value type, for conversion of layout rendering output - - - - - - - - - - - - - - Footer layout. - - - - - Header layout. - - - - - Body layout (can be repeated multiple times). - - - - - - - - - - - - - - - - - - - - - - - Option to include all properties from the log events - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Whether to include the contents of the T:NLog.ScopeContext properties-dictionary. - - - - - AppInfo field. By default it's the friendly name of the current AppDomain. - - - - - Indicates whether to include call site (class and method name) in the information sent over the network. - - - - - Indicates whether to include source info (file name and line number) in the information sent over the network. - - - - - Log4j:event logger-xml-attribute (Default ${logger}) - - - - - Whether the log4j:throwable xml-element should be written as CDATA - - - - - - - - - - - - - - Layout text. - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the root XML element - - - - - Value inside the root XML element - - - - - Whether to include the contents of the T:NLog.ScopeContext dictionary. - - - - - Determines whether or not this attribute will be Xml encoded. - - - - - List of property names to exclude when P:NLog.Layouts.XmlElementBase.IncludeAllProperties is true - - - - - Whether a ElementValue with empty value should be included in the output - - - - - Auto indent and create new lines - - - - - How far should the XML serializer follow object references before backing off - - - - - XML element name to use for rendering IList-collections items - - - - - XML attribute name to use when rendering property-key When null (or empty) then key-attribute is not included - - - - - XML element name to use when rendering properties - - - - - XML attribute name to use when rendering property-value When null (or empty) then value-attribute is not included and value is formatted as XML-element-value - - - - - Option to include all properties from the log event (as XML) - - - - - - - - - - - - - - - - - Name of the attribute. - - - - - Layout that will be rendered as the attribute's value. - - - - - Fallback value when result value is not available - - - - - Determines whether or not this attribute will be Xml encoded. - - - - - Whether an attribute with empty value should be included in the output - - - - - Result value type, for conversion of layout rendering output - - - - - - - - - - - - - - - - - - - - - - - - Name of the element - - - - - Whether to include the contents of the T:NLog.ScopeContext dictionary. - - - - - Value inside the element - - - - - Determines whether or not this attribute will be Xml encoded. - - - - - List of property names to exclude when P:NLog.Layouts.XmlElementBase.IncludeAllProperties is true - - - - - Whether a ElementValue with empty value should be included in the output - - - - - Auto indent and create new lines - - - - - How far should the XML serializer follow object references before backing off - - - - - XML element name to use for rendering IList-collections items - - - - - XML attribute name to use when rendering property-key When null (or empty) then key-attribute is not included - - - - - XML element name to use when rendering properties - - - - - XML attribute name to use when rendering property-value When null (or empty) then value-attribute is not included and value is formatted as XML-element-value - - - - - Option to include all properties from the log event (as XML) - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Condition expression. - - - - - - - - - - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - Substring to be matched. - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - String to compare the layout to. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - Substring to be matched. - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - String to compare the layout to. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - - - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Append FilterCount to the P:NLog.LogEventInfo.Message when an event is no longer filtered - - - - - Insert FilterCount value into P:NLog.LogEventInfo.Properties when an event is no longer filtered - - - - - Applies the configured action to the initial logevent that starts the timeout period. Used to configure that it should ignore all events until timeout. - - - - - Layout to be used to filter log messages. - - - - - Max length of filter values, will truncate if above limit - - - - - How long before a filter expires, and logging is accepted again - - - - - Default number of unique filter values to expect, will automatically increase if needed - - - - - Max number of unique filter values to expect simultaneously - - - - - Default buffer size for the internal buffers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/KfChatDotNetCli/Program.cs b/KfChatDotNetCli/Program.cs deleted file mode 100644 index 1a93c05..0000000 --- a/KfChatDotNetCli/Program.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Net; -using System.Text; -using CommandLine; -using NLog; - -namespace KfChatDotNetCli -{ - public class Program - { - public class Options - { - [Option('t', "token", Required = false, Default = null, HelpText = "XF session token from the 'xf_session' cookie")] - public string XfSessionToken { get; set; } = null!; - - [Option("debug", Required = false, Default = false, HelpText = "Enable debug logging")] - public bool Debug { get; set; } - [Option('r', "room", Required = false, Default = int.MaxValue, HelpText = "Room ID to join on start")] - public int RoomId { get; set; } - } - static void Main(string[] args) - { - Console.OutputEncoding = Encoding.UTF8; - Parser.Default.ParseArguments(args).WithParsed(CliOptions); - } - - static void CliOptions(Options options) - { - ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13; - if (options.Debug) - { - foreach (var rule in LogManager.Configuration.LoggingRules) - { - rule.EnableLoggingForLevel(LogLevel.Debug); - } - } - - new ChatCliMain(options.XfSessionToken, options.RoomId); - } - } -} diff --git a/KfChatDotNetGui/.gitignore b/KfChatDotNetGui/.gitignore deleted file mode 100644 index 8afdcb6..0000000 --- a/KfChatDotNetGui/.gitignore +++ /dev/null @@ -1,454 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# Tye -.tye/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd - -## -## Visual studio for Mac -## - - -# globs -Makefile.in -*.userprefs -*.usertasks -config.make -config.status -aclocal.m4 -install-sh -autom4te.cache/ -*.tar.gz -tarballs/ -test-results/ - -# Mac bundle stuff -*.dmg -*.app - -# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore -# Windows thumbnail cache files -Thumbs.db -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# JetBrains Rider -.idea/ -*.sln.iml - -## -## Visual Studio Code -## -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json diff --git a/KfChatDotNetGui/App.axaml b/KfChatDotNetGui/App.axaml deleted file mode 100644 index 17b4d69..0000000 --- a/KfChatDotNetGui/App.axaml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - diff --git a/KfChatDotNetGui/App.axaml.cs b/KfChatDotNetGui/App.axaml.cs deleted file mode 100644 index 10d7c0c..0000000 --- a/KfChatDotNetGui/App.axaml.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Collections.ObjectModel; -using System.IO; -using System.Text.Json; -using Avalonia; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Markup.Xaml; -using KfChatDotNetGui.Models; -using KfChatDotNetGui.ViewModels; -using KfChatDotNetGui.Views; -using NLog; - -namespace KfChatDotNetGui -{ - public partial class App : Application - { - public override void Initialize() - { - AvaloniaXamlLoader.Load(this); - } - - public override void OnFrameworkInitializationCompleted() - { - var logger = LogManager.GetCurrentClassLogger(); - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) - { - var dataContext = new MainWindowViewModel(); - if (File.Exists("rooms.json")) - { - var rooms = JsonSerializer.Deserialize(File.ReadAllText("rooms.json")); - dataContext.RoomList = rooms!.Rooms; - - } - dataContext.Messages.Add(new MainWindowViewModel.MessageViewModel - { - Author = "SneedChat", - Messages = new ObservableCollection{ - new(){ - Message = "Welcome to my shitty chat client.", - MessageId = 0, - OwnMessage = false - }, - new() - { - Message = "Click on Settings -> Identity to configure your XenForo token so you may connect to SneedChat", - MessageId = 0, - OwnMessage = false - } - }, - PostedAt = DateTimeOffset.Now, - AuthorId = -1 - }); - if (dataContext.RoomList.Count == 0) - { - dataContext.Messages[0].Messages.Add(new MainWindowViewModel.InnerMessageViewModel - { - Message = "Also it looks like you have no rooms configured. Click on Settings -> Rooms to configure the room list", - MessageId = 0, - OwnMessage = false - }); - } - desktop.MainWindow = new MainWindow - { - DataContext = dataContext - }; - } - - base.OnFrameworkInitializationCompleted(); - } - } -} \ No newline at end of file diff --git a/KfChatDotNetGui/Assets/avalonia-logo.ico b/KfChatDotNetGui/Assets/avalonia-logo.ico deleted file mode 100644 index da8d49f..0000000 Binary files a/KfChatDotNetGui/Assets/avalonia-logo.ico and /dev/null differ diff --git a/KfChatDotNetGui/Helpers/ForumIdentity.cs b/KfChatDotNetGui/Helpers/ForumIdentity.cs deleted file mode 100644 index f69aa47..0000000 --- a/KfChatDotNetGui/Helpers/ForumIdentity.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Text.Json; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using KfChatDotNetGui.Models; - -namespace KfChatDotNetGui.Helpers; - -public static class ForumIdentity -{ - public static async Task GetForumIdentity(string xfSession, Uri sneedChatUri, string? antiDdosPowCookie = null) - { - CookieContainer cookies = new CookieContainer(); - cookies.Add(new Cookie("xf_session", xfSession, "/", sneedChatUri.Host)); - if (antiDdosPowCookie != null) - { - cookies.Add(new Cookie("z_ddos_pow", antiDdosPowCookie, "/", sneedChatUri.Host)); - } - using (var client = new HttpClient(new HttpClientHandler {AutomaticDecompression = DecompressionMethods.All, CookieContainer = cookies})) - { - client.DefaultRequestHeaders.UserAgent.TryParseAdd("KfChatDotNetGui/1.0"); - client.DefaultRequestHeaders.Accept.Clear(); - client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/html")); - client.DefaultRequestHeaders.AcceptLanguage.Add(new StringWithQualityHeaderValue("en-US")); - var response = await client.GetAsync(sneedChatUri); - response.EnsureSuccessStatusCode(); - var html = await response.Content.ReadAsStringAsync(); - var accountRegex = new Regex(@"user: (.+),"); - var match = accountRegex.Match(html); - if (!match.Success) - { - throw new Exception("Shitty regex failed to extract account information"); - } - - var accountJs = match.Groups[1].Value; - return JsonSerializer.Deserialize(accountJs); - } - } -} \ No newline at end of file diff --git a/KfChatDotNetGui/KfChatDotNetGui.csproj b/KfChatDotNetGui/KfChatDotNetGui.csproj deleted file mode 100644 index 272a5b3..0000000 --- a/KfChatDotNetGui/KfChatDotNetGui.csproj +++ /dev/null @@ -1,36 +0,0 @@ - - - WinExe - net8.0 - enable - - copyused - true - default - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/KfChatDotNetGui/Models/ForumIdentityModel.cs b/KfChatDotNetGui/Models/ForumIdentityModel.cs deleted file mode 100644 index 3c84c48..0000000 --- a/KfChatDotNetGui/Models/ForumIdentityModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.Json.Serialization; - -namespace KfChatDotNetGui.Models; - -public class ForumIdentityModel -{ - [JsonPropertyName("id")] - public int Id { get; set; } - [JsonPropertyName("username")] - public string Username { get; set; } - [JsonPropertyName("avatar_url")] - public Uri AvatarUrl { get; set; } - // Guessing it'll be the user ID as an int but no idea as this list is empty for me - [JsonPropertyName("ignored_users")] - public List IgnoredUsers { get; set; } - [JsonPropertyName("is_staff")] - public bool IsStaff { get; set; } -} \ No newline at end of file diff --git a/KfChatDotNetGui/Models/RoomSettingsModel.cs b/KfChatDotNetGui/Models/RoomSettingsModel.cs deleted file mode 100644 index cfeb305..0000000 --- a/KfChatDotNetGui/Models/RoomSettingsModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; - -namespace KfChatDotNetGui.Models; - -public class RoomSettingsModel -{ - public class RoomList - { - public string Name { get; set; } - public int Id { get; set; } - } - - public List Rooms { get; set; } -} \ No newline at end of file diff --git a/KfChatDotNetGui/Models/SettingsModel.cs b/KfChatDotNetGui/Models/SettingsModel.cs deleted file mode 100644 index 2725b26..0000000 --- a/KfChatDotNetGui/Models/SettingsModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace KfChatDotNetGui.Models; - -public class SettingsModel -{ - public string XfSessionToken { get; set; } - public Uri WsUri { get; set; } - public int ReconnectTimeout { get; set; } - public string AntiDdosPow { get; set; } - public string Username { get; set; } -} \ No newline at end of file diff --git a/KfChatDotNetGui/NLog.config b/KfChatDotNetGui/NLog.config deleted file mode 100644 index e255848..0000000 --- a/KfChatDotNetGui/NLog.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/KfChatDotNetGui/NLog.xsd b/KfChatDotNetGui/NLog.xsd deleted file mode 100644 index e2b7858..0000000 --- a/KfChatDotNetGui/NLog.xsd +++ /dev/null @@ -1,3483 +0,0 @@ - - - - - - - - - - - - - - - Watch config file for changes and reload automatically. - - - - - Print internal NLog messages to the console. Default value is: false - - - - - Print internal NLog messages to the console error output. Default value is: false - - - - - Write internal NLog messages to the specified file. - - - - - Log level threshold for internal log messages. Default value is: Info. - - - - - Global log level threshold for application log messages. Messages below this level won't be logged. - - - - - Throw an exception when there is an internal error. Default value is: false. Not recommend to set to true in production! - - - - - Throw an exception when there is a configuration error. If not set, determined by throwExceptions. - - - - - Gets or sets a value indicating whether Variables should be kept on configuration reload. Default value is: false. - - - - - Write internal NLog messages to the System.Diagnostics.Trace. Default value is: false. - - - - - Write timestamps for internal NLog messages. Default value is: true. - - - - - Use InvariantCulture as default culture instead of CurrentCulture. Default value is: false. - - - - - Perform message template parsing and formatting of LogEvent messages (true = Always, false = Never, empty = Auto Detect). Default value is: empty. - - - - - - - - - - - - - - Make all targets within this section asynchronous (creates additional threads but the calling thread isn't blocked by any target writes). - - - - - - - - - - - - - - - - - Prefix for targets/layout renderers/filters/conditions loaded from this assembly. - - - - - Load NLog extensions from the specified file (*.dll) - - - - - Load NLog extensions from the specified assembly. Assembly name should be fully qualified. - - - - - - - - - - Filter on the name of the logger. May include wildcard characters ('*' or '?'). - - - - - Comma separated list of levels that this rule matches. - - - - - Minimum level that this rule matches. - - - - - Maximum level that this rule matches. - - - - - Level that this rule matches. - - - - - Comma separated list of target names. - - - - - Ignore further rules if this one matches. - - - - - Enable this rule. Note: disabled rules aren't available from the API. - - - - - Rule identifier to allow rule lookup with Configuration.FindRuleByName and Configuration.RemoveRuleByName. - - - - - Loggers matching will be restricted to specified minimum level for following rules. - - - - - - - - - - - - - - - Default action if none of the filters match. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the file to be included. You could use * wildcard. The name is relative to the name of the current config file. - - - - - Ignore any errors in the include file. - - - - - - - - Variable value. Note, the 'value' attribute has precedence over this one. - - - - - - Variable name. - - - - - Variable value. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Action to be taken when the lazy writer thread request queue count exceeds the set limit. - - - - - Limit on the number of requests in the lazy writer thread request queue. - - - - - Number of log events that should be processed in a batch by the lazy writer thread. - - - - - Whether to use the locking queue, instead of a lock-free concurrent queue - - - - - Number of batches of P:NLog.Targets.Wrappers.AsyncTargetWrapper.BatchSize to write before yielding into P:NLog.Targets.Wrappers.AsyncTargetWrapper.TimeToSleepBetweenBatches - - - - - Time in milliseconds to sleep between batches. (1 or less means trigger on new activity) - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Delay the flush until the LogEvent has been confirmed as written - - - - - Condition expression. Log events who meet this condition will cause a flush on the wrapped target. - - - - - Only flush when LogEvent matches condition. Ignore explicit-flush, config-reload-flush and shutdown-flush - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Number of log events to be buffered. - - - - - Action to take if the buffer overflows. - - - - - Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes. - - - - - Indicates whether to use sliding timeout. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Separator for T:NLog.ScopeContext operation-states-stack. - - - - - Stack separator for log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Renderer for log4j:event logger-xml-attribute (Default ${logger}) - - - - - Whether to include the contents of the T:NLog.ScopeContext properties-dictionary. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Indicates whether to include source info (file name and line number) in the information sent over the network. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Option to include all properties from the log events - - - - - Indicates whether to include call site (class and method name) in the information sent over the network. - - - - - AppInfo field. By default it's the friendly name of the current AppDomain. - - - - - Instance of T:NLog.Layouts.Log4JXmlEventLayout that is used to format log messages. - - - - - Indicates whether to include NLog-specific extensions to log4j schema. - - - - - Action that should be taken, when more connections than P:NLog.Targets.NetworkTarget.MaxConnections. - - - - - SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - - - - - Action that should be taken, when more pending messages than P:NLog.Targets.NetworkTarget.MaxQueueSize. - - - - - Action that should be taken if the message is larger than P:NLog.Targets.NetworkTarget.MaxMessageSize - - - - - Maximum queue size for a single connection. Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Network address. - - - - - Indicates whether to keep connection open whenever possible. - - - - - The number of seconds a connection will remain idle before the first keep-alive probe is sent - - - - - Size of the connection cache (number of connections which are kept alive). Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Maximum simultaneous connections. Requires P:NLog.Targets.NetworkTarget.KeepConnection = false - - - - - Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - - - - - Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - - - - - Maximum message size in bytes. On limit breach then P:NLog.Targets.NetworkTarget.OnOverflow action is activated. - - - - - Encoding to be used. - - - - - End of line value if a newline is appended at the end of log message P:NLog.Targets.NetworkTarget.NewLine. - - - - - Indicates whether to append newline at the end of log message. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Viewer parameter name. - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Whether an attribute with empty value should be included in the output - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether to auto-check if the console is available. - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) - - - - - Enables output using ANSI Color Codes - - - - - The encoding for writing messages to the T:System.Console. - - - - - Indicates whether to send the log messages to the standard error instead of the standard output. - - - - - Indicates whether to auto-flush after M:System.Console.WriteLine - - - - - Indicates whether to auto-check if the console has been redirected to file - Disables coloring logic when System.Console.IsOutputRedirected = true - - - - - Indicates whether to use default row highlighting rules. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Background color. - - - - - Condition that must be met in order to set the specified foreground and background color. - - - - - Foreground color. - - - - - - - - - - - - - - - - - Background color. - - - - - Compile the P:NLog.Targets.ConsoleWordHighlightingRule.Regex? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used. - - - - - Condition that must be met before scanning the row for highlight of words - - - - - Foreground color. - - - - - Indicates whether to ignore case when comparing texts. - - - - - Regular expression to be matched. You must specify either text or regex. - - - - - Text to be matched. You must specify either text or regex. - - - - - Indicates whether to match whole words only. - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether to auto-flush after M:System.Console.WriteLine - - - - - Indicates whether to auto-check if the console is available - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) - - - - - The encoding for writing messages to the T:System.Console. - - - - - Indicates whether to send the log messages to the standard error instead of the standard output. - - - - - Whether to activate internal buffering to allow batch writing, instead of using M:System.Console.WriteLine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string. - - - - - Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string. - - - - - Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string. - - - - - Name of the connection string (as specified in <connectionStrings> configuration section. - - - - - Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string. - - - - - Indicates whether to keep the database connection open between the log events. - - - - - Name of the database provider. - - - - - Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase. - - - - - Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used. - - - - - Configures isolated transaction batch writing. If supported by the database, then it will improve insert performance. - - - - - Text of the SQL command to be run on each log level. - - - - - Type of the SQL command to be run on each log level. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Convert format of the property value - - - - - Culture used for parsing property string-value for type-conversion - - - - - Value to assign on the object-property - - - - - Name for the object-property - - - - - Type of the object-property - - - - - - - - - - - - - - Type of the command. - - - - - Connection string to run the command against. If not provided, connection string from the target is used. - - - - - Indicates whether to ignore failures. - - - - - Command text. - - - - - - - - - - - - - - - - - - - - Database parameter name. - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Database parameter DbType. - - - - - Database parameter size. - - - - - Database parameter precision. - - - - - Database parameter scale. - - - - - Type of the parameter. - - - - - Fallback value when result value is not available - - - - - Convert format of the database parameter value. - - - - - Culture used for parsing parameter string-value for type-conversion - - - - - Whether empty value should translate into DbNull. Requires database column to allow NULL values. - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Layout that renders event Category. - - - - - Optional entry type. When not set, or when not convertible to T:System.Diagnostics.EventLogEntryType then determined by T:NLog.LogLevel - - - - - Layout that renders event ID. - - - - - Name of the Event Log to write to. This can be System, Application or any user-defined name. - - - - - Name of the machine on which Event Log service is running. - - - - - Maximum Event log size in kilobytes. - - - - - Message length limit to write to the Event Log. - - - - - Value to be used as the event Source. - - - - - Action to take if the message is larger than the P:NLog.Targets.EventLogTarget.MaxMessageLength option. - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Indicates whether to return to the first target after any successful write. - - - - - Whether to enable batching, but fallback will be handled individually - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Name of the file to write to. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether the footer should be written only when the file is archived. - - - - - Maximum number of archive files that should be kept. - - - - - Maximum days of archive files that should be kept. - - - - - Value of the file size threshold to archive old log file on startup. - - - - - Indicates whether to archive old log file on startup. - - - - - Indicates whether to compress archive files into the zip archive format. - - - - - Name of the file to be used for an archive. - - - - - Is the P:NLog.Targets.FileTarget.ArchiveFileName an absolute or relative path? - - - - - Indicates whether to automatically archive log files every time the specified time passes. - - - - - Value specifying the date format to use when archiving files. - - - - - Size in bytes above which log files will be automatically archived. - - - - - Way file archives are numbered. - - - - - Indicates whether to create directories if they do not exist. - - - - - Indicates whether file creation calls should be synchronized by a system global mutex. - - - - - Gets or set a value indicating whether a managed file stream is forced, instead of using the native implementation. - - - - - Is the P:NLog.Targets.FileTarget.FileName an absolute or relative path? - - - - - File attributes (Windows only). - - - - - Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong. - - - - - Indicates whether to write BOM (byte order mark) in created files. Defaults to true for UTF-16 and UTF-32 - - - - - Indicates whether to enable log file(s) to be deleted. - - - - - Indicates whether to delete old log file on startup. - - - - - File encoding. - - - - - Indicates whether to replace file contents on each write instead of appending log message at the end. - - - - - Line ending mode. - - - - - Number of times the write is appended on the file before NLog discards the log message. - - - - - Delay in milliseconds to wait before attempting to write to the file again. - - - - - Maximum number of seconds before open files are flushed. Zero or negative means disabled. - - - - - Maximum number of seconds that files are kept open. Zero or negative means disabled. - - - - - Indicates whether concurrent writes to the log file by multiple processes on different network hosts. - - - - - Log file buffer size in bytes. - - - - - Indicates whether to automatically flush the file buffers after each log message. - - - - - Indicates whether to keep log file open instead of opening and closing it on each logging event. - - - - - Indicates whether concurrent writes to the log file by multiple processes on the same host. - - - - - Whether or not this target should just discard all data that its asked to write. Mostly used for when testing NLog Stack except final write - - - - - Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Condition expression. Log events who meet this condition will be forwarded to the wrapped target. - - - - - - - - - - - - - - - Name of the target. - - - - - Identifier to perform group-by - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Windows domain name to change context to. - - - - - Required impersonation level. - - - - - Type of the logon provider. - - - - - Logon Type. - - - - - User account password. - - - - - Indicates whether to revert to the credentials of the process instead of impersonating another user. - - - - - Username to change context to. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Interval in which messages will be written up to the P:NLog.Targets.Wrappers.LimitingTargetWrapper.MessageLimit number of messages. - - - - - Maximum allowed number of messages written per P:NLog.Targets.Wrappers.LimitingTargetWrapper.Interval. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether NewLine characters in the body should be replaced with tags. - - - - - Priority used for sending mails. - - - - - Encoding to be used for sending e-mail. - - - - - BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - Indicates whether to add new lines between log entries. - - - - - Indicates whether to send message as HTML instead of plain text. - - - - - Sender's email address (e.g. joe@domain.com). - - - - - Mail message body (repeated for each log message send in one mail). - - - - - Mail subject. - - - - - Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - Specifies how outgoing email messages will be handled. - - - - - SMTP Server to be used for sending. - - - - - SMTP Authentication mode. - - - - - Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic"). - - - - - Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic"). - - - - - Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server. - - - - - Port number that SMTP Server is listening on. - - - - - Indicates whether the default Settings from System.Net.MailSettings should be used. - - - - - Folder where applications save mail messages to be processed by the local SMTP server. - - - - - Indicates the SMTP client timeout. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Max number of items to have in memory - - - - - - - - - - - - - - - - - Name of the target. - - - - - Class name. - - - - - Method name. The method must be public and static. Use the AssemblyQualifiedName , https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx e.g. - - - - - - - - - - - - - - - Name of the parameter. - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Fallback value when result value is not available - - - - - Type of the parameter. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - - - - - Action that should be taken, when more pending messages than P:NLog.Targets.NetworkTarget.MaxQueueSize. - - - - - Action that should be taken if the message is larger than P:NLog.Targets.NetworkTarget.MaxMessageSize - - - - - Maximum queue size for a single connection. Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Action that should be taken, when more connections than P:NLog.Targets.NetworkTarget.MaxConnections. - - - - - Indicates whether to keep connection open whenever possible. - - - - - The number of seconds a connection will remain idle before the first keep-alive probe is sent - - - - - Size of the connection cache (number of connections which are kept alive). Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Network address. - - - - - Maximum simultaneous connections. Requires P:NLog.Targets.NetworkTarget.KeepConnection = false - - - - - Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - - - - - Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - - - - - Maximum message size in bytes. On limit breach then P:NLog.Targets.NetworkTarget.OnOverflow action is activated. - - - - - Encoding to be used. - - - - - End of line value if a newline is appended at the end of log message P:NLog.Targets.NetworkTarget.NewLine. - - - - - Indicates whether to append newline at the end of log message. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Separator for T:NLog.ScopeContext operation-states-stack. - - - - - Stack separator for log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Renderer for log4j:event logger-xml-attribute (Default ${logger}) - - - - - Whether to include the contents of the T:NLog.ScopeContext properties-dictionary. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Indicates whether to include source info (file name and line number) in the information sent over the network. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Option to include all properties from the log events - - - - - Indicates whether to include call site (class and method name) in the information sent over the network. - - - - - AppInfo field. By default it's the friendly name of the current AppDomain. - - - - - Instance of T:NLog.Layouts.Log4JXmlEventLayout that is used to format log messages. - - - - - Indicates whether to include NLog-specific extensions to log4j schema. - - - - - Action that should be taken, when more connections than P:NLog.Targets.NetworkTarget.MaxConnections. - - - - - SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - - - - - Action that should be taken, when more pending messages than P:NLog.Targets.NetworkTarget.MaxQueueSize. - - - - - Action that should be taken if the message is larger than P:NLog.Targets.NetworkTarget.MaxMessageSize - - - - - Maximum queue size for a single connection. Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Network address. - - - - - Indicates whether to keep connection open whenever possible. - - - - - The number of seconds a connection will remain idle before the first keep-alive probe is sent - - - - - Size of the connection cache (number of connections which are kept alive). Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Maximum simultaneous connections. Requires P:NLog.Targets.NetworkTarget.KeepConnection = false - - - - - Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - - - - - Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - - - - - Maximum message size in bytes. On limit breach then P:NLog.Targets.NetworkTarget.OnOverflow action is activated. - - - - - Encoding to be used. - - - - - End of line value if a newline is appended at the end of log message P:NLog.Targets.NetworkTarget.NewLine. - - - - - Indicates whether to append newline at the end of log message. - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Indicates whether to perform layout calculation. - - - - - - - - - - - - - - - - Name of the target. - - - - - Default filter to be applied when no specific rule matches. - - - - - - - - - - - - - Condition to be tested. - - - - - Resulting filter to be applied when the condition matches. - - - - - - - - - - - - Name of the target. - - - - - - - - - - - - - - - Name of the target. - - - - - Number of times to repeat each log message. - - - - - - - - - - - - - - - - - Name of the target. - - - - - Whether to enable batching, and only apply single delay when a whole batch fails - - - - - Number of retries that should be attempted on the wrapped target in case of a failure. - - - - - Time to wait between retries in milliseconds. - - - - - - - - - - - - - - Name of the target. - - - - - - - - - - - - - - Name of the target. - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Forward F:NLog.LogLevel.Fatal to M:System.Diagnostics.Trace.Fail(System.String) (Instead of M:System.Diagnostics.Trace.TraceError(System.String)) - - - - - Force use M:System.Diagnostics.Trace.WriteLine(System.String) independent of T:NLog.LogLevel - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Indicates whether to pre-authenticate the HttpWebRequest (Requires 'Authorization' in P:NLog.Targets.WebServiceTarget.Headers parameters) - - - - - Value whether escaping be done according to Rfc3986 (Supports Internationalized Resource Identifiers - IRIs) - - - - - Value whether escaping be done according to the old NLog style (Very non-standard) - - - - - Value of the User-agent HTTP header. - - - - - Web service URL. - - - - - Proxy configuration when calling web service - - - - - Custom proxy address, include port separated by a colon - - - - - Protocol to be used when calling web service. - - - - - Web service namespace. Only used with Soap. - - - - - Web service method name. Only used with Soap. - - - - - Should we include the BOM (Byte-order-mark) for UTF? Influences the P:NLog.Targets.WebServiceTarget.Encoding property. This will only work for UTF-8. - - - - - Encoding. - - - - - Name of the root XML element, if POST of XML document chosen. If so, this property must not be null. (see P:NLog.Targets.WebServiceTarget.Protocol and F:NLog.Targets.WebServiceProtocol.XmlPost). - - - - - (optional) root namespace of the XML document, if POST of XML document chosen. (see P:NLog.Targets.WebServiceTarget.Protocol and F:NLog.Targets.WebServiceProtocol.XmlPost). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom'). - - - - - Column delimiter. - - - - - Footer layout. - - - - - Header layout. - - - - - Body layout (can be repeated multiple times). - - - - - Quote Character. - - - - - Quoting mode. - - - - - Indicates whether CVS should include header. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the column. - - - - - Layout of the column. - - - - - Override of Quoting mode - - - - - - - - - - - - - - Option to render the empty object value {} - - - - - Option to suppress the extra spaces in the output json - - - - - - - - - - - - - - - - - - - - - - - Option to include all properties from the log event (as JSON) - - - - - Indicates whether to include contents of the T:NLog.GlobalDiagnosticsContext dictionary. - - - - - Whether to include the contents of the T:NLog.ScopeContext dictionary. - - - - - Should forward slashes be escaped? If true, / will be converted to \/ - - - - - Option to exclude null/empty properties from the log event (as JSON) - - - - - List of property names to exclude when P:NLog.Layouts.JsonLayout.IncludeAllProperties is true - - - - - How far should the JSON serializer follow object references before backing off - - - - - Option to render the empty object value {} - - - - - Option to suppress the extra spaces in the output json - - - - - - - - - - - - - - - - - - - Name of the attribute. - - - - - Layout that will be rendered as the attribute's value. - - - - - Fallback value when result value is not available - - - - - Determines whether or not this attribute will be Json encoded. - - - - - Should forward slashes be escaped? If true, / will be converted to \/ - - - - - Indicates whether to escape non-ascii characters - - - - - Whether an attribute with empty value should be included in the output - - - - - Result value type, for conversion of layout rendering output - - - - - - - - - - - - - - Footer layout. - - - - - Header layout. - - - - - Body layout (can be repeated multiple times). - - - - - - - - - - - - - - - - - - - - - - - Option to include all properties from the log events - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Whether to include the contents of the T:NLog.ScopeContext properties-dictionary. - - - - - AppInfo field. By default it's the friendly name of the current AppDomain. - - - - - Indicates whether to include call site (class and method name) in the information sent over the network. - - - - - Indicates whether to include source info (file name and line number) in the information sent over the network. - - - - - Log4j:event logger-xml-attribute (Default ${logger}) - - - - - Whether the log4j:throwable xml-element should be written as CDATA - - - - - - - - - - - - - - Layout text. - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the root XML element - - - - - Value inside the root XML element - - - - - Whether to include the contents of the T:NLog.ScopeContext dictionary. - - - - - Determines whether or not this attribute will be Xml encoded. - - - - - List of property names to exclude when P:NLog.Layouts.XmlElementBase.IncludeAllProperties is true - - - - - Whether a ElementValue with empty value should be included in the output - - - - - Auto indent and create new lines - - - - - How far should the XML serializer follow object references before backing off - - - - - XML element name to use for rendering IList-collections items - - - - - XML attribute name to use when rendering property-key When null (or empty) then key-attribute is not included - - - - - XML element name to use when rendering properties - - - - - XML attribute name to use when rendering property-value When null (or empty) then value-attribute is not included and value is formatted as XML-element-value - - - - - Option to include all properties from the log event (as XML) - - - - - - - - - - - - - - - - - Name of the attribute. - - - - - Layout that will be rendered as the attribute's value. - - - - - Fallback value when result value is not available - - - - - Determines whether or not this attribute will be Xml encoded. - - - - - Whether an attribute with empty value should be included in the output - - - - - Result value type, for conversion of layout rendering output - - - - - - - - - - - - - - - - - - - - - - - - Name of the element - - - - - Whether to include the contents of the T:NLog.ScopeContext dictionary. - - - - - Value inside the element - - - - - Determines whether or not this attribute will be Xml encoded. - - - - - List of property names to exclude when P:NLog.Layouts.XmlElementBase.IncludeAllProperties is true - - - - - Whether a ElementValue with empty value should be included in the output - - - - - Auto indent and create new lines - - - - - How far should the XML serializer follow object references before backing off - - - - - XML element name to use for rendering IList-collections items - - - - - XML attribute name to use when rendering property-key When null (or empty) then key-attribute is not included - - - - - XML element name to use when rendering properties - - - - - XML attribute name to use when rendering property-value When null (or empty) then value-attribute is not included and value is formatted as XML-element-value - - - - - Option to include all properties from the log event (as XML) - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Condition expression. - - - - - - - - - - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - Substring to be matched. - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - String to compare the layout to. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - Substring to be matched. - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - String to compare the layout to. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - - - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Append FilterCount to the P:NLog.LogEventInfo.Message when an event is no longer filtered - - - - - Insert FilterCount value into P:NLog.LogEventInfo.Properties when an event is no longer filtered - - - - - Applies the configured action to the initial logevent that starts the timeout period. Used to configure that it should ignore all events until timeout. - - - - - Layout to be used to filter log messages. - - - - - Max length of filter values, will truncate if above limit - - - - - How long before a filter expires, and logging is accepted again - - - - - Default number of unique filter values to expect, will automatically increase if needed - - - - - Max number of unique filter values to expect simultaneously - - - - - Default buffer size for the internal buffers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/KfChatDotNetGui/Program.cs b/KfChatDotNetGui/Program.cs deleted file mode 100644 index ce5b262..0000000 --- a/KfChatDotNetGui/Program.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Avalonia; -using Avalonia.ReactiveUI; -using System; - -namespace KfChatDotNetGui -{ - class Program - { - // Initialization code. Don't use any Avalonia, third-party APIs or any - // SynchronizationContext-reliant code before AppMain is called: things aren't initialized - // yet and stuff might break. - [STAThread] - public static void Main(string[] args) => BuildAvaloniaApp() - .StartWithClassicDesktopLifetime(args); - - // Avalonia configuration, don't remove; also used by visual designer. - public static AppBuilder BuildAvaloniaApp() - => AppBuilder.Configure() - .UsePlatformDetect() - .LogToTrace() - .UseReactiveUI(); - } -} \ No newline at end of file diff --git a/KfChatDotNetGui/ViewLocator.cs b/KfChatDotNetGui/ViewLocator.cs deleted file mode 100644 index 099121d..0000000 --- a/KfChatDotNetGui/ViewLocator.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Avalonia.Controls; -using Avalonia.Controls.Templates; -using KfChatDotNetGui.ViewModels; - -namespace KfChatDotNetGui -{ - public class ViewLocator : IDataTemplate - { - public Control Build(object data) - { - var name = data.GetType().FullName!.Replace("ViewModel", "View"); - var type = Type.GetType(name); - - if (type != null) - { - return (Control) Activator.CreateInstance(type)!; - } - - return new TextBlock {Text = "Not Found: " + name}; - } - - public bool Match(object data) - { - return data is ViewModelBase; - } - } -} \ No newline at end of file diff --git a/KfChatDotNetGui/ViewModels/IdentitySettingsWindowViewModel.cs b/KfChatDotNetGui/ViewModels/IdentitySettingsWindowViewModel.cs deleted file mode 100644 index 5fff1f7..0000000 --- a/KfChatDotNetGui/ViewModels/IdentitySettingsWindowViewModel.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using ReactiveUI; - -namespace KfChatDotNetGui.ViewModels; - -public class IdentitySettingsWindowViewModel : ViewModelBase -{ - private Uri _wsUri = new ("wss://kiwifarms.net/chat.ws"); - - public Uri WsUri - { - get => _wsUri; - set => this.RaiseAndSetIfChanged(ref _wsUri, value); - } - - private string _xfSessionToken; - - public string XfSessionToken - { - get => _xfSessionToken; - set => this.RaiseAndSetIfChanged(ref _xfSessionToken, value); - } - - private string _antiDdosPow; - - public string AntiDdosPow - { - get => _antiDdosPow; - set => this.RaiseAndSetIfChanged(ref _antiDdosPow, value); - } - - private string _username; - - public string Username - { - get => _username; - set => this.RaiseAndSetIfChanged(ref _username, value); - } - - private int _reconnectTimeout = 30; - - public int ReconnectTimeout - { - get => _reconnectTimeout; - set => this.RaiseAndSetIfChanged(ref _reconnectTimeout, value); - } -} \ No newline at end of file diff --git a/KfChatDotNetGui/ViewModels/MainWindowViewModel.cs b/KfChatDotNetGui/ViewModels/MainWindowViewModel.cs deleted file mode 100644 index 110fb23..0000000 --- a/KfChatDotNetGui/ViewModels/MainWindowViewModel.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Runtime.CompilerServices; -using Avalonia.Media; -using JetBrains.Annotations; -using KfChatDotNetGui.Models; -using ReactiveUI; - -namespace KfChatDotNetGui.ViewModels -{ - public class MainWindowViewModel : ViewModelBase - { - public class InnerMessageViewModel : INotifyPropertyChanged - { - private string _message; - - public string Message - { - get => _message; - set - { - if (_message == value) return; - _message = value; - OnPropertyChanged(); - } - } - - private bool _isHighlighted = false; - - public bool IsHighlighted - { - get => _isHighlighted; - set - { - if (_isHighlighted == value) return; - _isHighlighted = value; - OnPropertyChanged(); - } - } - - public int MessageId { get; set; } - public bool OwnMessage { get; set; } - - public event PropertyChangedEventHandler? PropertyChanged; - - protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - } - - public class MessageViewModel : INotifyPropertyChanged - { - private ObservableCollection _messages; - - public ObservableCollection Messages - { - get => _messages; - set - { - if (_messages == value) return; - _messages = value; - OnPropertyChanged(); - } - } - - public DateTimeOffset PostedAt { get; set; } - public string Author { get; set; } - public int AuthorId { get; set; } - public event PropertyChangedEventHandler? PropertyChanged; - - protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - } - - public class UserListViewModel - { - public string Name { get; set; } - public int Id { get; set; } - } - - private string _statusText = "Not connected"; - - public string Status - { - get => _statusText; - set => this.RaiseAndSetIfChanged(ref _statusText, value); - } - - private int _userId; - - public int UserId - { - get => _userId; - set => this.RaiseAndSetIfChanged(ref _userId, value); - } - - private List _roomList = new(); - - public List RoomList - { - get => _roomList; - set => this.RaiseAndSetIfChanged(ref _roomList, value); - } - - private ObservableCollection _userList = new(); - - public ObservableCollection UserList - { - get => _userList; - set => this.RaiseAndSetIfChanged(ref _userList, value); - } - - private ObservableCollection _messages = new(); - - public ObservableCollection Messages - { - get => _messages; - set => this.RaiseAndSetIfChanged(ref _messages, value); - } - } -} \ No newline at end of file diff --git a/KfChatDotNetGui/ViewModels/RoomSettingsWindowViewModel.cs b/KfChatDotNetGui/ViewModels/RoomSettingsWindowViewModel.cs deleted file mode 100644 index b6470af..0000000 --- a/KfChatDotNetGui/ViewModels/RoomSettingsWindowViewModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.ObjectModel; -using KfChatDotNetGui.Models; -using ReactiveUI; - -namespace KfChatDotNetGui.ViewModels; - -public class RoomSettingsWindowViewModel : ViewModelBase -{ - - private ObservableCollection _roomList = new() - { - new RoomSettingsModel.RoomList {Id = 1, Name = "General"} - }; - - public ObservableCollection RoomList - { - get => _roomList; - set => this.RaiseAndSetIfChanged(ref _roomList, value); - } -} \ No newline at end of file diff --git a/KfChatDotNetGui/ViewModels/ViewModelBase.cs b/KfChatDotNetGui/ViewModels/ViewModelBase.cs deleted file mode 100644 index 7bf7f83..0000000 --- a/KfChatDotNetGui/ViewModels/ViewModelBase.cs +++ /dev/null @@ -1,8 +0,0 @@ -using ReactiveUI; - -namespace KfChatDotNetGui.ViewModels -{ - public class ViewModelBase : ReactiveObject - { - } -} \ No newline at end of file diff --git a/KfChatDotNetGui/Views/IdentitySettingsWindow.axaml b/KfChatDotNetGui/Views/IdentitySettingsWindow.axaml deleted file mode 100644 index fe34f51..0000000 --- a/KfChatDotNetGui/Views/IdentitySettingsWindow.axaml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/KfChatDotNetGui/Views/IdentitySettingsWindow.axaml.cs b/KfChatDotNetGui/Views/IdentitySettingsWindow.axaml.cs deleted file mode 100644 index b0e9d16..0000000 --- a/KfChatDotNetGui/Views/IdentitySettingsWindow.axaml.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using System.IO; -using System.Text.Json; -using System.Threading.Tasks; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Interactivity; -using Avalonia.Markup.Xaml; -using Avalonia.Media; -using Avalonia.Threading; -using KfChatDotNetGui.Helpers; -using KfChatDotNetGui.Models; -using KfChatDotNetGui.ViewModels; -using NLog; - -namespace KfChatDotNetGui.Views; - -public partial class IdentitySettingsWindow : Window -{ - private Logger _logger = LogManager.GetCurrentClassLogger(); - public IdentitySettingsWindow() - { - InitializeComponent(); -#if DEBUG - this.AttachDevTools(); -#endif - } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - - private void SaveButton_OnClick(object? sender, RoutedEventArgs e) - { - var saveResult = this.FindControl("SaveResult"); - try - { - var settings = new SettingsModel - { - XfSessionToken = (DataContext as IdentitySettingsWindowViewModel).XfSessionToken, - WsUri = (DataContext as IdentitySettingsWindowViewModel).WsUri, - ReconnectTimeout = (DataContext as IdentitySettingsWindowViewModel).ReconnectTimeout, - AntiDdosPow = (DataContext as IdentitySettingsWindowViewModel).AntiDdosPow, - Username = (DataContext as IdentitySettingsWindowViewModel).Username - }; - var options = new JsonSerializerOptions { WriteIndented = true }; - File.WriteAllText("settings.json", JsonSerializer.Serialize(settings, options)); - } - catch (Exception ex) - { - _logger.Error(ex); - saveResult.Foreground = Brushes.Red; - saveResult.Text = "Failed to save settings due to an error: " + ex.Message; - saveResult.IsVisible = true; - return; - } - saveResult.Foreground = Brushes.Green; - saveResult.Text = "Successfully saved settings!"; - saveResult.IsVisible = true; - } - - private void TestTokenButton_OnClick(object? sender, RoutedEventArgs e) - { - var saveResult = this.FindControl("SaveResult"); - saveResult.Foreground = Brushes.Yellow; - saveResult.Text = "Testing XenForo token"; - saveResult.IsVisible = true; - var kfHost = (DataContext as IdentitySettingsWindowViewModel).WsUri.Host; - Dispatcher.UIThread.Post( - () => TestXfToken((DataContext as IdentitySettingsWindowViewModel).XfSessionToken, kfHost, (DataContext as IdentitySettingsWindowViewModel).AntiDdosPow), - DispatcherPriority.Background); - } - - public void UpdateSaveText(ISolidColorBrush brush, string text) - { - Dispatcher.UIThread.InvokeAsync(() => - { - var saveResult = this.FindControl("SaveResult"); - saveResult.Foreground = brush; - saveResult.Text = text; - if (!saveResult.IsVisible) - { - saveResult.IsVisible = true; - } - }); - } - - public async Task TestXfToken(string xfToken, string kfHost, string? antiDdosPowToken = null) - { - ForumIdentityModel forumIdentity; - try - { - forumIdentity = await ForumIdentity.GetForumIdentity(xfToken, new Uri($"https://{kfHost}/test-chat"), antiDdosPowToken); - } - catch (Exception ex) - { - _logger.Error(ex); - UpdateSaveText(Brushes.Red, "Caught exception while testing token: " + ex.Message); - return; - } - - if (forumIdentity == null) - { - UpdateSaveText(Brushes.Red, "Failed to parse SneedChat page, got a null when deserializing the user info"); - return; - } - - if (forumIdentity.Id == 0) - { - UpdateSaveText(Brushes.Red, "Token is invalid, SneedChat page returned Guest"); - return; - } - - UpdateSaveText(Brushes.Green, "Success! Token belongs to " + forumIdentity.Username); - } -} \ No newline at end of file diff --git a/KfChatDotNetGui/Views/MainWindow.axaml b/KfChatDotNetGui/Views/MainWindow.axaml deleted file mode 100644 index abde377..0000000 --- a/KfChatDotNetGui/Views/MainWindow.axaml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/KfChatDotNetGui/Views/MainWindow.axaml.cs b/KfChatDotNetGui/Views/MainWindow.axaml.cs deleted file mode 100644 index 11390c8..0000000 --- a/KfChatDotNetGui/Views/MainWindow.axaml.cs +++ /dev/null @@ -1,495 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.IO; -using System.Linq; -using System.Net; -using System.Text.Json; -using System.Threading.Tasks; -using Avalonia.Controls; -using Avalonia.Input; -using Avalonia.Interactivity; -using Avalonia.LogicalTree; -using Avalonia.Threading; -using KfChatDotNetGui.Models; -using KfChatDotNetGui.ViewModels; -using KfChatDotNetWsClient; -using KfChatDotNetWsClient.Models; -using KfChatDotNetWsClient.Models.Events; -using KfChatDotNetWsClient.Models.Json; -using NLog; -using Websocket.Client; - -namespace KfChatDotNetGui.Views -{ - public partial class MainWindow : Window - { - private Logger _logger = LogManager.GetCurrentClassLogger(); - // Using an empty config as we can update it later through the UpdateConfig method - // Having this instance created early is handy for wiring up the events - private ChatClient _chatClient = new(new ChatClientConfigModel()); - private SettingsModel _settings = null!; - private int _currentRoom; - private ForumIdentityModel? _forumIdentity = null!; - - public MainWindow() - { - InitializeComponent(); - - _chatClient.OnMessages += OnMessages; - _chatClient.OnUsersJoined += OnUsersJoined; - _chatClient.OnUsersParted += OnUsersParted; - _chatClient.OnWsReconnect += OnOnWsReconnect; - _chatClient.OnWsDisconnection += OnOnWsDisconnection; - _chatClient.OnDeleteMessages += OnDeleteMessages; - _chatClient.OnFailedToJoinRoom += OnFailedToJoinRoom; - } - - private void OnFailedToJoinRoom(object sender, string message) - { - Dispatcher.UIThread.InvokeAsync(() => - { - UpdateStatus($"Failed to join room, room ID {_currentRoom} is probably invalid"); - }); - } - - private void OnDeleteMessages(object sender, List messageIds) - { - Dispatcher.UIThread.InvokeAsync(() => - { - _logger.Info($"Received delete event for following message IDs: {string.Join(',', messageIds)}"); - // Gotta make a copy of all the messages (annoyingly) as we'll be deleting stuff and .NET has a very obvious limitation there - var messages = ((DataContext as MainWindowViewModel)!).Messages.ToList(); - foreach (var message in messages) - { - foreach (var innerMessage in message.Messages.Where(m => messageIds.Contains(m.MessageId))) - { - // Remove the parent message thingy as otherwise it just shows as a blank item - if (message.Messages.Count == 1) - { - _logger.Info("Removing parent message box"); - ((DataContext as MainWindowViewModel)!).Messages.Remove(message); - } - // Go scavenging if there are multiple messages and we don't want to lose the lot - else - { - ((DataContext as MainWindowViewModel)!) - .Messages[((DataContext as MainWindowViewModel)!).Messages.IndexOf(message)].Messages - .Remove(innerMessage); - } - - _logger.Info($"Removed {innerMessage.MessageId}"); - } - } - }); - } - - private void OnOnWsDisconnection(object sender, DisconnectionInfo disconnectionInfo) - { - Dispatcher.UIThread.InvokeAsync(() => - { - UpdateStatus($"Disconnected from SneedChat due to {disconnectionInfo.Type}. Client should automatically attempt to reconnect"); - }); - } - - private void OnOnWsReconnect(object sender, ReconnectionInfo reconnectionInfo) - { - Dispatcher.UIThread.InvokeAsync(() => - { - UpdateStatus("Reconnected to SneedChat. Reason was " + reconnectionInfo.Type); - ((DataContext as MainWindowViewModel)!).Messages.Clear(); - ((DataContext as MainWindowViewModel)!).UserList.Clear(); - }); - - _chatClient.JoinRoom(_currentRoom); - } - - private void IdentitySettings_OnClick(object? sender, RoutedEventArgs e) - { - var context = new IdentitySettingsWindowViewModel(); - if (File.Exists("settings.json")) - { - var settings = JsonSerializer.Deserialize(File.ReadAllText("settings.json")); - context.WsUri = settings!.WsUri; - context.XfSessionToken = settings.XfSessionToken; - context.ReconnectTimeout = settings.ReconnectTimeout; - context.AntiDdosPow = settings.AntiDdosPow; - context.Username = settings.Username; - } - var identitySettingsWindow = new IdentitySettingsWindow - { - DataContext = context - }; - identitySettingsWindow.ShowDialog(this); - identitySettingsWindow.Closed += (o, args) => - { - ReloadSettings(); - }; - } - - private void ExitMenuItem_OnClick(object? sender, RoutedEventArgs e) - { - Environment.Exit(0); - } - - private async Task ConnectToSneedChat() - { - UpdateStatus("Connecting to SneedChat"); - if (!File.Exists("settings.json")) - { - _logger.Error("Cannot find settings.json and therefore unable to connect to SneedChat, notifying the user through the status bar"); - UpdateStatus("Unable to connect as client has not been configured (settings.json missing)"); - return; - } - ReloadSettings(); - UpdateStatus("Testing XenForo token validity"); - ForumIdentityModel? forumIdentity; - if (string.IsNullOrEmpty(_settings.Username)) - { - try - { - forumIdentity = (await Helpers.ForumIdentity.GetForumIdentity(_settings.XfSessionToken, - new Uri($"https://{_settings.WsUri.Host}/test-chat"), _settings.AntiDdosPow)); - } - catch (Exception ex) - { - _logger.Error(ex); - UpdateStatus("Failed to test XenForo token, caught exception " + ex.Message); - return; - } - } - else - { - forumIdentity = new ForumIdentityModel - { - Username = _settings.Username, - Id = int.MaxValue - }; - } - - if (forumIdentity == null) - { - UpdateStatus("Failed to deserialize account info on SneedChat page"); - return; - } - - if (forumIdentity.Id == 0) - { - UpdateStatus("Token failed, SneedChat page returned Guest"); - return; - } - - UpdateStatus("Token works! It belongs to " + forumIdentity.Username); - _forumIdentity = forumIdentity; - ((DataContext as MainWindowViewModel)!).UserId = _forumIdentity.Id; - var roomListControl = this.FindControl("RoomList"); - RoomSettingsModel.RoomList initialRoom; - if (roomListControl!.SelectedItem == null) - { - initialRoom = (DataContext as MainWindowViewModel)?.RoomList.First()!; - } - else - { - initialRoom = (RoomSettingsModel.RoomList) roomListControl.SelectedItem; - } - - _chatClient.UpdateConfig(new ChatClientConfigModel - { - CookieDomain = _settings.WsUri.Host, - ReconnectTimeout = _settings.ReconnectTimeout, - WsUri = _settings.WsUri, - XfSessionToken = _settings.XfSessionToken - }); - - await _chatClient.StartWsClient(); - _chatClient.JoinRoom(initialRoom!.Id); - _currentRoom = initialRoom.Id; - UpdateStatus("Connected!"); - } - - private void OnUsersJoined(object sender, List users, UsersJsonModel jsonPayload) - { - Dispatcher.UIThread.InvokeAsync(() => - { - foreach (var user in users) - { - if (((DataContext as MainWindowViewModel)!).UserList.FirstOrDefault(x => x.Id == user.Id) != null) - { - _logger.Info($"{user.Username} ({user.Id}) is already in the list but has joined again. New tab? Ignoring!"); - continue; - } - ((DataContext as MainWindowViewModel)!).UserList.Add(new MainWindowViewModel.UserListViewModel - { - Id = user.Id, - Name = user.Username - }); - } - UpdateUserTotalStatus(); - }); - } - - private void OnUsersParted(object sender, List userIds) - { - Dispatcher.UIThread.InvokeAsync(() => - { - foreach (var id in userIds) - { - var row = ((DataContext as MainWindowViewModel)!).UserList.FirstOrDefault(x => x.Id == id); - if (row == null) - { - _logger.Info($"A user ({id}) who isn't in the list has parted, ignoring!"); - continue; - } - ((DataContext as MainWindowViewModel)!).UserList.Remove(row); - } - UpdateUserTotalStatus(); - }); - } - - private void OnMessages(object sender, List messages, MessagesJsonModel jsonPayload) - { - Dispatcher.UIThread.InvokeAsync(() => - { - var previousMessage = ((DataContext as MainWindowViewModel)!).Messages.LastOrDefault(); - if (previousMessage == null) - { - previousMessage = new MainWindowViewModel.MessageViewModel {AuthorId = -1}; - } - foreach (var message in messages) - { - _logger.Info("Received message, data payload next"); - if (message.RoomId != _currentRoom) - { - _logger.Info($"Message {message.MessageId} belongs to another room (we're in {_currentRoom}, this one was for {message.RoomId}), ignoring."); - continue; - } - - if (message.MessageEditDate != null) - { - _logger.Info("Received an edit. Going to rewrite message if it already exists, " + - "if it doesn't, nothing will happen as this would occur when loading historically modified messages."); - foreach (var msg in ((DataContext as MainWindowViewModel)!).Messages) - { - foreach (var innerMsg in msg.Messages.Where(m => m.MessageId == message.MessageId)) - { - innerMsg.Message = WebUtility.HtmlDecode(message.MessageRaw); - _logger.Info("Found the original message, text has been overwritten"); - return; - } - } - _logger.Info("Never ended up finding the original message so this was probably historical"); - } - - if (previousMessage.AuthorId == message.Author.Id) - { - _logger.Info("Found a message from the same author, merging"); - var lastMessage = ((DataContext as MainWindowViewModel)!).Messages.Last(); - lastMessage.Messages.Add(new MainWindowViewModel.InnerMessageViewModel - { - Message = WebUtility.HtmlDecode(message.MessageRaw), - MessageId = message.MessageId, - OwnMessage = _forumIdentity.Username == message.Author.Username - }); - continue; - } - - var viewMessage = new MainWindowViewModel.MessageViewModel - { - Author = message.Author.Username, - Messages = new ObservableCollection - { - new() - { - Message = WebUtility.HtmlDecode(message.MessageRaw), - MessageId = message.MessageId, - OwnMessage = _forumIdentity.Username == message.Author.Username - } - }, - PostedAt = message.MessageDate.LocalDateTime, - AuthorId = message.Author.Id - }; - ((DataContext as MainWindowViewModel)!).Messages.Add(viewMessage); - previousMessage = viewMessage; - } - var messagesControl = this.FindControl("ChatMessageList"); - messagesControl!.ScrollIntoView(((DataContext as MainWindowViewModel)!).Messages.Last()); - }); - } - - private void UpdateStatus(string newStatus) - { - (DataContext as MainWindowViewModel)!.Status = newStatus; - } - - private void ConnectMenuItem_OnClick(object? sender, RoutedEventArgs e) - { - Dispatcher.UIThread.Post(() => ConnectToSneedChat(), DispatcherPriority.Background); - } - - private void RoomSettingsMenuItem_OnClick(object? sender, RoutedEventArgs e) - { - var context = new RoomSettingsWindowViewModel(); - if (File.Exists("rooms.json")) - { - var settings = JsonSerializer.Deserialize(File.ReadAllText("rooms.json")); - context.RoomList.Clear(); - foreach (var room in settings.Rooms) - { - context.RoomList.Add(new RoomSettingsModel.RoomList - { - Id = room.Id, - Name = room.Name - }); - } - } - var roomSettingsWindow = new RoomSettingsWindow - { - DataContext = context - }; - roomSettingsWindow.ShowDialog(this); - roomSettingsWindow.Closed += (o, args) => - { - ReloadRoomList(); - }; - } - - private void ReloadSettings() - { - if (!File.Exists("settings.json")) - { - _logger.Error("Was asked to reload the settings but settings.json doesn't exist so I won't bother"); - return; - } - var settings = JsonSerializer.Deserialize(File.ReadAllText("settings.json")); - _settings = settings; - } - - private void ReloadRoomList() - { - if (!File.Exists("rooms.json")) - { - _logger.Error("Was asked to reload the room list but rooms.json doesn't exist so I won't bother"); - return; - } - var rooms = JsonSerializer.Deserialize(File.ReadAllText("rooms.json")); - (DataContext as MainWindowViewModel)!.RoomList = rooms!.Rooms; - } - - private void RoomList_OnSelectionChanged(object? sender, SelectionChangedEventArgs e) - { - if (!_chatClient.IsConnected()) - { - UpdateStatus("Cannot join room as client is not connected"); - return; - } - var roomListControl = this.FindControl("RoomList"); - var room = (RoomSettingsModel.RoomList) roomListControl.SelectedItem!; - // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract - if (room == null) - { - _logger.Info("Got a selection change on room list with a null selected item. This seems to just happen sometimes, ignoring."); - return; - } - UpdateStatus($"Connected! Changing to {room.Name}"); - ((DataContext as MainWindowViewModel)!).Messages.Clear(); - (DataContext as MainWindowViewModel)?.UserList.Clear(); - _chatClient.JoinRoom(room.Id); - _currentRoom = room.Id; - } - - private MainWindowViewModel.MessageViewModel? GetCurrentlySelectedMessage() - { - var messagesControl = this.FindControl("ChatMessageList"); - return messagesControl.SelectedItem as MainWindowViewModel.MessageViewModel; - } - - private void NewChatMessage_OnKeyDown(object? sender, KeyEventArgs e) - { - if (e.Key is not (Key.Enter or Key.Return)) - { - return; - } - TrySendMessageFromTextBox(); - } - - private void NewChatMessageSubmitButton_OnClick(object? sender, RoutedEventArgs e) - { - TrySendMessageFromTextBox(); - } - - private void TrySendMessageFromTextBox() - { - if (!_chatClient.IsConnected()) - { - UpdateStatus("Cannot send a message while disconnected"); - return; - } - var newChatMessage = this.FindControl("NewChatMessage"); - _chatClient.SendMessage(newChatMessage.Text); - newChatMessage.Clear(); - } - - private void UpdateUserTotalStatus() - { - var userCount = (DataContext as MainWindowViewModel).UserList.Count; - UpdateStatus($"Connected! {userCount} users in chat"); - } - - private void MessageEditButton_OnClick(object? sender, RoutedEventArgs e) - { - _logger.Info("Edit button clicked for " + ((e.Source as Button).DataContext as MainWindowViewModel.InnerMessageViewModel).MessageId); - } - - private void CopyButton_OnClick(object? sender, RoutedEventArgs e) - { - var message = (e.Source as Button).DataContext as MainWindowViewModel.InnerMessageViewModel; - if (message == null) - { - _logger.Info("Caught a null when trying to access the inner message model instance for the purposes of copying"); - return; - } - _logger.Info($"Copying {message.MessageId} to clipboard"); - GetTopLevel(e.Source as Button)?.Clipboard?.SetTextAsync(message.Message).Wait(); - } - - private void InnerMessageRow_OnPointerEnter(object? sender, PointerEventArgs e) - { - ((e.Source as ListBoxItem).DataContext as MainWindowViewModel.InnerMessageViewModel).IsHighlighted = true; - } - - private void InnerMessageRow_OnPointerLeave(object? sender, PointerEventArgs e) - { - ((e.Source as ListBoxItem).DataContext as MainWindowViewModel.InnerMessageViewModel).IsHighlighted = false; - } - - private void OuterMessageRow_OnPointerEnter(object? sender, PointerEventArgs e) - { - var children = ((e.Source as ListBox)!).GetLogicalChildren().Cast(); - foreach (var child in children) - { - // Bit of a ghetto hack but it ensures that there's only ever one subscriber - child.PointerEntered -= InnerMessageRow_OnPointerEnter; - child.PointerExited -= InnerMessageRow_OnPointerLeave; - child.PointerEntered += InnerMessageRow_OnPointerEnter; - child.PointerExited += InnerMessageRow_OnPointerLeave; - } - } - - private void MessageDeleteButton_OnClick(object? sender, RoutedEventArgs e) - { - var newChatMessage = this.FindControl("NewChatMessage"); - var messageId = ((e.Source as Button).DataContext as MainWindowViewModel.InnerMessageViewModel).MessageId; - newChatMessage.Text = "/delete " + messageId; - } - - private void AuthorNameButton_OnClick(object? sender, RoutedEventArgs e) - { - var message = (e.Source as Button).DataContext as MainWindowViewModel.MessageViewModel; - var newChatMessage = this.FindControl("NewChatMessage"); - newChatMessage.Text += $"@{message.Author}, "; - newChatMessage.Focus(); - newChatMessage.SelectionStart = newChatMessage.Text.Length; - newChatMessage.SelectionEnd = newChatMessage.Text.Length; - } - } -} \ No newline at end of file diff --git a/KfChatDotNetGui/Views/RoomSettingsWindow.axaml b/KfChatDotNetGui/Views/RoomSettingsWindow.axaml deleted file mode 100644 index 7a11202..0000000 --- a/KfChatDotNetGui/Views/RoomSettingsWindow.axaml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/KfChatDotNetGui/Views/RoomSettingsWindow.axaml.cs b/KfChatDotNetGui/Views/RoomSettingsWindow.axaml.cs deleted file mode 100644 index 4d2dae2..0000000 --- a/KfChatDotNetGui/Views/RoomSettingsWindow.axaml.cs +++ /dev/null @@ -1,176 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Text.Json; -using System.Threading.Tasks; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Interactivity; -using Avalonia.Markup.Xaml; -using Avalonia.Media; -using Avalonia.Threading; -using HtmlAgilityPack; -using KfChatDotNetGui.Models; -using KfChatDotNetGui.ViewModels; -using NLog; - -namespace KfChatDotNetGui.Views; - -public partial class RoomSettingsWindow : Window -{ - private Logger _logger = LogManager.GetCurrentClassLogger(); - public RoomSettingsWindow() - { - InitializeComponent(); -#if DEBUG - this.AttachDevTools(); -#endif - } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - - private void SaveButton_OnClick(object? sender, RoutedEventArgs e) - { - var saveResult = this.FindControl("SaveResult"); - try - { - var roomSettings = new RoomSettingsModel - { - Rooms = new List() - }; - foreach (var room in (DataContext as RoomSettingsWindowViewModel).RoomList) - { - roomSettings.Rooms.Add(new RoomSettingsModel.RoomList - { - Id = room.Id, - Name = room.Name - }); - } - - File.WriteAllText("rooms.json", - JsonSerializer.Serialize(roomSettings, new JsonSerializerOptions { WriteIndented = true })); - } - catch (Exception ex) - { - _logger.Error(e); - saveResult.Foreground = Brushes.Red; - saveResult.Text = "Failed to save rooms due to an error: " + ex.Message; - saveResult.IsVisible = true; - return; - } - saveResult.Foreground = Brushes.Green; - saveResult.Text = "Successfully saved rooms!"; - saveResult.IsVisible = true; - } - - private void AddRowButton_OnClick(object? sender, RoutedEventArgs e) - { - (DataContext as RoomSettingsWindowViewModel).RoomList.Add(new RoomSettingsModel.RoomList()); - } - - private void DeleteSelectedRowsButton_OnClick(object? sender, RoutedEventArgs e) - { - var roomGrid = this.FindControl("RoomGrid"); - var roomList = (DataContext as RoomSettingsWindowViewModel).RoomList.ToList(); - foreach (var room in roomGrid.SelectedItems) - { - roomList.Remove(room as RoomSettingsModel.RoomList); - } - - (DataContext as RoomSettingsWindowViewModel).RoomList = - new ObservableCollection(roomList); - } - - private void AutoDetectButton_OnClick(object? sender, RoutedEventArgs e) - { - var saveResult = this.FindControl("SaveResult"); - saveResult.Foreground = Brushes.Yellow; - saveResult.Text = "Downloading the SneedChat page"; - saveResult.IsVisible = true; - - Dispatcher.UIThread.Post(() => AutoDetectRooms(), DispatcherPriority.Background); - } - - private async Task AutoDetectRooms() - { - var kfDomain = "kiwifarms.net"; - if (File.Exists("settings.json")) - { - var settings = JsonSerializer.Deserialize(await File.ReadAllTextAsync("settings.json")); - kfDomain = settings.WsUri.Host; - } - - Uri sneedChatUri = new Uri($"https://{kfDomain}/test-chat"); - using (var client = new HttpClient(new HttpClientHandler {AutomaticDecompression = DecompressionMethods.All})) - { - client.DefaultRequestHeaders.UserAgent.TryParseAdd("KfChatDotNetGui/1.0"); - client.DefaultRequestHeaders.Accept.Clear(); - client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/html")); - client.DefaultRequestHeaders.AcceptLanguage.Add(new StringWithQualityHeaderValue("en-US")); - - HttpResponseMessage response = await client.GetAsync(sneedChatUri); - if (!response.IsSuccessStatusCode) - { - _logger.Error($"Got HTTP error {response.StatusCode} when fetching {sneedChatUri}"); - Dispatcher.UIThread.InvokeAsync(() => - { - var saveResult = this.FindControl("SaveResult"); - saveResult.Foreground = Brushes.Red; - saveResult.Text = $"Failed to load the SneedChat page due to an HTTP error (Status code {response.StatusCode})"; - saveResult.IsVisible = true; - }); - return; - } - - var html = await response.Content.ReadAsStringAsync(); - var document = new HtmlDocument(); - document.LoadHtml(html); - - var roomList = document.DocumentNode.SelectNodes("//a[@class=\"chat-room\"]"); - if (roomList == null) - { - _logger.Error("Chat room list is null, xpath for it is probably broken"); - Dispatcher.UIThread.InvokeAsync(() => - { - var saveResult = this.FindControl("SaveResult"); - saveResult.Foreground = Brushes.Red; - saveResult.Text = "Failed to parse the SneedChat page, list of rooms was null"; - saveResult.IsVisible = true; - }); - return; - } - - List roomListModel = new List(); - foreach (var element in roomList) - { - roomListModel.Add(new RoomSettingsModel.RoomList - { - Id = element.GetAttributeValue("data-id", 0), - Name = WebUtility.HtmlDecode(element.InnerText) - }); - } - - Dispatcher.UIThread.InvokeAsync(() => - { - (DataContext as RoomSettingsWindowViewModel).RoomList.Clear(); - foreach (var room in roomListModel) - { - (DataContext as RoomSettingsWindowViewModel).RoomList.Add(room); - } - - var saveResult = this.FindControl("SaveResult"); - saveResult.Foreground = Brushes.Green; - saveResult.Text = "Populated list using SneedChat page. Remember to hit Save when you're done!"; - saveResult.IsVisible = true; - }); - } - } -} \ No newline at end of file diff --git a/ThreeXplCliClient/NLog.config b/ThreeXplCliClient/NLog.config deleted file mode 100644 index ab4e010..0000000 --- a/ThreeXplCliClient/NLog.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/ThreeXplCliClient/NLog.xsd b/ThreeXplCliClient/NLog.xsd deleted file mode 100644 index e2b7858..0000000 --- a/ThreeXplCliClient/NLog.xsd +++ /dev/null @@ -1,3483 +0,0 @@ - - - - - - - - - - - - - - - Watch config file for changes and reload automatically. - - - - - Print internal NLog messages to the console. Default value is: false - - - - - Print internal NLog messages to the console error output. Default value is: false - - - - - Write internal NLog messages to the specified file. - - - - - Log level threshold for internal log messages. Default value is: Info. - - - - - Global log level threshold for application log messages. Messages below this level won't be logged. - - - - - Throw an exception when there is an internal error. Default value is: false. Not recommend to set to true in production! - - - - - Throw an exception when there is a configuration error. If not set, determined by throwExceptions. - - - - - Gets or sets a value indicating whether Variables should be kept on configuration reload. Default value is: false. - - - - - Write internal NLog messages to the System.Diagnostics.Trace. Default value is: false. - - - - - Write timestamps for internal NLog messages. Default value is: true. - - - - - Use InvariantCulture as default culture instead of CurrentCulture. Default value is: false. - - - - - Perform message template parsing and formatting of LogEvent messages (true = Always, false = Never, empty = Auto Detect). Default value is: empty. - - - - - - - - - - - - - - Make all targets within this section asynchronous (creates additional threads but the calling thread isn't blocked by any target writes). - - - - - - - - - - - - - - - - - Prefix for targets/layout renderers/filters/conditions loaded from this assembly. - - - - - Load NLog extensions from the specified file (*.dll) - - - - - Load NLog extensions from the specified assembly. Assembly name should be fully qualified. - - - - - - - - - - Filter on the name of the logger. May include wildcard characters ('*' or '?'). - - - - - Comma separated list of levels that this rule matches. - - - - - Minimum level that this rule matches. - - - - - Maximum level that this rule matches. - - - - - Level that this rule matches. - - - - - Comma separated list of target names. - - - - - Ignore further rules if this one matches. - - - - - Enable this rule. Note: disabled rules aren't available from the API. - - - - - Rule identifier to allow rule lookup with Configuration.FindRuleByName and Configuration.RemoveRuleByName. - - - - - Loggers matching will be restricted to specified minimum level for following rules. - - - - - - - - - - - - - - - Default action if none of the filters match. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the file to be included. You could use * wildcard. The name is relative to the name of the current config file. - - - - - Ignore any errors in the include file. - - - - - - - - Variable value. Note, the 'value' attribute has precedence over this one. - - - - - - Variable name. - - - - - Variable value. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Action to be taken when the lazy writer thread request queue count exceeds the set limit. - - - - - Limit on the number of requests in the lazy writer thread request queue. - - - - - Number of log events that should be processed in a batch by the lazy writer thread. - - - - - Whether to use the locking queue, instead of a lock-free concurrent queue - - - - - Number of batches of P:NLog.Targets.Wrappers.AsyncTargetWrapper.BatchSize to write before yielding into P:NLog.Targets.Wrappers.AsyncTargetWrapper.TimeToSleepBetweenBatches - - - - - Time in milliseconds to sleep between batches. (1 or less means trigger on new activity) - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Delay the flush until the LogEvent has been confirmed as written - - - - - Condition expression. Log events who meet this condition will cause a flush on the wrapped target. - - - - - Only flush when LogEvent matches condition. Ignore explicit-flush, config-reload-flush and shutdown-flush - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Number of log events to be buffered. - - - - - Action to take if the buffer overflows. - - - - - Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes. - - - - - Indicates whether to use sliding timeout. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Separator for T:NLog.ScopeContext operation-states-stack. - - - - - Stack separator for log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Renderer for log4j:event logger-xml-attribute (Default ${logger}) - - - - - Whether to include the contents of the T:NLog.ScopeContext properties-dictionary. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Indicates whether to include source info (file name and line number) in the information sent over the network. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Option to include all properties from the log events - - - - - Indicates whether to include call site (class and method name) in the information sent over the network. - - - - - AppInfo field. By default it's the friendly name of the current AppDomain. - - - - - Instance of T:NLog.Layouts.Log4JXmlEventLayout that is used to format log messages. - - - - - Indicates whether to include NLog-specific extensions to log4j schema. - - - - - Action that should be taken, when more connections than P:NLog.Targets.NetworkTarget.MaxConnections. - - - - - SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - - - - - Action that should be taken, when more pending messages than P:NLog.Targets.NetworkTarget.MaxQueueSize. - - - - - Action that should be taken if the message is larger than P:NLog.Targets.NetworkTarget.MaxMessageSize - - - - - Maximum queue size for a single connection. Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Network address. - - - - - Indicates whether to keep connection open whenever possible. - - - - - The number of seconds a connection will remain idle before the first keep-alive probe is sent - - - - - Size of the connection cache (number of connections which are kept alive). Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Maximum simultaneous connections. Requires P:NLog.Targets.NetworkTarget.KeepConnection = false - - - - - Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - - - - - Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - - - - - Maximum message size in bytes. On limit breach then P:NLog.Targets.NetworkTarget.OnOverflow action is activated. - - - - - Encoding to be used. - - - - - End of line value if a newline is appended at the end of log message P:NLog.Targets.NetworkTarget.NewLine. - - - - - Indicates whether to append newline at the end of log message. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Viewer parameter name. - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Whether an attribute with empty value should be included in the output - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether to auto-check if the console is available. - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) - - - - - Enables output using ANSI Color Codes - - - - - The encoding for writing messages to the T:System.Console. - - - - - Indicates whether to send the log messages to the standard error instead of the standard output. - - - - - Indicates whether to auto-flush after M:System.Console.WriteLine - - - - - Indicates whether to auto-check if the console has been redirected to file - Disables coloring logic when System.Console.IsOutputRedirected = true - - - - - Indicates whether to use default row highlighting rules. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Background color. - - - - - Condition that must be met in order to set the specified foreground and background color. - - - - - Foreground color. - - - - - - - - - - - - - - - - - Background color. - - - - - Compile the P:NLog.Targets.ConsoleWordHighlightingRule.Regex? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used. - - - - - Condition that must be met before scanning the row for highlight of words - - - - - Foreground color. - - - - - Indicates whether to ignore case when comparing texts. - - - - - Regular expression to be matched. You must specify either text or regex. - - - - - Text to be matched. You must specify either text or regex. - - - - - Indicates whether to match whole words only. - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether to auto-flush after M:System.Console.WriteLine - - - - - Indicates whether to auto-check if the console is available - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) - - - - - The encoding for writing messages to the T:System.Console. - - - - - Indicates whether to send the log messages to the standard error instead of the standard output. - - - - - Whether to activate internal buffering to allow batch writing, instead of using M:System.Console.WriteLine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string. - - - - - Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string. - - - - - Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string. - - - - - Name of the connection string (as specified in <connectionStrings> configuration section. - - - - - Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string. - - - - - Indicates whether to keep the database connection open between the log events. - - - - - Name of the database provider. - - - - - Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase. - - - - - Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used. - - - - - Configures isolated transaction batch writing. If supported by the database, then it will improve insert performance. - - - - - Text of the SQL command to be run on each log level. - - - - - Type of the SQL command to be run on each log level. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Convert format of the property value - - - - - Culture used for parsing property string-value for type-conversion - - - - - Value to assign on the object-property - - - - - Name for the object-property - - - - - Type of the object-property - - - - - - - - - - - - - - Type of the command. - - - - - Connection string to run the command against. If not provided, connection string from the target is used. - - - - - Indicates whether to ignore failures. - - - - - Command text. - - - - - - - - - - - - - - - - - - - - Database parameter name. - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Database parameter DbType. - - - - - Database parameter size. - - - - - Database parameter precision. - - - - - Database parameter scale. - - - - - Type of the parameter. - - - - - Fallback value when result value is not available - - - - - Convert format of the database parameter value. - - - - - Culture used for parsing parameter string-value for type-conversion - - - - - Whether empty value should translate into DbNull. Requires database column to allow NULL values. - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Layout that renders event Category. - - - - - Optional entry type. When not set, or when not convertible to T:System.Diagnostics.EventLogEntryType then determined by T:NLog.LogLevel - - - - - Layout that renders event ID. - - - - - Name of the Event Log to write to. This can be System, Application or any user-defined name. - - - - - Name of the machine on which Event Log service is running. - - - - - Maximum Event log size in kilobytes. - - - - - Message length limit to write to the Event Log. - - - - - Value to be used as the event Source. - - - - - Action to take if the message is larger than the P:NLog.Targets.EventLogTarget.MaxMessageLength option. - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Indicates whether to return to the first target after any successful write. - - - - - Whether to enable batching, but fallback will be handled individually - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Name of the file to write to. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether the footer should be written only when the file is archived. - - - - - Maximum number of archive files that should be kept. - - - - - Maximum days of archive files that should be kept. - - - - - Value of the file size threshold to archive old log file on startup. - - - - - Indicates whether to archive old log file on startup. - - - - - Indicates whether to compress archive files into the zip archive format. - - - - - Name of the file to be used for an archive. - - - - - Is the P:NLog.Targets.FileTarget.ArchiveFileName an absolute or relative path? - - - - - Indicates whether to automatically archive log files every time the specified time passes. - - - - - Value specifying the date format to use when archiving files. - - - - - Size in bytes above which log files will be automatically archived. - - - - - Way file archives are numbered. - - - - - Indicates whether to create directories if they do not exist. - - - - - Indicates whether file creation calls should be synchronized by a system global mutex. - - - - - Gets or set a value indicating whether a managed file stream is forced, instead of using the native implementation. - - - - - Is the P:NLog.Targets.FileTarget.FileName an absolute or relative path? - - - - - File attributes (Windows only). - - - - - Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong. - - - - - Indicates whether to write BOM (byte order mark) in created files. Defaults to true for UTF-16 and UTF-32 - - - - - Indicates whether to enable log file(s) to be deleted. - - - - - Indicates whether to delete old log file on startup. - - - - - File encoding. - - - - - Indicates whether to replace file contents on each write instead of appending log message at the end. - - - - - Line ending mode. - - - - - Number of times the write is appended on the file before NLog discards the log message. - - - - - Delay in milliseconds to wait before attempting to write to the file again. - - - - - Maximum number of seconds before open files are flushed. Zero or negative means disabled. - - - - - Maximum number of seconds that files are kept open. Zero or negative means disabled. - - - - - Indicates whether concurrent writes to the log file by multiple processes on different network hosts. - - - - - Log file buffer size in bytes. - - - - - Indicates whether to automatically flush the file buffers after each log message. - - - - - Indicates whether to keep log file open instead of opening and closing it on each logging event. - - - - - Indicates whether concurrent writes to the log file by multiple processes on the same host. - - - - - Whether or not this target should just discard all data that its asked to write. Mostly used for when testing NLog Stack except final write - - - - - Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Condition expression. Log events who meet this condition will be forwarded to the wrapped target. - - - - - - - - - - - - - - - Name of the target. - - - - - Identifier to perform group-by - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Windows domain name to change context to. - - - - - Required impersonation level. - - - - - Type of the logon provider. - - - - - Logon Type. - - - - - User account password. - - - - - Indicates whether to revert to the credentials of the process instead of impersonating another user. - - - - - Username to change context to. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Interval in which messages will be written up to the P:NLog.Targets.Wrappers.LimitingTargetWrapper.MessageLimit number of messages. - - - - - Maximum allowed number of messages written per P:NLog.Targets.Wrappers.LimitingTargetWrapper.Interval. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether NewLine characters in the body should be replaced with tags. - - - - - Priority used for sending mails. - - - - - Encoding to be used for sending e-mail. - - - - - BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - Indicates whether to add new lines between log entries. - - - - - Indicates whether to send message as HTML instead of plain text. - - - - - Sender's email address (e.g. joe@domain.com). - - - - - Mail message body (repeated for each log message send in one mail). - - - - - Mail subject. - - - - - Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - Specifies how outgoing email messages will be handled. - - - - - SMTP Server to be used for sending. - - - - - SMTP Authentication mode. - - - - - Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic"). - - - - - Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic"). - - - - - Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server. - - - - - Port number that SMTP Server is listening on. - - - - - Indicates whether the default Settings from System.Net.MailSettings should be used. - - - - - Folder where applications save mail messages to be processed by the local SMTP server. - - - - - Indicates the SMTP client timeout. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Max number of items to have in memory - - - - - - - - - - - - - - - - - Name of the target. - - - - - Class name. - - - - - Method name. The method must be public and static. Use the AssemblyQualifiedName , https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx e.g. - - - - - - - - - - - - - - - Name of the parameter. - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Fallback value when result value is not available - - - - - Type of the parameter. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - - - - - Action that should be taken, when more pending messages than P:NLog.Targets.NetworkTarget.MaxQueueSize. - - - - - Action that should be taken if the message is larger than P:NLog.Targets.NetworkTarget.MaxMessageSize - - - - - Maximum queue size for a single connection. Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Action that should be taken, when more connections than P:NLog.Targets.NetworkTarget.MaxConnections. - - - - - Indicates whether to keep connection open whenever possible. - - - - - The number of seconds a connection will remain idle before the first keep-alive probe is sent - - - - - Size of the connection cache (number of connections which are kept alive). Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Network address. - - - - - Maximum simultaneous connections. Requires P:NLog.Targets.NetworkTarget.KeepConnection = false - - - - - Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - - - - - Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - - - - - Maximum message size in bytes. On limit breach then P:NLog.Targets.NetworkTarget.OnOverflow action is activated. - - - - - Encoding to be used. - - - - - End of line value if a newline is appended at the end of log message P:NLog.Targets.NetworkTarget.NewLine. - - - - - Indicates whether to append newline at the end of log message. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Separator for T:NLog.ScopeContext operation-states-stack. - - - - - Stack separator for log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Renderer for log4j:event logger-xml-attribute (Default ${logger}) - - - - - Whether to include the contents of the T:NLog.ScopeContext properties-dictionary. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Indicates whether to include source info (file name and line number) in the information sent over the network. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Option to include all properties from the log events - - - - - Indicates whether to include call site (class and method name) in the information sent over the network. - - - - - AppInfo field. By default it's the friendly name of the current AppDomain. - - - - - Instance of T:NLog.Layouts.Log4JXmlEventLayout that is used to format log messages. - - - - - Indicates whether to include NLog-specific extensions to log4j schema. - - - - - Action that should be taken, when more connections than P:NLog.Targets.NetworkTarget.MaxConnections. - - - - - SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - - - - - Action that should be taken, when more pending messages than P:NLog.Targets.NetworkTarget.MaxQueueSize. - - - - - Action that should be taken if the message is larger than P:NLog.Targets.NetworkTarget.MaxMessageSize - - - - - Maximum queue size for a single connection. Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Network address. - - - - - Indicates whether to keep connection open whenever possible. - - - - - The number of seconds a connection will remain idle before the first keep-alive probe is sent - - - - - Size of the connection cache (number of connections which are kept alive). Requires P:NLog.Targets.NetworkTarget.KeepConnection = true - - - - - Maximum simultaneous connections. Requires P:NLog.Targets.NetworkTarget.KeepConnection = false - - - - - Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - - - - - Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - - - - - Maximum message size in bytes. On limit breach then P:NLog.Targets.NetworkTarget.OnOverflow action is activated. - - - - - Encoding to be used. - - - - - End of line value if a newline is appended at the end of log message P:NLog.Targets.NetworkTarget.NewLine. - - - - - Indicates whether to append newline at the end of log message. - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Indicates whether to perform layout calculation. - - - - - - - - - - - - - - - - Name of the target. - - - - - Default filter to be applied when no specific rule matches. - - - - - - - - - - - - - Condition to be tested. - - - - - Resulting filter to be applied when the condition matches. - - - - - - - - - - - - Name of the target. - - - - - - - - - - - - - - - Name of the target. - - - - - Number of times to repeat each log message. - - - - - - - - - - - - - - - - - Name of the target. - - - - - Whether to enable batching, and only apply single delay when a whole batch fails - - - - - Number of retries that should be attempted on the wrapped target in case of a failure. - - - - - Time to wait between retries in milliseconds. - - - - - - - - - - - - - - Name of the target. - - - - - - - - - - - - - - Name of the target. - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Forward F:NLog.LogLevel.Fatal to M:System.Diagnostics.Trace.Fail(System.String) (Instead of M:System.Diagnostics.Trace.TraceError(System.String)) - - - - - Force use M:System.Diagnostics.Trace.WriteLine(System.String) independent of T:NLog.LogLevel - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Indicates whether to pre-authenticate the HttpWebRequest (Requires 'Authorization' in P:NLog.Targets.WebServiceTarget.Headers parameters) - - - - - Value whether escaping be done according to Rfc3986 (Supports Internationalized Resource Identifiers - IRIs) - - - - - Value whether escaping be done according to the old NLog style (Very non-standard) - - - - - Value of the User-agent HTTP header. - - - - - Web service URL. - - - - - Proxy configuration when calling web service - - - - - Custom proxy address, include port separated by a colon - - - - - Protocol to be used when calling web service. - - - - - Web service namespace. Only used with Soap. - - - - - Web service method name. Only used with Soap. - - - - - Should we include the BOM (Byte-order-mark) for UTF? Influences the P:NLog.Targets.WebServiceTarget.Encoding property. This will only work for UTF-8. - - - - - Encoding. - - - - - Name of the root XML element, if POST of XML document chosen. If so, this property must not be null. (see P:NLog.Targets.WebServiceTarget.Protocol and F:NLog.Targets.WebServiceProtocol.XmlPost). - - - - - (optional) root namespace of the XML document, if POST of XML document chosen. (see P:NLog.Targets.WebServiceTarget.Protocol and F:NLog.Targets.WebServiceProtocol.XmlPost). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom'). - - - - - Column delimiter. - - - - - Footer layout. - - - - - Header layout. - - - - - Body layout (can be repeated multiple times). - - - - - Quote Character. - - - - - Quoting mode. - - - - - Indicates whether CVS should include header. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the column. - - - - - Layout of the column. - - - - - Override of Quoting mode - - - - - - - - - - - - - - Option to render the empty object value {} - - - - - Option to suppress the extra spaces in the output json - - - - - - - - - - - - - - - - - - - - - - - Option to include all properties from the log event (as JSON) - - - - - Indicates whether to include contents of the T:NLog.GlobalDiagnosticsContext dictionary. - - - - - Whether to include the contents of the T:NLog.ScopeContext dictionary. - - - - - Should forward slashes be escaped? If true, / will be converted to \/ - - - - - Option to exclude null/empty properties from the log event (as JSON) - - - - - List of property names to exclude when P:NLog.Layouts.JsonLayout.IncludeAllProperties is true - - - - - How far should the JSON serializer follow object references before backing off - - - - - Option to render the empty object value {} - - - - - Option to suppress the extra spaces in the output json - - - - - - - - - - - - - - - - - - - Name of the attribute. - - - - - Layout that will be rendered as the attribute's value. - - - - - Fallback value when result value is not available - - - - - Determines whether or not this attribute will be Json encoded. - - - - - Should forward slashes be escaped? If true, / will be converted to \/ - - - - - Indicates whether to escape non-ascii characters - - - - - Whether an attribute with empty value should be included in the output - - - - - Result value type, for conversion of layout rendering output - - - - - - - - - - - - - - Footer layout. - - - - - Header layout. - - - - - Body layout (can be repeated multiple times). - - - - - - - - - - - - - - - - - - - - - - - Option to include all properties from the log events - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Whether to include log4j:NDC in output from T:NLog.ScopeContext nested context. - - - - - Whether to include the contents of the T:NLog.ScopeContext properties-dictionary. - - - - - AppInfo field. By default it's the friendly name of the current AppDomain. - - - - - Indicates whether to include call site (class and method name) in the information sent over the network. - - - - - Indicates whether to include source info (file name and line number) in the information sent over the network. - - - - - Log4j:event logger-xml-attribute (Default ${logger}) - - - - - Whether the log4j:throwable xml-element should be written as CDATA - - - - - - - - - - - - - - Layout text. - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the root XML element - - - - - Value inside the root XML element - - - - - Whether to include the contents of the T:NLog.ScopeContext dictionary. - - - - - Determines whether or not this attribute will be Xml encoded. - - - - - List of property names to exclude when P:NLog.Layouts.XmlElementBase.IncludeAllProperties is true - - - - - Whether a ElementValue with empty value should be included in the output - - - - - Auto indent and create new lines - - - - - How far should the XML serializer follow object references before backing off - - - - - XML element name to use for rendering IList-collections items - - - - - XML attribute name to use when rendering property-key When null (or empty) then key-attribute is not included - - - - - XML element name to use when rendering properties - - - - - XML attribute name to use when rendering property-value When null (or empty) then value-attribute is not included and value is formatted as XML-element-value - - - - - Option to include all properties from the log event (as XML) - - - - - - - - - - - - - - - - - Name of the attribute. - - - - - Layout that will be rendered as the attribute's value. - - - - - Fallback value when result value is not available - - - - - Determines whether or not this attribute will be Xml encoded. - - - - - Whether an attribute with empty value should be included in the output - - - - - Result value type, for conversion of layout rendering output - - - - - - - - - - - - - - - - - - - - - - - - Name of the element - - - - - Whether to include the contents of the T:NLog.ScopeContext dictionary. - - - - - Value inside the element - - - - - Determines whether or not this attribute will be Xml encoded. - - - - - List of property names to exclude when P:NLog.Layouts.XmlElementBase.IncludeAllProperties is true - - - - - Whether a ElementValue with empty value should be included in the output - - - - - Auto indent and create new lines - - - - - How far should the XML serializer follow object references before backing off - - - - - XML element name to use for rendering IList-collections items - - - - - XML attribute name to use when rendering property-key When null (or empty) then key-attribute is not included - - - - - XML element name to use when rendering properties - - - - - XML attribute name to use when rendering property-value When null (or empty) then value-attribute is not included and value is formatted as XML-element-value - - - - - Option to include all properties from the log event (as XML) - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Condition expression. - - - - - - - - - - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - Substring to be matched. - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - String to compare the layout to. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - Substring to be matched. - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - String to compare the layout to. - - - - - Indicates whether to ignore case when comparing strings. - - - - - Layout to be used to filter log messages. - - - - - - - - - - - - - - - - - - - - - - - Action to be taken when filter matches. - - - - - Append FilterCount to the P:NLog.LogEventInfo.Message when an event is no longer filtered - - - - - Insert FilterCount value into P:NLog.LogEventInfo.Properties when an event is no longer filtered - - - - - Applies the configured action to the initial logevent that starts the timeout period. Used to configure that it should ignore all events until timeout. - - - - - Layout to be used to filter log messages. - - - - - Max length of filter values, will truncate if above limit - - - - - How long before a filter expires, and logging is accepted again - - - - - Default number of unique filter values to expect, will automatically increase if needed - - - - - Max number of unique filter values to expect simultaneously - - - - - Default buffer size for the internal buffers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ThreeXplCliClient/Program.cs b/ThreeXplCliClient/Program.cs deleted file mode 100644 index 2b773c5..0000000 --- a/ThreeXplCliClient/Program.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Net; -using System.Text; -using Spectre.Console; -using ThreeXplWsClient.Events; - -namespace ThreeXplCliClient -{ - public class Program - { - static async Task Main(string[] args) - { - Console.OutputEncoding = Encoding.UTF8; - AnsiConsole.MarkupLine("[green]3xpl test client started[/]"); - var cliClient = new ThreeXplClient(); - await cliClient.Start(); - } - } -} \ No newline at end of file diff --git a/ThreeXplCliClient/ThreeXplCliClient.csproj b/ThreeXplCliClient/ThreeXplCliClient.csproj deleted file mode 100644 index eff5cb2..0000000 --- a/ThreeXplCliClient/ThreeXplCliClient.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - - - - - - - - - - - - - Always - - - - diff --git a/ThreeXplCliClient/ThreeXplClient.cs b/ThreeXplCliClient/ThreeXplClient.cs deleted file mode 100644 index ab352df..0000000 --- a/ThreeXplCliClient/ThreeXplClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Text.Json; -using Spectre.Console; -using ThreeXplWsClient.Events; - -namespace ThreeXplCliClient; - -public class ThreeXplClient -{ - private List _addresses = - [ - "0x3C736854AC7Cf8f24070aa3ceC72B8471d1f9781", - "0x2d709a3c76a28b45594d6a54be72d4ab0203c546" - ]; - public async Task Start() - { - var client = new ThreeXplWsClient.ThreeXplWsClient(); - client.OnThreeXplPush += OnThreeXplEvent; - await client.StartWsClient(); - while (true) - { - var prompt = AnsiConsole.Ask("Channel: "); - client.SendSubscribeRequest(prompt); - AnsiConsole.MarkupLine($"[green]Subbed at {DateTime.Now:O}[/]"); - } - } - - private void OnThreeXplEvent(object sender, ThreeXplPushModel e, int connectionId) - { - //AnsiConsole.MarkupLine("[blue]Received event from 3xpl[/]"); - foreach (var txn in e.Pub.Data.Data) - { - if (txn.Address == null) return; - if (_addresses.Contains(txn.Address)) - { - AnsiConsole.MarkupLine($"[green]Saw txn I'm interested in: {txn.Address}, effect {txn.Effect}, currency {txn.Currency}[/]"); - continue; - } - //AnsiConsole.MarkupLine($"[gray]Saw txn I'm not interested in: {txn.Address}, effect {txn.Effect}, currency {txn.Currency}[/]"); - } - } -} \ No newline at end of file diff --git a/ThreeXplWsClient/Converters.cs b/ThreeXplWsClient/Converters.cs deleted file mode 100644 index 6ef9a39..0000000 --- a/ThreeXplWsClient/Converters.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace ThreeXplWsClient; - -public class ThreeXplDateTimeConverter : JsonConverter -{ - // 2025-05-05 23:53:08 - private const string Format = "yyyy-MM-dd HH:mm:ss"; - - public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var input = reader.GetString(); - if (input == null) - { - throw new NullReferenceException("Tried to convert a string to DateTime that was null"); - } - return DateTime.ParseExact(input, Format, null); - } - public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) - { - writer.WriteStringValue(value.ToString(Format)); - } -} \ No newline at end of file diff --git a/ThreeXplWsClient/Events/EventHandlers.cs b/ThreeXplWsClient/Events/EventHandlers.cs deleted file mode 100644 index a360196..0000000 --- a/ThreeXplWsClient/Events/EventHandlers.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Websocket.Client; - -namespace ThreeXplWsClient.Events; - -public class EventHandlers -{ - public delegate void OnThreeXplPing(object sender, int connectionId); - - public delegate void OnThreeXplPush(object sender, ThreeXplPushModel e, int connectionId); - - public delegate void OnWsDisconnectionEventHandler(object sender, DisconnectionInfo e, int connectionId); - - public delegate void OnWsReconnectEventHandler(object sender, ReconnectionInfo e, int connectionId); - - public delegate void OnWsMessageReceivedEventHandler(object sender, ResponseMessage e, int connectionId); - - public delegate void OnThreeXplConnect(object sender, ThreeXplConnectDataModel e, int connectionId); - - public delegate void OnThreeXplError(object sender, ThreeXplErrorModel e, int connectionId); - - public delegate void OnThreeXplSubscribe(object sender, ThreeXplSubscribeModel e, int connectionId); -} \ No newline at end of file diff --git a/ThreeXplWsClient/Events/EventModels.cs b/ThreeXplWsClient/Events/EventModels.cs deleted file mode 100644 index e12dc00..0000000 --- a/ThreeXplWsClient/Events/EventModels.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System.Text.Json.Serialization; - -namespace ThreeXplWsClient.Events; - -public class BaseThreeXplPacketModel -{ - [JsonPropertyName("connect")] - public ThreeXplConnectDataModel? Connect { get; set; } - [JsonPropertyName("id")] - public int? Id { get; set; } - [JsonPropertyName("error")] - public ThreeXplErrorModel? Error { get; set; } - [JsonPropertyName("subscribe")] - public ThreeXplSubscribeModel? Subscribe { get; set; } - [JsonPropertyName("push")] - public ThreeXplPushModel? Push { get; set; } - -} - -public class ThreeXplDataModel -{ - [JsonPropertyName("blockchain")] - public string? Blockchain { get; set; } - [JsonPropertyName("module")] - public string? Module { get; set; } - [JsonPropertyName("block")] - public int? Block { get; set; } - [JsonPropertyName("transaction")] - public string? Transaction { get; set; } - [JsonPropertyName("sort_key")] - public int? SortKey { get; set; } - [JsonPropertyName("time")] - [JsonConverter(typeof(ThreeXplDateTimeConverter))] - public DateTime Time { get; set; } - [JsonPropertyName("currency")] - public string? Currency { get; set; } - [JsonPropertyName("effect")] - public string? Effect { get; set; } - [JsonPropertyName("failed")] - public bool? Failed { get; set; } - [JsonPropertyName("extra")] - public object? Extra { get; set; } - [JsonPropertyName("extra_indexed")] - public object? ExtraIndexed { get; set; } - [JsonPropertyName("address")] - public string? Address { get; set; } -} - -public class ThreeXplContextModel -{ - // "time":"0.21778600 1718465848" - [JsonPropertyName("time")] - public string? Time { get; set; } -} - -public class ThreeXplConnectDataModel -{ - [JsonPropertyName("client")] - public string? Client { get; set; } - [JsonPropertyName("version")] - public string? Version { get; set; } - [JsonPropertyName("ping")] - public int? Ping { get; set; } - [JsonPropertyName("pong")] - public bool? Pong { get; set; } -} - -public class ThreeXplErrorModel -{ - [JsonPropertyName("code")] - public int? Code { get; set; } - [JsonPropertyName("Message")] - public string? Message { get; set; } - [JsonPropertyName("temporary")] - public bool? Temporary { get; set; } -} - -public class ThreeXplSubscribeModel -{ - [JsonPropertyName("recoverable")] - public bool? Recoverable { get; set; } - [JsonPropertyName("epoch")] - public string? Epoch { get; set; } - [JsonPropertyName("positioned")] - public bool? Positioned { get; set; } -} - -public class ThreeXplPushModel -{ - [JsonPropertyName("channel")] - public required string Channel { get; set; } - [JsonPropertyName("pub")] - public required ThreeXplPushPubModel Pub { get; set; } - [JsonPropertyName("offset")] - public int? Offset { get; set; } - -} - -public class ThreeXplPushPubModel -{ - [JsonPropertyName("data")] - public required ThreeXplPushDataModel Data { get; set; } -} - -public class ThreeXplPushDataModel -{ - [JsonPropertyName("data")] - public required List Data { get; set; } - [JsonPropertyName("context")] - public required ThreeXplContextModel Context { get; set; } -} \ No newline at end of file diff --git a/ThreeXplWsClient/Models/JwtResponseModels.cs b/ThreeXplWsClient/Models/JwtResponseModels.cs deleted file mode 100644 index 5b61075..0000000 --- a/ThreeXplWsClient/Models/JwtResponseModels.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Text.Json.Serialization; - -namespace ThreeXplWsClient.Models; - -public class GetWebsocketTokenModel -{ - [JsonPropertyName("data")] - public required string Data { get; set; } - [JsonPropertyName("context")] - public GetWebSocketTokenContextModel? Context { get; set; } -} - -public class GetWebSocketTokenContextModel -{ - [JsonPropertyName("code")] - public int? Code { get; set; } -} \ No newline at end of file diff --git a/ThreeXplWsClient/Models/RequestModels.cs b/ThreeXplWsClient/Models/RequestModels.cs deleted file mode 100644 index 11691f1..0000000 --- a/ThreeXplWsClient/Models/RequestModels.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Text.Json.Serialization; - -namespace ThreeXplWsClient.Models; - -public class ConnectRequestModel -{ - [JsonPropertyName("connect")] - public required ConnectRequestTokenModel Connect { get; set; } - [JsonPropertyName("id")] - public int Id { get; set; } = 1; -} - -public class ConnectRequestTokenModel -{ - [JsonPropertyName("token")] - public required string Token { get; set; } -} - -public class SubscribeRequestModel -{ - [JsonPropertyName("subscribe")] - public required SubscribeRequestChannelModel Subscribe { get; set; } - [JsonPropertyName("id")] - public int Id { get; set; } = 2; -} - -public class SubscribeRequestChannelModel -{ - [JsonPropertyName("channel")] - public required string Channel { get; set; } -} \ No newline at end of file diff --git a/ThreeXplWsClient/ThreeXplWsClient.cs b/ThreeXplWsClient/ThreeXplWsClient.cs deleted file mode 100644 index 723adca..0000000 --- a/ThreeXplWsClient/ThreeXplWsClient.cs +++ /dev/null @@ -1,236 +0,0 @@ -using System.Net; -using System.Net.Http.Json; -using System.Net.WebSockets; -using System.Text.Json; -using NLog; -using ThreeXplWsClient.Events; -using ThreeXplWsClient.Models; -using Websocket.Client; - -namespace ThreeXplWsClient; - -public class ThreeXplWsClient -{ - public event EventHandlers.OnWsMessageReceivedEventHandler OnWsMessageReceived; - public event EventHandlers.OnWsDisconnectionEventHandler OnWsDisconnection; - public event EventHandlers.OnWsReconnectEventHandler OnWsReconnect; - public event EventHandlers.OnThreeXplPing OnThreeXplPing; - public event EventHandlers.OnThreeXplPush OnThreeXplPush; - public event EventHandlers.OnThreeXplConnect OnThreeXplConnect; - public event EventHandlers.OnThreeXplError OnThreeXplError; - public event EventHandlers.OnThreeXplSubscribe OnThreeXplSubscribe; - - private WebsocketClient _wsClient; - private readonly Logger _logger = LogManager.GetCurrentClassLogger(); - private string? _wsJwt; - private DateTime _wsJwtLastRetrieved = DateTime.Now; - private int _wsJwtValidityPeriodSeconds; - private string? _proxy; - private int _reconnectTimeout; - private Uri _wsUri; - // Basically they have a limit of 10 subscriptions per connection and I have more than 10 addresses to monitor, so - // I give each connection an ID number as that way I know what addresses need to be resubscribed in the event of a - // connection drop. This ID is included with every event fired and set when the class is constructed. - private int _connectionId; - - /// - /// Client for the 3xpl WebSocket API - /// - /// URI for the websocket API, published at https://3xpl.com/data/websocket-api - /// Web proxy to use for the WebSocket connection - /// Reconnect timeout, defaults to 30 seconds as 3xpl tells us to expect a ping every 25 seconds - /// How long the JWT is valid for. Set to int.MaxValue if you've manually provided a non-expiring token - /// Manually provide a JWT if you have access to create your own - /// ID that can be used to differentiate multiple 3xpl connections - public ThreeXplWsClient(string threeXplWsUri = "wss://stream.3xpl.net", string? proxy = null, - int reconnectTimeout = 30, int jwtValidityPeriodSeconds = 600, string? jwtApiToken = null, int connectionId = 0) - { - _wsUri = new Uri(threeXplWsUri); - _proxy = proxy; - _reconnectTimeout = reconnectTimeout; - _wsJwtValidityPeriodSeconds = jwtValidityPeriodSeconds; - _wsJwt = jwtApiToken; - _connectionId = connectionId; - } - - private async Task RefreshApiToken() - { - _logger.Debug("Refreshing the API token"); - if (_wsJwtValidityPeriodSeconds == int.MaxValue) - { - _logger.Debug($"Token is non expiring as it is set to {int.MaxValue}"); - return; - } - if (_wsJwt != null && _wsJwtLastRetrieved.AddSeconds(_wsJwtValidityPeriodSeconds) >= DateTime.Now) - { - _logger.Debug( - $"Token has not yet expired. Its expiration date is {_wsJwtLastRetrieved.AddSeconds(_wsJwtValidityPeriodSeconds):yyyy-MM-dd HH:mm:ss}"); - return; - } - - var handler = new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }; - if (_proxy != null) - { - handler.Proxy = new WebProxy(_proxy); - handler.UseProxy = true; - } - - using var client = new HttpClient(handler); - var token = await client.GetFromJsonAsync("https://3xpl.com/get-websockets-token"); - if (token == null) - { - _logger.Error("Caught a null when retrieving a WebSocket JWT from 3xpl"); - throw new InvalidOperationException("Caught a null when retrieving a WebSocket JWT from 3xp"); - } - - _wsJwt = token.Data; - _wsJwtLastRetrieved = DateTime.Now; - } - - public async Task StartWsClient() - { - _logger.Debug("StartWsClient() called, creating client"); - await CreateWsClient(); - } - - private async Task CreateWsClient() - { - var factory = new Func(() => - { - var clientWs = new ClientWebSocket(); - if (_proxy == null) return clientWs; - clientWs.Options.Proxy = new WebProxy(_proxy); - return clientWs; - }); - var client = new WebsocketClient(_wsUri, factory) - { - ReconnectTimeout = TimeSpan.FromSeconds(_reconnectTimeout) - }; - _wsClient = client; - - client.ReconnectionHappened.Subscribe(WsReconnection); - client.MessageReceived.Subscribe(WsMessageReceived); - client.DisconnectionHappened.Subscribe(WsDisconnection); - - _logger.Debug("Websocket client has been built, about to start"); - await client.Start(); - _logger.Debug("Websocket client started!"); - } - - public bool IsConnected() - { - return _wsClient is { IsRunning: true }; - } - - private void WsDisconnection(DisconnectionInfo disconnectionInfo) - { - _logger.Error($"Client disconnected from the chat (or never successfully connected). Type is {disconnectionInfo.Type}"); - _logger.Error($"Close Status => {disconnectionInfo.CloseStatus}; Close Status Description => {disconnectionInfo.CloseStatusDescription}"); - _logger.Error(disconnectionInfo.Exception); - OnWsDisconnection?.Invoke(this, disconnectionInfo, _connectionId); - } - - private void SendConnectRequest() - { - if (_wsJwt == null) - { - _logger.Error("JWT was null."); - throw new InvalidOperationException("JWT was null"); - } - - var data = new ConnectRequestModel { Connect = new ConnectRequestTokenModel { Token = _wsJwt } }; - var payload = JsonSerializer.Serialize(data); - _logger.Debug("Sending the following payload to 3xpl"); - _logger.Debug(payload); - _wsClient.Send(payload); - } - - private void WsReconnection(ReconnectionInfo reconnectionInfo) - { - _logger.Error($"Websocket connection dropped and reconnected. Reconnection type is {reconnectionInfo.Type}"); - _logger.Info("Refreshing JWT"); - RefreshApiToken().Wait(); - _logger.Info("Sending connect request"); - SendConnectRequest(); - OnWsReconnect?.Invoke(this, reconnectionInfo, _connectionId); - } - - public void SendSubscribeRequest(string channel) - { - var data = new SubscribeRequestModel { Subscribe = new SubscribeRequestChannelModel { Channel = channel }}; - var payload = JsonSerializer.Serialize(data); - _logger.Debug("Sending the following subscription payload to 3xpl"); - _logger.Debug(payload); - _wsClient.Send(payload); - } - - private void WsMessageReceived(ResponseMessage message) - { - OnWsMessageReceived?.Invoke(this, message, _connectionId); - _logger.Debug("Received JSON from 3xpl"); - _logger.Debug(message.Text); - - if (message.Text == null) - { - _logger.Info("Websocket message was null, ignoring packet"); - return; - } - - if (message.Text == "{}") - { - _logger.Debug("Received ping from 3xpl. Sending back a pong and invoking event"); - _wsClient.Send("{}"); - OnThreeXplPing?.Invoke(this, _connectionId); - return; - } - - BaseThreeXplPacketModel threeXplPacket; - try - { - threeXplPacket = JsonSerializer.Deserialize(message.Text) ?? - throw new InvalidOperationException(); - } - catch (Exception e) - { - _logger.Error("Failed to parse 3xpl payload. Exception follows:"); - _logger.Error(e); - _logger.Error("--- Message from 3xpl follows ---"); - _logger.Error(message.Text); - _logger.Error("--- /end of message ---"); - return; - } - - if (threeXplPacket.Connect != null) - { - _logger.Debug("Received connect packet from 3xpl, invoking event"); - OnThreeXplConnect?.Invoke(this, threeXplPacket.Connect, _connectionId); - return; - } - - if (threeXplPacket.Push != null) - { - _logger.Debug("Received data event from 3xpl"); - OnThreeXplPush?.Invoke(this, threeXplPacket.Push, _connectionId); - return; - } - - if (threeXplPacket.Error != null) - { - _logger.Debug("Received error packet from 3xpl"); - OnThreeXplError?.Invoke(this, threeXplPacket.Error, _connectionId); - return; - } - - if (threeXplPacket.Subscribe != null) - { - _logger.Debug("Received subscribe packet from 3xpl"); - OnThreeXplSubscribe?.Invoke(this, threeXplPacket.Subscribe, _connectionId); - return; - } - - _logger.Error("Failed to handle 3xpl packet"); - _logger.Error("--- Message from 3xpl follows ---"); - _logger.Error(message.Text); - _logger.Error("--- /end of message ---"); - } -} \ No newline at end of file diff --git a/ThreeXplWsClient/ThreeXplWsClient.csproj b/ThreeXplWsClient/ThreeXplWsClient.csproj deleted file mode 100644 index 4e54bcb..0000000 --- a/ThreeXplWsClient/ThreeXplWsClient.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - -