fCraft.IRC.SendRawMessage C# (CSharp) Method

SendRawMessage() public static method

public static SendRawMessage ( string prefix, [ line, string suffix ) : void
prefix string
line [
suffix string
return void
        public static void SendRawMessage( string prefix, [NotNull] string line, string suffix ) {
            if ( line == null )
                throw new ArgumentNullException( "line" );
            // handle newlines
            if ( line.Contains( '\n' ) ) {
                string[] segments = line.Split( '\n' );
                SendRawMessage( prefix, segments[0], suffix );
                for ( int i = 1; i < segments.Length; i++ ) {
                    SendRawMessage( prefix, "> " + segments[i], suffix );
                }
                return;
            }

            // handle line wrapping
            int maxContentLength = MaxMessageSize - prefix.Length - suffix.Length - userHostLength - 3 - maxNickLength;
            if ( line.Length > maxContentLength ) {
                SendRawMessage( prefix, line.Substring( 0, maxContentLength ), suffix );
                int offset = maxContentLength;
                while ( offset < line.Length ) {
                    int length = Math.Min( line.Length - offset, maxContentLength - 2 );
                    SendRawMessage( prefix, "> " + line.Substring( offset, length ), suffix );
                    offset += length;
                }
                return;
            }

            // actually send
            OutputQueue.Enqueue( prefix + line + suffix );
        }