コード例 #1
0
 public EventMucRoom(TypicalEvent typicalEvent, MucRoom mucRoom, User user, string message)
     : base(message, EventSeverity.Info)
 {
     _typicalEvent = typicalEvent;
     _mucRoom = mucRoom;
     _user = user;
 }
コード例 #2
0
ファイル: Client.cs プロジェクト: haslo/OCTGN
 /// <summary>
 /// The remove friend.
 /// </summary>
 /// <param name="user">
 /// The user.
 /// </param>
 public void RemoveFriend(User user)
 {
     this.xmpp.PresenceManager.Unsubscribe(user.JidUser);
     this.RosterManager.RemoveRosterItem(user.JidUser);
     this.Friends.Remove(user);
     this.OnDataReceived.Invoke(this, DataRecType.FriendList, this);
 }
コード例 #3
0
ファイル: Client.cs プロジェクト: digitalalchemy/OCTGN
        public void UnignoreUser(User user)
        {
            IgnoreList.RemoveAll(x => x.Val == user.JidUser);

            PrivacyManager.UpdateList("ignore", IgnoreList.ToArray(), OnIgnorelistUpdated, null);
        }
コード例 #4
0
ファイル: Client.cs プロジェクト: digitalalchemy/OCTGN
 public void SendGameInvite(User user, Guid sessionId, string gamePassword)
 {
     Log.InfoFormat("Sending game request to {0}", user.UserName);
     var req = new InviteToGameRequest(sessionId, gamePassword);
     var m = new Message(user.JidUser, this.Me.JidUser, MessageType.normal, "", "invitetogamerequest");
     m.GenerateId();
     m.AddChild(req);
     this.xmpp.Send(m);
 }
コード例 #5
0
ファイル: Client.cs プロジェクト: digitalalchemy/OCTGN
        public void IgnoreUser(string username)
        {
            username = username.ToLower();
            if (username == this.Me.UserName.ToLowerInvariant())
            {
                return;
            }

            var user = new User(new Jid(username + "@" + this.Config.ChatHost));
            if (Ignorees.Contains(user))
            {
                return;
            }

            var order = (IgnoreList.Count == 0) ? 1 : IgnoreList.Max(x => x.Order) + 1;
            var block = RuleManager.BlockByJid(user.JidUser, order, Stanza.Message);

            IgnoreList.Add(block);

            PrivacyManager.AddList("ignore", IgnoreList.ToArray(), OnIgnorelistUpdated, null);
            PrivacyManager.ChangeActiveList("ignore");
            PrivacyManager.ChangeDefaultList("ignore");
        }
コード例 #6
0
ファイル: MucManager.cs プロジェクト: jptoto/argsxmpp
        /// <summary>
        /// Invite multiple contacts to a chatroom
        /// </summary>
        /// <param name="jids"></param>
        /// <param name="room"></param>
        /// <param name="reason"></param>
        public void Invite(Jid[] jids, Jid room, string reason)
        {
            Message msg = new Message();
            msg.To = room;

            User user = new User();
            foreach (Jid jid in jids)
            {
                if (reason != null)
                    user.AddChild(new Invite(jid, reason));
                else
                    user.AddChild(new Invite(jid));
            }

            msg.AddChild(user);

            m_connection.Send(msg);
        }
コード例 #7
0
ファイル: MucManager.cs プロジェクト: jptoto/argsxmpp
        /// <summary>
        /// Decline a groupchat invitation
        /// </summary>
        /// <param name="to">the jid which invited us</param>
        /// <param name="room">to room to which we send the decline (this is normally the same room we were invited to)</param>
        /// <param name="reason">reason why we decline the invitation</param>
        public void Decline(Jid to, Jid room, string reason)
        {
            Message msg = new Message();
            msg.To = room;

            User user = new User();
            if (reason != null)
                user.Decline = new Decline(to, reason);
            else
                user.Decline = new Decline(to);

            msg.AddChild(user);

            m_connection.Send(msg);
        }
コード例 #8
0
ファイル: HipChatAdapter.cs プロジェクト: jamessantiago/mmbot
        private void OnClientMessage(object sender, agsXMPP.protocol.client.Message message)
        {
            if (!String.IsNullOrEmpty(message.Body))
            {
                Console.WriteLine("Message : {0} - from {1}", message.Body, message.From);

                string user;

                if (message.Type != MessageType.groupchat)
                {
                    if (!_roster.TryGetValue(message.From.User, out user))
                    {
                        user = "******";
                    }
                }
                else
                {
                    user = message.From.Resource;
                }

                if (user == _roomNick)
                    return;

                
                Logger.Info(string.Format("[{0}] {1}: {2}", DateTime.Now, user, message.Body.Trim()));

                var userObj = new User(message.Id, user, new string[0], message.From.Bare, Id);

                if (userObj.Name != _nick)
                {
                    Task.Run(() =>
                        Robot.Receive(new TextMessage(userObj, message.Body.Trim(), message.Id)));
                }
            }
        }
