internal IrcMessage(bool raw, IrcPrefix prefix, string command, params string[] parameters) { this.Raw = raw; this.From = prefix; this.Command = command; this.Parameters = parameters; }
internal static IrcMessage Parse(string data) { StringBuilder sb = new StringBuilder(); List <string> para = new List <string>(); int size = data.Length > 512 ? 512 : data.Length; Char[] c = data.ToCharArray(0, size); int pos = 0; string prefix = null; string command = null; if (c[0] == ':') { for (pos = 1; pos < c.Length; pos++) { if (c[pos] == ' ') { break; } sb.Append(c[pos]); } prefix = sb.ToString(); sb.Length = 0; pos++; } for (; pos < c.Length; pos++) { if (c[pos] == ' ') { break; } sb.Append(c[pos]); } command = sb.ToString(); sb.Length = 0; pos++; bool trailing = false; while (pos < c.Length) { if (c[pos] == ':') { trailing = true; pos++; } for (; pos < c.Length; pos++) { if (c[pos] == ' ' && !trailing) { break; } sb.Append(c[pos]); } para.Add(sb.ToString()); sb.Length = 0; pos++; } return(new IrcMessage(IrcPrefix.Parse(prefix), command, para.ToArray())); }
internal IrcMessage(IrcPrefix prefix, string command, params string[] parameters) : this(false, prefix, command, parameters) { }