private void ProcessMessageFromGroupSession(GridInstantMessage msg)
        {
            if (m_debugEnabled)
            {
                m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID);
            }

            UUID AgentID = new UUID(msg.fromAgentID);
            UUID GroupID = new UUID(msg.imSessionID);

            switch (msg.dialog)
            {
            case (byte)InstantMessageDialog.SessionAdd:
                m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
                break;

            case (byte)InstantMessageDialog.SessionDrop:
                m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID);
                break;

            case (byte)InstantMessageDialog.SessionSend:
                if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID) &&
                    !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID)
                    )
                {
                    // Agent not in session and hasn't dropped from session
                    // Add them to the session for now, and Invite them
                    m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);

                    UUID       toAgentID    = new UUID(msg.toAgentID);
                    IClientAPI activeClient = GetActiveClient(toAgentID);
                    if (activeClient != null)
                    {
                        GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
                        if (groupInfo != null)
                        {
                            if (m_debugEnabled)
                            {
                                m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
                            }

                            // Force? open the group session dialog???
                            // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
                            IEventQueue eq = activeClient.Scene.RequestModuleInterface <IEventQueue>();
                            eq.ChatterboxInvitation(
                                GroupID
                                , groupInfo.GroupName
                                , new UUID(msg.fromAgentID)
                                , msg.message
                                , new UUID(msg.toAgentID)
                                , msg.fromAgentName
                                , msg.dialog
                                , msg.timestamp
                                , msg.offline == 1
                                , (int)msg.ParentEstateID
                                , msg.Position
                                , 1
                                , new UUID(msg.imSessionID)
                                , msg.fromGroup
                                , Utils.StringToBytes(groupInfo.GroupName)
                                );

                            eq.ChatterBoxSessionAgentListUpdates(
                                new UUID(GroupID)
                                , new UUID(msg.fromAgentID)
                                , new UUID(msg.toAgentID)
                                , false     //canVoiceChat
                                , false     //isModerator
                                , false     //text mute
                                );
                        }
                    }
                }
                else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID))
                {
                    // User hasn't dropped, so they're in the session,
                    // maybe we should deliver it.
                    IClientAPI client = GetActiveClient(new UUID(msg.toAgentID));
                    if (client != null)
                    {
                        // Deliver locally, directly
                        if (m_debugEnabled)
                        {
                            m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} locally", client.Name);
                        }
                        client.SendInstantMessage(msg);
                    }
                    else
                    {
                        m_log.WarnFormat("[GROUPS-MESSAGING]: Received a message over the grid for a client that isn't here: {0}", msg.toAgentID);
                    }
                }
                break;

            default:
                m_log.WarnFormat("[GROUPS-MESSAGING]: I don't know how to proccess a {0} message.", ((InstantMessageDialog)msg.dialog).ToString());
                break;
            }
        }
예제 #2
0
        private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client)
        {
            if (m_debugEnabled)
            {
                m_log.DebugFormat(
                    "[GROUPS-MESSAGING]: Session message from {0} going to agent {1}, sessionID {2}, type {3}",
                    msg.fromAgentName, msg.toAgentID, msg.imSessionID, (InstantMessageDialog)msg.dialog);
            }

            UUID        fromAgentID = new UUID(msg.fromAgentID);
            UUID        GroupID     = new UUID(msg.imSessionID);
            IEventQueue eq          = client.Scene.RequestModuleInterface <IEventQueue>();

            switch (msg.dialog)
            {
            case (byte)InstantMessageDialog.SessionAdd:
                m_groupData.AgentInvitedToGroupChatSession(fromAgentID, GroupID);
                if (eq != null)
                {
                    eq.ChatterBoxSessionAgentListUpdates(
                        GroupID
                        , fromAgentID
                        , client.AgentId
                        , false    //canVoiceChat
                        , false    //isModerator
                        , false    //text mute
                        , true     // enter
                        );
                }
                break;

            case (byte)InstantMessageDialog.SessionDrop:
                m_groupData.AgentDroppedFromGroupChatSession(fromAgentID, GroupID);
                if (eq != null)
                {
                    eq.ChatterBoxSessionAgentListUpdates(
                        GroupID
                        , fromAgentID
                        , client.AgentId
                        , false         //canVoiceChat
                        , false         //isModerator
                        , false         //text mute
                        , false         // leave
                        );
                }
                break;

            case (byte)InstantMessageDialog.SessionSend:
                if (!m_groupData.hasAgentDroppedGroupChatSession(client.AgentId, GroupID))
                {
                    if (!m_groupData.hasAgentBeenInvitedToGroupChatSession(client.AgentId, GroupID))
                    {
                        GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
                        if (groupInfo != null)
                        {
                            if (m_debugEnabled)
                            {
                                m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
                            }

                            if (eq != null)
                            {
                                eq.ChatterboxInvitation(
                                    GroupID
                                    , groupInfo.GroupName
                                    , fromAgentID
                                    , msg.message
                                    , client.AgentId
                                    , msg.fromAgentName
                                    , msg.dialog
                                    , msg.timestamp
                                    , msg.offline == 1
                                    , (int)msg.ParentEstateID
                                    , msg.Position
                                    , 1
                                    , new UUID(msg.imSessionID)
                                    , msg.fromGroup
                                    , Utils.StringToBytes(groupInfo.GroupName)
                                    );
                            }
                        }
                    }
                    else
                    {
                        client.SendInstantMessage(msg);
                    }

//                        if (!m_groupData.hasAgentBeenInvitedToGroupChatSession(fromAgentID, GroupID))
                    {
                        m_groupData.AgentInvitedToGroupChatSession(fromAgentID, GroupID);
                        eq.ChatterBoxSessionAgentListUpdates(
                            GroupID
                            , fromAgentID
                            , client.AgentId
                            , false        //canVoiceChat
                            , false        //isModerator
                            , false        //text mute
                            , true         // enter
                            );
                    }
                }
                break;

            default:
                client.SendInstantMessage(msg);
                break;;
            }
        }