Ejemplo n.º 1
0
        /// <summary>
        ///   Find the member from X sessionID
        /// </summary>
        /// <param name = "sessionid"></param>
        /// <param name = "Agent"></param>
        /// <returns></returns>
        public ChatSessionMember FindMember(UUID sessionid, UUID Agent)
        {
            ChatSession session;

            ChatSessions.TryGetValue(sessionid, out session);
            if (session == null)
            {
                return(null);
            }
            ChatSessionMember thismember = new ChatSessionMember {
                AvatarKey = UUID.Zero
            };

#if (!ISWIN)
            foreach (ChatSessionMember testmember in session.Members)
            {
                if (testmember.AvatarKey == Agent)
                {
                    thismember = testmember;
                }
            }
#else
            foreach (ChatSessionMember testmember in session.Members.Where(testmember => testmember.AvatarKey == Agent))
            {
                thismember = testmember;
            }
#endif
            return(thismember);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Add this member to the friend conference
        /// </summary>
        /// <param name = "member"></param>
        /// <param name = "SessionID"></param>
        public void AddMemberToGroup(ChatSessionMember member, UUID SessionID)
        {
            ChatSession session;

            ChatSessions.TryGetValue(SessionID, out session);
            session.Members.Add(member);
        }
Ejemplo n.º 3
0
        private void MuteUser(UUID sessionid, IEventQueueService eq, UUID AgentID, ChatSessionMember thismember,
                              bool forward)
        {
            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
            {
                AgentID      = thismember.AvatarKey,
                CanVoiceChat = thismember.CanVoiceChat,
                IsModerator  = thismember.IsModerator,
                MuteText     = thismember.MuteText,
                MuteVoice    = thismember.MuteVoice,
                Transition   = "ENTER"
            };

            // Send an update to the affected user
            IClientAPI affectedUser = GetActiveClient(thismember.AvatarKey);

            if (affectedUser != null)
            {
                eq.ChatterBoxSessionAgentListUpdates(sessionid, new[] { block }, AgentID, "ENTER",
                                                     affectedUser.Scene.RegionInfo.RegionHandle);
            }
            else if (forward)
            {
                SendMutedUserIM(thismember, sessionid);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        ///   Check whether the user has moderator permissions
        /// </summary>
        /// <param name = "Agent"></param>
        /// <param name = "sessionid"></param>
        /// <returns></returns>
        public bool CheckModeratorPermission(UUID Agent, UUID sessionid)
        {
            ChatSession session;

            ChatSessions.TryGetValue(sessionid, out session);
            if (session == null)
            {
                return(false);
            }
            ChatSessionMember thismember = new ChatSessionMember {
                AvatarKey = UUID.Zero
            };

#if (!ISWIN)
            foreach (ChatSessionMember testmember in session.Members)
            {
                if (testmember.AvatarKey == Agent)
                {
                    thismember = testmember;
                }
            }
#else
            foreach (ChatSessionMember testmember in session.Members.Where(testmember => testmember.AvatarKey == Agent))
            {
                thismember = testmember;
            }
#endif
            if (thismember == null)
            {
                return(false);
            }
            return(thismember.IsModerator);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///   Remove the member from this session
        /// </summary>
        /// <param name = "client"></param>
        /// <param name = "im"></param>
        public void DropMemberFromSession(IClientAPI client, GridInstantMessage im)
        {
            ChatSession session;

            ChatSessions.TryGetValue(im.imSessionID, out session);
            if (session == null)
            {
                return;
            }
            ChatSessionMember member = new ChatSessionMember {
                AvatarKey = UUID.Zero
            };

#if (!ISWIN)
            foreach (ChatSessionMember testmember in session.Members)
            {
                if (testmember.AvatarKey == im.fromAgentID)
                {
                    member = testmember;
                }
            }
#else
            foreach (ChatSessionMember testmember in session.Members.Where(testmember => testmember.AvatarKey == im.fromAgentID))
            {
                member = testmember;
            }
#endif

            if (member.AvatarKey != UUID.Zero)
            {
                session.Members.Remove(member);
            }

            if (session.Members.Count == 0)
            {
                ChatSessions.Remove(session.SessionID);
                return;
            }

            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
            {
                AgentID      = member.AvatarKey,
                CanVoiceChat = member.CanVoiceChat,
                IsModerator  = member.IsModerator,
                MuteText     = member.MuteText,
                MuteVoice    = member.MuteVoice,
                Transition   = "LEAVE"
            };
            IEventQueueService eq = client.Scene.RequestModuleInterface <IEventQueueService>();
            foreach (ChatSessionMember sessionMember in session.Members)
            {
                eq.ChatterBoxSessionAgentListUpdates(session.SessionID, new[] { block }, sessionMember.AvatarKey, "LEAVE",
                                                     findScene(sessionMember.AvatarKey).RegionInfo.RegionHandle);
            }
        }
Ejemplo n.º 6
0
        private void SendMutedUserIM(ChatSessionMember member, UUID GroupID)
        {
            GridInstantMessage img = new GridInstantMessage
            {
                toAgentID   = member.AvatarKey,
                fromGroup   = true,
                imSessionID = GroupID,
                dialog      = 213,
                //Special mute one
                message = member.MuteText + "," + member.MuteVoice
            };

            m_msgTransferModule.SendInstantMessage(img);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///   Add this member to the friend conference
        /// </summary>
        /// <param name = "member"></param>
        /// <param name = "SessionID"></param>
        public void AddMemberToGroup(ChatSessionMember member, UUID SessionID)
        {
            ChatSession session;

            ChatSessions.TryGetValue(SessionID, out session);
            ChatSessionMember oldMember = FindMember(SessionID, member.AvatarKey);

            if ((oldMember == null) || (oldMember.AvatarKey == UUID.Zero))
            {
                session.Members.Add(member);
            }
            else
            {
                oldMember.HasBeenAdded = true; //Reset this
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///   Add the agent to the in-memory session lists and give them the default permissions
        /// </summary>
        /// <param name = "AgentID"></param>
        /// <param name = "SessionID"></param>
        private void AddDefaultPermsMemberToSession(UUID AgentID, UUID SessionID)
        {
            ChatSession session;

            ChatSessions.TryGetValue(SessionID, out session);
            ChatSessionMember member = new ChatSessionMember
            {
                AvatarKey    = AgentID,
                CanVoiceChat = true,
                IsModerator  = false,
                MuteText     = false,
                MuteVoice    = false,
                HasBeenAdded = false
            };

            session.Members.Add(member);
        }
Ejemplo n.º 9
0
        /// <summary>
        ///   Check whether the user has moderator permissions
        /// </summary>
        /// <param name = "Agent"></param>
        /// <param name = "sessionid"></param>
        /// <returns></returns>
        public bool CheckModeratorPermission(UUID Agent, UUID sessionid)
        {
            ChatSession session;
            ChatSessions.TryGetValue(sessionid, out session);
            if (session == null)
                return false;
            ChatSessionMember thismember = new ChatSessionMember {AvatarKey = UUID.Zero};
#if (!ISWIN)
            foreach (ChatSessionMember testmember in session.Members)
            {
                if (testmember.AvatarKey == Agent)
                {
                    thismember = testmember;
                }
            }
#else
             foreach (ChatSessionMember testmember in session.Members.Where(testmember => testmember.AvatarKey == Agent))
            {
                thismember = testmember;
            }
#endif
            if (thismember == null)
                return false;
            return thismember.IsModerator;
        }
Ejemplo n.º 10
0
 /// <summary>
 ///   Add the agent to the in-memory session lists and give them the default permissions
 /// </summary>
 /// <param name = "AgentID"></param>
 /// <param name = "SessionID"></param>
 private void AddDefaultPermsMemberToSession(UUID AgentID, UUID SessionID)
 {
     ChatSession session;
     ChatSessions.TryGetValue(SessionID, out session);
     ChatSessionMember member = new ChatSessionMember
                                    {
                                        AvatarKey = AgentID,
                                        CanVoiceChat = true,
                                        IsModerator = false,
                                        MuteText = false,
                                        MuteVoice = false,
                                        HasBeenAdded = false
                                    };
     session.Members.Add(member);
 }
Ejemplo n.º 11
0
        /// <summary>
        ///   Find the member from X sessionID
        /// </summary>
        /// <param name = "sessionid"></param>
        /// <param name = "Agent"></param>
        /// <returns></returns>
        private ChatSessionMember FindMember(UUID sessionid, UUID Agent)
        {
            ChatSession session;
            ChatSessions.TryGetValue(sessionid, out session);
            if (session == null)
                return null;
            ChatSessionMember thismember = new ChatSessionMember {AvatarKey = UUID.Zero};
#if (!ISWIN)
            foreach (ChatSessionMember testmember in session.Members)
            {
                if (testmember.AvatarKey == Agent)
                {
                    thismember = testmember;
                }
            }
#else
            foreach (ChatSessionMember testmember in session.Members.Where(testmember => testmember.AvatarKey == Agent))
            {
                thismember = testmember;
            }
#endif
            return thismember;
        }
Ejemplo n.º 12
0
        /// <summary>
        ///   Remove the member from this session
        /// </summary>
        /// <param name = "client"></param>
        /// <param name = "im"></param>
        public void DropMemberFromSession(IClientAPI client, GridInstantMessage im)
        {
            ChatSession session;
            ChatSessions.TryGetValue(im.imSessionID, out session);
            if (session == null)
                return;
            ChatSessionMember member = new ChatSessionMember {AvatarKey = UUID.Zero};
#if (!ISWIN)
            foreach (ChatSessionMember testmember in session.Members)
            {
                if (testmember.AvatarKey == im.fromAgentID)
                {
                    member = testmember;
                }
            }
#else
            foreach (ChatSessionMember testmember in session.Members.Where(testmember => testmember.AvatarKey == im.fromAgentID))
            {
                member = testmember;
            }
#endif

            if (member.AvatarKey != UUID.Zero)
                session.Members.Remove(member);

            if (session.Members.Count == 0)
            {
                ChatSessions.Remove(session.SessionID);
                return;
            }

            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                    {
                        AgentID = member.AvatarKey,
                        CanVoiceChat = member.CanVoiceChat,
                        IsModerator = member.IsModerator,
                        MuteText = member.MuteText,
                        MuteVoice = member.MuteVoice,
                        Transition = "LEAVE"
                    };
            IEventQueueService eq = client.Scene.RequestModuleInterface<IEventQueueService>();
            foreach (ChatSessionMember sessionMember in session.Members)
            {
                eq.ChatterBoxSessionAgentListUpdates(session.SessionID, new[] {block}, sessionMember.AvatarKey, "LEAVE",
                                                     findScene(sessionMember.AvatarKey).RegionInfo.RegionHandle);
            }
        }
Ejemplo n.º 13
0
 /// <summary>
 ///   Add this member to the friend conference
 /// </summary>
 /// <param name = "member"></param>
 /// <param name = "SessionID"></param>
 public void AddMemberToGroup(ChatSessionMember member, UUID SessionID)
 {
     ChatSession session;
     ChatSessions.TryGetValue(SessionID, out session);
     session.Members.Add(member);
 }
Ejemplo n.º 14
0
 private void SendMutedUserIM(ChatSessionMember member, UUID GroupID)
 {
     GridInstantMessage img = new GridInstantMessage
                                  {
                                      toAgentID = member.AvatarKey,
                                      fromGroup = true,
                                      imSessionID = GroupID,
                                      dialog = 213,
                                      //Special mute one
                                      message = member.MuteText + "," + member.MuteVoice
                                  };
     m_msgTransferModule.SendInstantMessage(img);
 }
Ejemplo n.º 15
0
        /// <summary>
        ///   Remove the member from this session
        /// </summary>
        /// <param name = "client"></param>
        /// <param name = "im"></param>
        public void DropMemberFromSession(IClientAPI client, GridInstantMessage im, bool forwardOn)
        {
            ChatSession session = m_groupData.GetSession(im.imSessionID);
            if (session == null)
                return;
            ChatSessionMember member = new ChatSessionMember {AvatarKey = UUID.Zero};
#if (!ISWIN)
            foreach (ChatSessionMember testmember in session.Members)
            {
                if (testmember.AvatarKey == im.fromAgentID)
                {
                    member = testmember;
                }
            }
#else
            foreach (ChatSessionMember testmember in session.Members.Where(testmember => testmember.AvatarKey == im.fromAgentID))
            {
                member = testmember;
            }
#endif

            if (member.AvatarKey != UUID.Zero)
            {
                member.HasBeenAdded = false;
            }

            if (GetMemeberCount(session) == 0)
            {
                m_groupData.RemoveSession(session.SessionID); //Noone is left!
                return;
            }

            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                    {
                        AgentID = member.AvatarKey,
                        CanVoiceChat = member.CanVoiceChat,
                        IsModerator = member.IsModerator,
                        MuteText = member.MuteText,
                        MuteVoice = member.MuteVoice,
                        Transition = "LEAVE"
                    };
            List<UUID> usersToForwardTo = new List<UUID>();
            IEventQueueService eq = client.Scene.RequestModuleInterface<IEventQueueService>();
            foreach (ChatSessionMember sessionMember in session.Members)
            {
                IClientAPI user = GetActiveClient(sessionMember.AvatarKey);
                if (user != null)
                    eq.ChatterBoxSessionAgentListUpdates(session.SessionID, new[] {block}, sessionMember.AvatarKey,
                                                         "LEAVE", user.Scene.RegionInfo.RegionHandle);
                else
                    usersToForwardTo.Add(sessionMember.AvatarKey);
            }
            if (forwardOn)
            {
                im.dialog = 212; //Don't keep forwarding on other sims
                m_msgTransferModule.SendInstantMessages(im, usersToForwardTo);
            }
        }
 /// <summary>
 ///   Add this member to the friend conference
 /// </summary>
 /// <param name = "member"></param>
 /// <param name = "SessionID"></param>
 public void AddMemberToGroup(ChatSessionMember member, UUID SessionID)
 {
     ChatSession session;
     ChatSessions.TryGetValue(SessionID, out session);
     ChatSessionMember oldMember = FindMember(SessionID, member.AvatarKey);
     if ((oldMember == null) || (oldMember.AvatarKey == UUID.Zero))
         session.Members.Add(member);
     else
         oldMember.HasBeenAdded = true; //Reset this
 }
Ejemplo n.º 17
0
        private void MuteUser(UUID sessionid, IEventQueueService eq, UUID AgentID, ChatSessionMember thismember,
                              bool forward)
        {
            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                    {
                        AgentID = thismember.AvatarKey,
                        CanVoiceChat = thismember.CanVoiceChat,
                        IsModerator = thismember.IsModerator,
                        MuteText = thismember.MuteText,
                        MuteVoice = thismember.MuteVoice,
                        Transition = "ENTER"
                    };

            // Send an update to the affected user
            IClientAPI affectedUser = GetActiveClient(thismember.AvatarKey);
            if (affectedUser != null)
                eq.ChatterBoxSessionAgentListUpdates(sessionid, new[] {block}, AgentID, "ENTER",
                                                     affectedUser.Scene.RegionInfo.RegionHandle);
            else if (forward)
                SendMutedUserIM(thismember, sessionid);
        }
 public void AddMemberToGroup(ChatSessionMember chatSessionMember, UUID GroupID)
 {
 }
 public void AddMemberToGroup(ChatSessionMember chatSessionMember, UUID GroupID)
 {
 }
Ejemplo n.º 20
0
        private string OnChatSessionRequest(UUID Agent, OSDMap rm)
        {
            string method = rm["method"].AsString();

            UUID sessionid = UUID.Parse(rm["session-id"].AsString());

            IScenePresence     SP = findScenePresence(Agent);
            IEventQueueService eq = SP.Scene.RequestModuleInterface <IEventQueueService>();

            if (method == "start conference")
            {
                //Create the session.
                CreateSession(new ChatSession
                {
                    Members   = new List <ChatSessionMember>(),
                    SessionID = sessionid,
                    Name      = SP.Name + " Conference"
                });

                OSDArray parameters = (OSDArray)rm["params"];
                //Add other invited members.
                foreach (OSD param in parameters)
                {
                    AddDefaultPermsMemberToSession(param.AsUUID(), sessionid);
                }

                //Add us to the session!
                AddMemberToGroup(new ChatSessionMember
                {
                    AvatarKey    = Agent,
                    CanVoiceChat = true,
                    IsModerator  = true,
                    MuteText     = false,
                    MuteVoice    = false,
                    HasBeenAdded = true
                }, sessionid);


                //Inform us about our room
                ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                    new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                {
                    AgentID      = Agent,
                    CanVoiceChat = true,
                    IsModerator  = true,
                    MuteText     = false,
                    MuteVoice    = false,
                    Transition   = "ENTER"
                };
                eq.ChatterBoxSessionAgentListUpdates(sessionid, new[] { block }, Agent, "ENTER",
                                                     findScene(Agent).RegionInfo.RegionHandle);

                ChatterBoxSessionStartReplyMessage cs = new ChatterBoxSessionStartReplyMessage
                {
                    VoiceEnabled   = true,
                    TempSessionID  = UUID.Random(),
                    Type           = 1,
                    Success        = true,
                    SessionID      = sessionid,
                    SessionName    = SP.Name + " Conference",
                    ModeratedVoice = true
                };

                return(cs.Serialize().ToString());
            }
            else if (method == "accept invitation")
            {
                //They would like added to the group conversation
                List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> Us =
                    new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();
                List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> NotUsAgents =
                    new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();

                ChatSession session = GetSession(sessionid);
                if (session != null)
                {
                    ChatSessionMember thismember = FindMember(sessionid, Agent);
                    //Tell all the other members about the incoming member
                    foreach (ChatSessionMember sessionMember in session.Members)
                    {
                        ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                            new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                        {
                            AgentID      = sessionMember.AvatarKey,
                            CanVoiceChat = sessionMember.CanVoiceChat,
                            IsModerator  = sessionMember.IsModerator,
                            MuteText     = sessionMember.MuteText,
                            MuteVoice    = sessionMember.MuteVoice,
                            Transition   = "ENTER"
                        };
                        if (sessionMember.AvatarKey == thismember.AvatarKey)
                        {
                            Us.Add(block);
                        }
                        else
                        {
                            if (sessionMember.HasBeenAdded)
                            {
                                // Don't add not joined yet agents. They don't want to be here.
                                NotUsAgents.Add(block);
                            }
                        }
                    }
                    thismember.HasBeenAdded = true;
                    foreach (ChatSessionMember member in session.Members)
                    {
                        eq.ChatterBoxSessionAgentListUpdates(session.SessionID,
                                                             member.AvatarKey == thismember.AvatarKey
                                                                 ? NotUsAgents.ToArray()
                                                                 : Us.ToArray(),
                                                             member.AvatarKey, "ENTER",
                                                             findScene(Agent).RegionInfo.RegionHandle);
                    }
                    return("Accepted");
                }
                else
                {
                    return(""); //not this type of session
                }
            }
            else if (method == "mute update")
            {
                //Check if the user is a moderator
                if (!CheckModeratorPermission(Agent, sessionid))
                {
                    return("");
                }

                OSDMap parameters  = (OSDMap)rm["params"];
                UUID   AgentID     = parameters["agent_id"].AsUUID();
                OSDMap muteInfoMap = (OSDMap)parameters["mute_info"];

                ChatSessionMember thismember = FindMember(sessionid, AgentID);
                if (muteInfoMap.ContainsKey("text"))
                {
                    thismember.MuteText = muteInfoMap["text"].AsBoolean();
                }
                if (muteInfoMap.ContainsKey("voice"))
                {
                    thismember.MuteVoice = muteInfoMap["voice"].AsBoolean();
                }

                ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                    new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                {
                    AgentID      = thismember.AvatarKey,
                    CanVoiceChat = thismember.CanVoiceChat,
                    IsModerator  = thismember.IsModerator,
                    MuteText     = thismember.MuteText,
                    MuteVoice    = thismember.MuteVoice,
                    Transition   = "ENTER"
                };

                // Send an update to the affected user
                eq.ChatterBoxSessionAgentListUpdates(sessionid, new[] { block }, AgentID, "",
                                                     findScene(Agent).RegionInfo.RegionHandle);

                return("Accepted");
            }
            else
            {
                MainConsole.Instance.Warn("ChatSessionRequest : " + method);
                return("");
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        ///   Remove the member from this session
        /// </summary>
        /// <param name = "client"></param>
        /// <param name = "im"></param>
        public void DropMemberFromSession(IClientAPI client, GridInstantMessage im, bool forwardOn)
        {
            ChatSession session = m_groupData.GetSession(im.imSessionID);

            if (session == null)
            {
                return;
            }
            ChatSessionMember member = new ChatSessionMember {
                AvatarKey = UUID.Zero
            };

#if (!ISWIN)
            foreach (ChatSessionMember testmember in session.Members)
            {
                if (testmember.AvatarKey == im.fromAgentID)
                {
                    member = testmember;
                }
            }
#else
            foreach (ChatSessionMember testmember in session.Members.Where(testmember => testmember.AvatarKey == im.fromAgentID))
            {
                member = testmember;
            }
#endif

            if (member.AvatarKey != UUID.Zero)
            {
                member.HasBeenAdded = false;
            }

            if (GetMemeberCount(session) == 0)
            {
                m_groupData.RemoveSession(session.SessionID); //Noone is left!
                return;
            }

            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
            {
                AgentID      = member.AvatarKey,
                CanVoiceChat = member.CanVoiceChat,
                IsModerator  = member.IsModerator,
                MuteText     = member.MuteText,
                MuteVoice    = member.MuteVoice,
                Transition   = "LEAVE"
            };
            List <UUID>        usersToForwardTo = new List <UUID>();
            IEventQueueService eq = client.Scene.RequestModuleInterface <IEventQueueService>();
            foreach (ChatSessionMember sessionMember in session.Members)
            {
                IClientAPI user = GetActiveClient(sessionMember.AvatarKey);
                if (user != null)
                {
                    eq.ChatterBoxSessionAgentListUpdates(session.SessionID, new[] { block }, sessionMember.AvatarKey,
                                                         "LEAVE", user.Scene.RegionInfo.RegionHandle);
                }
                else
                {
                    usersToForwardTo.Add(sessionMember.AvatarKey);
                }
            }
            if (forwardOn)
            {
                im.dialog = 212; //Don't keep forwarding on other sims
                m_msgTransferModule.SendInstantMessages(im, usersToForwardTo);
            }
        }
Ejemplo n.º 22
0
        private void ProcessMessageFromGroupSession(GridInstantMessage msg)
        {
            if (m_debugEnabled)
            {
                MainConsole.Instance.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName,
                                                 msg.toAgentID);
            }

            UUID AgentID = msg.toAgentID;
            UUID GroupID = msg.imSessionID;

            switch (msg.dialog)
            {
            case (byte)InstantMessageDialog.SessionAdd:
                ChatSession chatSession = m_groupData.GetSession(msg.imSessionID);
                if (chatSession != null)
                {
                    chatSession.Members.Add(new ChatSessionMember
                    {
                        AvatarKey    = AgentID,
                        CanVoiceChat = false,
                        HasBeenAdded = true,
                        IsModerator  = GetIsModerator(AgentID, GroupID),
                        MuteVoice    = false,
                        MuteText     = false
                    });
                }
                break;

            case (byte)InstantMessageDialog.SessionDrop:
            case 212:
                DropMemberFromSession(GetActiveClient(AgentID), msg, false);
                break;

            case 213:     //Special for muting/unmuting a user
                IClientAPI         client     = GetActiveClient(AgentID);
                IEventQueueService eq         = client.Scene.RequestModuleInterface <IEventQueueService>();
                ChatSessionMember  thismember = m_groupData.FindMember(msg.imSessionID, AgentID);
                if (thismember == null)
                {
                    return;
                }
                string[] brokenMessage = msg.message.Split(',');
                bool     mutedText = false, mutedVoice = false;
                bool.TryParse(brokenMessage[0], out mutedText);
                bool.TryParse(brokenMessage[1], out mutedVoice);
                thismember.MuteText  = mutedText;
                thismember.MuteVoice = mutedVoice;
                MuteUser(msg.imSessionID, eq, AgentID, thismember, false);
                break;

            case (byte)InstantMessageDialog.SessionSend:
                EnsureGroupChatIsStarted(msg.imSessionID);     //Make sure one exists
                ChatSession session = m_groupData.GetSession(msg.imSessionID);
                if (session != null)
                {
                    ChatSessionMember member = m_groupData.FindMember(msg.imSessionID, AgentID);
                    if (member.AvatarKey == AgentID && !member.MuteText)
                    {
                        IClientAPI msgclient = GetActiveClient(msg.toAgentID);
                        if (msgclient != null)
                        {
                            if (!member.HasBeenAdded)
                            {
                                msgclient.Scene.RequestModuleInterface <IEventQueueService>().ChatterboxInvitation(
                                    session.SessionID
                                    , session.Name
                                    , msg.fromAgentID
                                    , msg.message
                                    , member.AvatarKey
                                    , msg.fromAgentName
                                    , msg.dialog
                                    , msg.timestamp
                                    , msg.offline == 1
                                    , (int)msg.ParentEstateID
                                    , msg.Position
                                    , 1
                                    , msg.imSessionID
                                    , true
                                    , Utils.StringToBytes(session.Name)
                                    , msgclient.Scene.RegionInfo.RegionHandle
                                    );
                            }
                            // Deliver locally, directly
                            if (m_debugEnabled)
                            {
                                MainConsole.Instance.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} locally", msgclient.Name);
                            }
                            msgclient.SendInstantMessage(msg);
                        }
                    }
                }
                break;

            default:
                MainConsole.Instance.WarnFormat("[GROUPS-MESSAGING]: I don't know how to proccess a {0} message.",
                                                ((InstantMessageDialog)msg.dialog).ToString());
                break;
            }
        }
Ejemplo n.º 23
0
        private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
        {
            IScenePresence presence;

            if ((presence = remoteClient.Scene.GetScenePresence(remoteClient.AgentId)) == null || presence.IsChildAgent)
            {
                return; //Must exist and not be a child
            }
            if (m_debugEnabled)
            {
                MainConsole.Instance.DebugFormat("[GROUPS-MESSAGING]: {0} called", MethodBase.GetCurrentMethod().Name);

                DebugGridInstantMessage(im);
            }

            // Start group IM session
            if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
            {
                if (m_debugEnabled)
                {
                    MainConsole.Instance.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID);
                }

                UUID GroupID = im.imSessionID;
                UUID AgentID = im.fromAgentID;

                GroupRecord groupInfo = m_groupData.GetGroupRecord(AgentID, GroupID, null);

                if (groupInfo != null)
                {
                    if (!m_groupsModule.GroupPermissionCheck(AgentID, GroupID, GroupPowers.JoinChat))
                    {
                        return; //They have to be able to join to create a group chat
                    }
                    //Create the session.
                    IEventQueueService queue = remoteClient.Scene.RequestModuleInterface <IEventQueueService>();
                    if (m_groupData.CreateSession(new ChatSession
                    {
                        Members = new List <ChatSessionMember>(),
                        SessionID = GroupID,
                        Name = groupInfo.GroupName
                    }))
                    {
                        m_groupData.AddMemberToGroup(new ChatSessionMember
                        {
                            AvatarKey    = AgentID,
                            CanVoiceChat = false,
                            IsModerator  = GetIsModerator(AgentID, GroupID),
                            MuteText     = false,
                            MuteVoice    = false,
                            HasBeenAdded = true
                        }, GroupID);

#if (!ISWIN)
                        foreach (GroupMembersData gmd in m_groupData.GetGroupMembers(AgentID, GroupID))
                        {
                            if (gmd.AgentID != AgentID)
                            {
                                if ((gmd.AgentPowers & (ulong)GroupPowers.JoinChat) == (ulong)GroupPowers.JoinChat)
                                {
                                    m_groupData.AddMemberToGroup(new ChatSessionMember
                                    {
                                        AvatarKey    = gmd.AgentID,
                                        CanVoiceChat = false,
                                        IsModerator  =
                                            GetIsModerator(gmd.AgentID, GroupID),
                                        MuteText     = false,
                                        MuteVoice    = false,
                                        HasBeenAdded = false
                                    }, GroupID);
                                }
                            }
                        }
#else
                        foreach (GroupMembersData gmd in m_groupData.GetGroupMembers(AgentID, GroupID).Where(gmd => gmd.AgentID != AgentID).Where(gmd => (gmd.AgentPowers & (ulong)GroupPowers.JoinChat) == (ulong)GroupPowers.JoinChat))
                        {
                            m_groupData.AddMemberToGroup(new ChatSessionMember
                            {
                                AvatarKey    = gmd.AgentID,
                                CanVoiceChat = false,
                                IsModerator  =
                                    GetIsModerator(gmd.AgentID, GroupID),
                                MuteText     = false,
                                MuteVoice    = false,
                                HasBeenAdded = false
                            }, GroupID);
                        }
#endif
                        //Tell us that it was made successfully
                        ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
                    }
                    else
                    {
                        ChatSession thisSession = m_groupData.GetSession(GroupID);
                        //A session already exists
                        //Add us
                        m_groupData.AddMemberToGroup(new ChatSessionMember
                        {
                            AvatarKey    = AgentID,
                            CanVoiceChat = false,
                            IsModerator  = GetIsModerator(AgentID, GroupID),
                            MuteText     = false,
                            MuteVoice    = false,
                            HasBeenAdded = true
                        }, GroupID);

                        //Tell us that we entered successfully
                        ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
                        List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> Us =
                            new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();
                        List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> NotUsAgents =
                            new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();

                        foreach (ChatSessionMember sessionMember in thisSession.Members)
                        {
                            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                            {
                                AgentID      = sessionMember.AvatarKey,
                                CanVoiceChat = sessionMember.CanVoiceChat,
                                IsModerator  = sessionMember.IsModerator,
                                MuteText     = sessionMember.MuteText,
                                MuteVoice    = sessionMember.MuteVoice,
                                Transition   = "ENTER"
                            };
                            if (AgentID == sessionMember.AvatarKey)
                            {
                                Us.Add(block);
                            }
                            if (sessionMember.HasBeenAdded)
                            {
                                // Don't add not joined yet agents. They don't want to be here.
                                NotUsAgents.Add(block);
                            }
                        }
                        foreach (ChatSessionMember member in thisSession.Members)
                        {
                            if (member.AvatarKey == AgentID)
                            {
                                //Tell 'us' about all the other agents in the group
                                queue.ChatterBoxSessionAgentListUpdates(GroupID, NotUsAgents.ToArray(), member.AvatarKey,
                                                                        "ENTER",
                                                                        remoteClient.Scene.RegionInfo.RegionHandle);
                            }
                            else
                            {
                                //Tell 'other' agents about the new agent ('us')
                                IClientAPI otherAgent = GetActiveClient(member.AvatarKey);
                                if (otherAgent != null) //Local, so we can send it directly
                                {
                                    queue.ChatterBoxSessionAgentListUpdates(GroupID, Us.ToArray(), member.AvatarKey,
                                                                            "ENTER",
                                                                            otherAgent.Scene.RegionInfo.RegionHandle);
                                }
                                else
                                {
                                    ISyncMessagePosterService amps =
                                        m_sceneList[0].RequestModuleInterface <ISyncMessagePosterService>();
                                    if (amps != null)
                                    {
                                        OSDMap message = new OSDMap();
                                        message["Method"]  = "GroupSessionAgentUpdate";
                                        message["AgentID"] = AgentID;
                                        message["Message"] = ChatterBoxSessionAgentListUpdates(GroupID, Us.ToArray(),
                                                                                               "ENTER");
                                        amps.Post(message, remoteClient.Scene.RegionInfo.RegionHandle);
                                    }
                                }
                            }
                        }
                    }

                    //Tell us that we entered
                    ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock ourblock =
                        new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                    {
                        AgentID      = AgentID,
                        CanVoiceChat = true,
                        IsModerator  = true,
                        MuteText     = false,
                        MuteVoice    = false,
                        Transition   = "ENTER"
                    };
                    queue.ChatterBoxSessionAgentListUpdates(GroupID, new[] { ourblock }, AgentID, "ENTER",
                                                            remoteClient.Scene.RegionInfo.RegionHandle);
                }
            }
            // Send a message from locally connected client to a group
            else if ((im.dialog == (byte)InstantMessageDialog.SessionSend) && im.message != "")
            {
                UUID GroupID = im.imSessionID;
                UUID AgentID = im.fromAgentID;

                if (m_debugEnabled)
                {
                    MainConsole.Instance.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}",
                                                     GroupID, im.imSessionID.ToString());
                }

                ChatSessionMember memeber = m_groupData.FindMember(im.imSessionID, AgentID);
                if (memeber == null || memeber.MuteText)
                {
                    return; //Not in the chat or muted
                }
                SendMessageToGroup(im, GroupID);
            }
            else if (im.dialog == (byte)InstantMessageDialog.SessionDrop)
            {
                DropMemberFromSession(remoteClient, im, true);
            }
            else if (im.dialog == 212) //Forwarded sessionDrop
            {
                DropMemberFromSession(remoteClient, im, false);
            }
        }
Ejemplo n.º 24
0
        private string OnChatSessionRequest(UUID Agent, OSDMap rm)
        {
            string method = rm["method"].AsString();

            UUID sessionid = UUID.Parse(rm["session-id"].AsString());

            IClientAPI         SP = GetActiveClient(Agent);
            IEventQueueService eq = SP.Scene.RequestModuleInterface <IEventQueueService>();

            if (method == "accept invitation")
            {
                //They would like added to the group conversation
                List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> Us =
                    new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();
                List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> NotUsAgents =
                    new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();

                ChatSession session = m_groupData.GetSession(sessionid);
                if (session != null)
                {
                    ChatSessionMember thismember = m_groupData.FindMember(sessionid, Agent);
                    if (thismember == null)
                    {
                        return(""); //No user with that session
                    }
                    //Tell all the other members about the incoming member
                    thismember.HasBeenAdded = true;
                    foreach (ChatSessionMember sessionMember in session.Members)
                    {
                        ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                            new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                        {
                            AgentID      = sessionMember.AvatarKey,
                            CanVoiceChat = sessionMember.CanVoiceChat,
                            IsModerator  = sessionMember.IsModerator,
                            MuteText     = sessionMember.MuteText,
                            MuteVoice    = sessionMember.MuteVoice,
                            Transition   = "ENTER"
                        };
                        if (Agent == sessionMember.AvatarKey)
                        {
                            Us.Add(block);
                        }
                        if (sessionMember.HasBeenAdded) // Don't add not joined yet agents. They don't want to be here.
                        {
                            NotUsAgents.Add(block);
                        }
                    }
                    foreach (ChatSessionMember member in session.Members)
                    {
                        if (member.AvatarKey == thismember.AvatarKey)
                        {
                            //Tell 'us' about all the other agents in the group
                            eq.ChatterBoxSessionAgentListUpdates(session.SessionID, NotUsAgents.ToArray(),
                                                                 member.AvatarKey, "ENTER",
                                                                 SP.Scene.RegionInfo.RegionHandle);
                        }
                        else
                        {
                            //Tell 'other' agents about the new agent ('us')
                            IClientAPI otherAgent = GetActiveClient(member.AvatarKey);
                            if (otherAgent != null) //Local, so we can send it directly
                            {
                                eq.ChatterBoxSessionAgentListUpdates(session.SessionID, Us.ToArray(), member.AvatarKey,
                                                                     "ENTER", otherAgent.Scene.RegionInfo.RegionHandle);
                            }
                            else
                            {
                                ISyncMessagePosterService amps =
                                    m_sceneList[0].RequestModuleInterface <ISyncMessagePosterService>();
                                if (amps != null)
                                {
                                    OSDMap message = new OSDMap();
                                    message["Method"]  = "GroupSessionAgentUpdate";
                                    message["AgentID"] = thismember.AvatarKey;
                                    message["Message"] = ChatterBoxSessionAgentListUpdates(session.SessionID,
                                                                                           Us.ToArray(), "ENTER");
                                    amps.Post(message, SP.Scene.RegionInfo.RegionHandle);
                                }
                            }
                        }
                    }
                    return("Accepted");
                }
                else
                {
                    return(""); //not this type of session
                }
            }
            else if (method == "mute update")
            {
                //Check if the user is a moderator
                if (!GetIsModerator(Agent, sessionid))
                {
                    return("");
                }

                OSDMap parameters  = (OSDMap)rm["params"];
                UUID   AgentID     = parameters["agent_id"].AsUUID();
                OSDMap muteInfoMap = (OSDMap)parameters["mute_info"];

                ChatSessionMember thismember = m_groupData.FindMember(sessionid, AgentID);
                if (muteInfoMap.ContainsKey("text"))
                {
                    thismember.MuteText = muteInfoMap["text"].AsBoolean();
                }
                if (muteInfoMap.ContainsKey("voice"))
                {
                    thismember.MuteVoice = muteInfoMap["voice"].AsBoolean();
                }
                MuteUser(sessionid, eq, AgentID, thismember, true);

                return("Accepted");
            }
            else
            {
                MainConsole.Instance.Warn("ChatSessionRequest : " + method);
                return("");
            }
        }