コード例 #9
0
ファイル: Chat.cs プロジェクト: Cosworth32/OCTGN
        private void XmppOnPresence(object sender, Presence pres)
        {
            switch (pres.Type)
            {
                case PresenceType.available:
                    if (pres.From.Server == "conference." + this.client.Host)
                    {
                        var addUser = new User(pres.MucUser.Item.Jid);
                        var rm = this.GetRoom(new User(pres.From), true);
                        switch (pres.MucUser.Item.Affiliation)
                        {
                            case Affiliation.none:
                                break;
                            case Affiliation.owner:
                                rm.OwnerList.Add(addUser);
                                break;
                            case Affiliation.admin:
                                rm.AdminList.Add(addUser);
                                break;
                            case Affiliation.member:
                                break;
                            case Affiliation.outcast:
                                break;
                        }

                        switch (pres.MucUser.Item.Role)
                        {
                            case Role.none:
                                break;
                            case Role.moderator:
                                rm.ModeratorList.Add(addUser);
                                break;
                            case Role.participant:
                                break;
                            case Role.visitor:
                                break;
                        }

                        rm.AddUser(new User(pres.MucUser.Item.Jid), false);
                    }

                    break;
                case PresenceType.unavailable:
                    {
                        if (pres.From.Server == "conference." + this.client.Host)
                        {
                            if (pres.MucUser.Item.Jid == null)
                            {
                                break;
                            }

                            if (pres.MucUser.Item.Jid.Bare == this.client.Me.FullUserName)
                            {
                                break;
                            }

                            ChatRoom rm = this.GetRoom(new User(pres.From), true);
                            rm.UserLeft(new User(pres.MucUser.Item.Jid));
                        }

                        break;
                    }
            }
        }
コード例 #10
0
ファイル: Chat.cs プロジェクト: Cosworth32/OCTGN
        /// <summary>
        /// Get an existing user, or if it doesn't exist, create it.
        /// </summary>
        /// <param name="otherUser">
        /// The other user(or group user if a group chat)
        /// </param>
        /// <param name="group">
        /// Is it a group chat?
        /// </param>
        /// <returns>
        /// The <see cref="ChatRoom"/>.
        /// </returns>
        public ChatRoom GetRoom(User otherUser, bool group = false)
        {
            if (group)
            {
                ChatRoom ret = this.Rooms.FirstOrDefault(x => x.IsGroupChat && x.GroupUser.Equals(otherUser));
                if (ret == null)
                {
                    ret = new ChatRoom(this.NextRid, this.client, otherUser);
                    this.Rooms.Add(ret);
                }

                if(ret != null)
                    this.FireOnCreateRoom(this,ret);
                return ret;
            }
            else
            {
                ChatRoom ret = this.Rooms.FirstOrDefault(x => x.Users.Contains(otherUser) && !x.IsGroupChat);
                if (ret == null)
                {
                    ret = new ChatRoom(this.NextRid, this.client, otherUser);
                    this.Rooms.Add(ret);
                }
                if(ret != null)
                    this.FireOnCreateRoom(this,ret);
                return ret;
            }
        }
コード例 #11
0
ファイル: Client.cs プロジェクト: TriAdX/OCTGN
        /// <summary>
        /// The xmpp on on message.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="msg">
        /// The msg.
        /// </param>
        private void XmppOnOnMessage(object sender, Message msg)
        {
            if (msg.Type == MessageType.groupchat)
            {
                if (msg.HasTag(typeof(Sub)))
                {
                    var sub = msg.SelectSingleElement<Sub>();
                    if (this.OnDataReceived != null)
                    {
                        var u = new User(new Jid(msg.From.Resource + "@" + Host));
                        u.IsSubbed = sub.IsSubbed;
                        this.OnDataReceived.Invoke(this,DataRecType.UserSubChanged, u);
                    }
                }
            }
            if (msg.Type == MessageType.normal)
            {
                if (msg.Subject == "gameready")
                {
                    Log.Info("Got gameready message");
                    int port = -1;
                    if (int.TryParse(msg.Body, out port) && port != -1)
                    {
                        Log.Info("gameready port " + port);
                        if (this.OnDataReceived != null)
                        {
                            Log.Info("Firing gameready data on port " + port);
                            this.OnDataReceived.Invoke(this, DataRecType.HostedGameReady, port);
                        }
                        Log.InfoFormat("CurrentHostedGamePort={0}", CurrentHostedGamePort);
                        this.CurrentHostedGamePort = port;
                    }
                    else
                    {
                        Log.Info("Couldn't parse gameready port " + msg.Body ?? "null");
                    }
                }
                else if (msg.Subject == "gamelist")
                {
                    Log.Info("Got game list");
                    var list = new List<HostedGameData>();
                    foreach (object a in msg.ChildNodes)
                    {
                        var gi = a as HostedGameData;
                        if (gi != null)
                        {
                            list.Add(gi);
                        }
                    }

                    this.games = list;
                    Log.Info("Going to fire game list event");
                    if (this.OnDataReceived != null)
                    {
                        Log.Info("Firing game list event");
                        this.OnDataReceived.Invoke(this, DataRecType.GameList, list);
                    }
                }
                else if (msg.Subject == "refresh")
                {
                    Log.Info("Server wants a refresh of game list");
                    if (this.OnDataReceived != null)
                    {
                        Log.Info("Firing server wants a refresh of game list");
                        this.OnDataReceived.Invoke(this, DataRecType.GamesNeedRefresh, null);
                    }
                }
                else if (msg.From.Bare.ToLower() == this.xmpp.MyJID.Server.ToLower())
                {
                    if (msg.Subject == null)
                    {
                        msg.Subject = string.Empty;
                    }

                    if (msg.Body == null)
                    {
                        msg.Body = string.Empty;
                    }

                    var d = new Dictionary<string, string>();
                    d["Message"] = msg.Body;
                    d["Subject"] = msg.Subject;
                    if (this.OnDataReceived != null)
                    {
                        this.OnDataReceived.Invoke(this, DataRecType.Announcement, d);
                    }
                }
            }
        }
コード例 #12
0
 public EventMucRoom(MucRoom mucRoom, User user, string message)
     : base(message, EventSeverity.Info)
 {
     _mucRoom = mucRoom;
     _user = user;
 }
コード例 #13
0
ファイル: Chat.cs プロジェクト: jonbonne/OCTGN
 public bool HasGroupRoom(User groupUser)
 {
     lock (Rooms)
     {
         return Rooms.Any(x => x.GroupUser == groupUser);
     }
 }