public void InitNickUserTests() { User user = new User("nick", "user"); Assert.AreEqual("nick", user.NickName); Assert.AreEqual("user", user.UserName); }
public void InviteTests() { User user = new User("user"); Channel channel = new Channel("channel"); Messages.Send.Invite invite = user.Invite(channel); string output = TestHelpers.GetSendMessageOutput(invite); Assert.AreEqual("INVITE user #channel", output); }
public User FromNick(string nick) { if (this._store.ContainsKey(nick)) { return this._store[nick]; } User user = new User(nick); this._store[nick] = user; return user; }
internal void TriggerOnJoin(User user) { if (this.OnJoin != null) { this.OnJoin(this, user); } }
public void InitNickTests() { User user = new User("nick"); Assert.AreEqual("nick", user.NickName); }
public Messages.Send.Kick Kick(User user, string message) { return new Messages.Send.Kick(this, user, message); }
internal void TriggerOnVersionReply(User source, string version) { if (this.OnVersionReply != null) { this.OnVersionReply(this, source, version); } }
public Messages.Send.Kick Kick(User user) { return new Messages.Send.Kick(this, user); }
public void TriggerOnMessage(User source, string message) { if (this.OnMessage != null) { this.OnMessage(this, source, message); } }
internal void TriggerOnNotice(User user, string notice) { if (this.OnNotice != null) { this.OnNotice(this, user, notice); } }
public Dictionary<string, Channel> HasUser(User user) { return this._store.Where(c => c.Value.Users.ContainsKey(user.NickName)).ToDictionary(c => c.Key, c => c.Value, StringComparer.InvariantCultureIgnoreCase); }
internal void SetUser(string nick, User user) { this._store[nick] = user; }
internal void SetRank(User user, UserRank rank) { user._ranks[this.Name] = rank; this.TriggerOnRank(this, user, rank); }
internal void RemoveUser(User user) { if (this.Users.ContainsKey(user.NickName)) { user._channels.Remove(this.Name); user._ranks.Remove(this.Name); } }
internal void LeaveUser(User user, string reason) { this.RemoveUser(user); this.TriggerOnLeave(user, reason); }
internal void JoinUser(User user) { this.AddUser(user); this.TriggerOnJoin(user); }
internal void AddUser(User user) { if (this.Users.ContainsKey(user.NickName)) { return; } user._channels.Add(this.Name, this); this.TriggerOnUserAdded(user); if (!user._ranks.ContainsKey(this.Name)) { user._ranks.Add(this.Name, UserRank.None); } }
internal void TriggerOnKick(User kicker, User user, string reason) { if (this.OnKick != null) { this.OnKick(this, kicker, user, reason); } }
internal void TriggerOnLeave(User user, string reason) { if (this.OnLeave != null) { this.OnLeave(this, user, reason); } }
/// <summary> /// Connect to a specified <paramref name="server" />. /// </summary> /// <param name="server">The host of the server to connect to.</param> /// <param name="port">The port to connect to on the server.</param> /// <param name="ssl">True for SSL, false if not.</param> /// <param name="user">The NetIRC.User to use for connecting to the server.</param> /// <param name="capabilities">The capabilities to request from the server.</param> public void Connect(string server, int port, bool ssl, User user) { this.User = user; this.HostName = server; this.Port = port; this.UserFactory.SetUser(user.NickName, user); this.TcpClient = new TcpClient(); this.TcpClient.Connect(server, port); this.Stream = this.TcpClient.GetStream(); this.Reader = new StreamReader(this.Stream); this.Writer = new StreamWriter(this.Stream) { NewLine = "\r\n", AutoFlush = true }; this.ReadThread = new Thread(this.ReadStream) {IsBackground = true}; this.ReadThread.Start(); this.Send(new Messages.Send.UserMessage(user)); this.Send(new Messages.Send.Nick(user)); }
internal void TriggerOnMode(User setter, List<KeyValuePair<string, string>> changes) { if (this.OnMode != null) { this.OnMode(this, setter, changes); } }
internal void TriggerOnAction(User user, string action) { if (this.OnAction != null) { this.OnAction(this, user, action); } }
internal virtual void TriggerOnRank(Channel source, User user, UserRank rank) { OnRankHandler handler = this.OnRank; if (handler != null) handler(source, user, rank); }
internal void TriggerOnVersion(User source) { if (this.OnVersion != null) { this.OnVersion(this, source); } }
internal void TriggerOnUserAdded(User user) { if (this.OnUserAdded != null) { this.OnUserAdded(this, user); } }
internal void TriggerOnWho(User user, string message) { if (this.OnWho != null) { this.OnWho(this, user, message); } }
public Messages.Send.Invite Invite(User user) { return new Messages.Send.Invite(this, user); }