Пример #1
0
        public void InitNickUserTests()
        {
            User user = new User("nick", "user");

            Assert.AreEqual("nick", user.NickName);
            Assert.AreEqual("user", user.UserName);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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;
        }
Пример #4
0
 internal void TriggerOnJoin(User user)
 {
     if (this.OnJoin != null)
     {
         this.OnJoin(this, user);
     }
 }
Пример #5
0
        public void InitNickTests()
        {
            User user = new User("nick");

            Assert.AreEqual("nick", user.NickName);
        }
Пример #6
0
 public Messages.Send.Kick Kick(User user, string message)
 {
     return new Messages.Send.Kick(this, user, message);
 }
Пример #7
0
 internal void TriggerOnVersionReply(User source, string version)
 {
     if (this.OnVersionReply != null)
     {
         this.OnVersionReply(this, source, version);
     }
 }
Пример #8
0
 public Messages.Send.Kick Kick(User user)
 {
     return new Messages.Send.Kick(this, user);
 }
Пример #9
0
 public void TriggerOnMessage(User source, string message)
 {
     if (this.OnMessage != null)
     {
         this.OnMessage(this, source, message);
     }
 }
Пример #10
0
 internal void TriggerOnNotice(User user, string notice)
 {
     if (this.OnNotice != null)
     {
         this.OnNotice(this, user, notice);
     }
 }
Пример #11
0
 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);
 }
Пример #12
0
 internal void SetUser(string nick, User user)
 {
     this._store[nick] = user;
 }
Пример #13
0
 internal void SetRank(User user, UserRank rank)
 {
     user._ranks[this.Name] = rank;
     this.TriggerOnRank(this, user, rank);
 }
Пример #14
0
 internal void RemoveUser(User user)
 {
     if (this.Users.ContainsKey(user.NickName))
     {
         user._channels.Remove(this.Name);
         user._ranks.Remove(this.Name);
     }
 }
Пример #15
0
 internal void LeaveUser(User user, string reason)
 {
     this.RemoveUser(user);
     this.TriggerOnLeave(user, reason);
 }
Пример #16
0
        internal void JoinUser(User user)
        {
            this.AddUser(user);

            this.TriggerOnJoin(user);
        }
Пример #17
0
        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);
            }
        }
Пример #18
0
 internal void TriggerOnKick(User kicker, User user, string reason)
 {
     if (this.OnKick != null)
     {
         this.OnKick(this, kicker, user, reason);
     }
 }
Пример #19
0
 internal void TriggerOnLeave(User user, string reason)
 {
     if (this.OnLeave != null)
     {
         this.OnLeave(this, user, reason);
     }
 }
Пример #20
0
        /// <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));
        }
Пример #21
0
 internal void TriggerOnMode(User setter, List<KeyValuePair<string, string>> changes)
 {
     if (this.OnMode != null)
     {
         this.OnMode(this, setter, changes);
     }
 }
Пример #22
0
 internal void TriggerOnAction(User user, string action)
 {
     if (this.OnAction != null)
     {
         this.OnAction(this, user, action);
     }
 }
Пример #23
0
 internal virtual void TriggerOnRank(Channel source, User user, UserRank rank)
 {
     OnRankHandler handler = this.OnRank;
     if (handler != null) handler(source, user, rank);
 }
Пример #24
0
 internal void TriggerOnVersion(User source)
 {
     if (this.OnVersion != null)
     {
         this.OnVersion(this, source);
     }
 }
Пример #25
0
 internal void TriggerOnUserAdded(User user)
 {
     if (this.OnUserAdded != null)
     {
         this.OnUserAdded(this, user);
     }
 }
Пример #26
0
 internal void TriggerOnWho(User user, string message)
 {
     if (this.OnWho != null)
     {
         this.OnWho(this, user, message);
     }
 }
Пример #27
0
 public Messages.Send.Invite Invite(User user)
 {
     return new Messages.Send.Invite(this, user);
 }