internal void AddMessageToServerConversation(IrcMessage message) { int x; var type = (Int32.TryParse(message.Type, out x)) ? IrcMessageType.ServerResponse : IrcMessageType.ServerRequest; _serverConversation.Messages.Add(new IrcConversationServerMessage() { TimeStamp = DateTime.Now, Message = message.ToString(), IsLoginError = message.IsLoginError(), Type = type, Username = _connectionInfo.Username, MessageType = message.Type, }); }
internal void AddMessageToChannelConversation(IrcMessage message, String channelName, IrcMessageType type) { foreach (var c in _conversations) { if (c is IrcChannelConversation) { if (((IrcChannelConversation)c).Name == channelName) { c.Messages.Add(new IrcConversationMessage() { TimeStamp = DateTime.Now, Message = message.ToString(), Type = type, Username = _connectionInfo.Username, MessageType = message.Type, }); return; } } } }
internal void AddMessageToPersonConversation(IrcMessage message, String username, IrcMessageType type) { foreach (var c in _conversations) { if (c is IrcPersonConversation) { if (((IrcPersonConversation)c).Name == username) { c.Messages.Add(new IrcConversationMessage() { TimeStamp = DateTime.Now, Message = message.ToString(), Type = type, Username = _connectionInfo.Username, MessageType = message.Type, }); return; } } } var newConversation = CreatePersonConversation(username); newConversation.Messages.Add(new IrcConversationMessage() { TimeStamp = DateTime.Now, Message = message.ToString(), Type = type, Username = _connectionInfo.Username, MessageType = message.Type, }); }
/// <summary> /// This method sends message to IRC server where IrcConnection is connected /// </summary> /// <param name="message">Message to send to IRC server</param> public void SendAsync(IrcMessage message) { if (message == null) { throw new ArgumentNullException("messages"); } if (message.ToString().Length > 512) { throw new ArgumentException("message length"); } var sendString = message.ToString() + IrcDefinition.NewLine; BeginWrite(IrcDefinition.Encoding.GetBytes(sendString)); }