ChatClient/ChatClient.cs
/// <summary>
/// Sends the specified text as a message.
/// </summary>
/// <param name="text">The message text.</param>
/// <param name="channelName">The name of the channel; default: sole connected channel.</param>
/// <returns>False if error</returns>
Sends the specified text as a message.
Sends the specified text as a message .
public bool SendMessage(string? text, string? channelName = null) {
            channelName = GetValidChannelName(channelName);
            if (string.IsNullOrEmpty(channelName)) {
                LogLine($"null/empty {nameof(channelName)}", LogLevel.Error);
                return false;
            }
            if (string.IsNullOrEmpty(text)) {
                LogLine($"null/empty {nameof(text)}", LogLevel.Error);
                return false;
            }
            if (!SocketIsReady)
                return false;
            LastMessageSent = text;
            while (text.Length > 500) {
                var subText = text[0..500];
                subText = subText[0..subText.LastIndexOf(' ')];
                text = text[subText.Length..];
                socket.Send($"PRIVMSG #{channelName} :{subText}");
            }
            socket.Send($"PRIVMSG #{channelName} :{text}");
            return true;
        }
public bool SendMessage ( string ? text , string ? channelName = null ) { channelName = GetValidChannelName ( channelName ) ; if ( string . IsNullOrEmpty ( channelName ) ) { LogLine ( $" null/empty  { nameof ( channelName ) } " , LogLevel . Error ) ; return false ; } if ( string . IsNullOrEmpty ( text ) ) { LogLine ( $" null/empty  { nameof ( text ) } " , LogLevel . Error ) ; return false ; } if ( ! SocketIsReady ) return false ; LastMessageSent = text ; while ( text . Length > 500 ) { var subText = text [ 0 .. 500 ] ; subText = subText [ 0 .. subText . LastIndexOf ( ' ' ) ] ; text = text [ subText . Length .. ] ; socket . Send ( $" PRIVMSG # { channelName }  : { subText } " ) ; } socket . Send ( $" PRIVMSG # { channelName }  : { text } " ) ; return true ; }
Sends the specified text as a message.
Sends the specified text as a message .
False if error
False if error
text
string?
The message text.
The message text .
channelName
string?
The name of the channel; default: sole connected channel.
The name of the channel ; default : sole connected channel .