Serialize() public method

Serialize the object
public Serialize ( ) : OSDMap
return OSDMap
コード例 #1
0
        public string ChatSessionRequest(IRegionClientCapsService caps, OSDMap req)
        {
            string method = req["method"].AsString();

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

            switch (method)
            {
                case "start conference":
                    {
                        if (SessionExists(sessionid))
                            return ""; //No duplicate sessions
                        //Create the session.
                        CreateSession(new ChatSession
                                          {
                                              Members = new List<ChatSessionMember>(),
                                              SessionID = sessionid,
                                              Name = caps.ClientCaps.AccountInfo.Name + " Conference"
                                          });

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

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

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

                        ChatterBoxSessionStartReplyMessage cs = new ChatterBoxSessionStartReplyMessage
                                                                    {
                                                                        VoiceEnabled = true,
                                                                        TempSessionID = sessionid,
                                                                        Type = 1,
                                                                        Success = true,
                                                                        SessionID = sessionid,
                                                                        SessionName =
                                                                            caps.ClientCaps.AccountInfo.Name +
                                                                            " Conference",
                                                                        ModeratedVoice = true
                                                                    };
                        return OSDParser.SerializeLLSDXmlString(cs.Serialize());
                    }
                case "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, caps.AgentID);
                            //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);
                                    NotUsAgents.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)
                            {
                                if (member.HasBeenAdded) //Only send to those in the group
                                {
                                    UUID regionID = FindRegionID(member.AvatarKey);
                                    if (regionID != UUID.Zero)
                                    {
                                        m_eventQueueService.ChatterBoxSessionAgentListUpdates(session.SessionID,
                                                                                              member.AvatarKey ==
                                                                                              thismember.AvatarKey
                                                                                                  ? NotUsAgents.ToArray()
                                                                                                  : Us.ToArray(),
                                                                                              member.AvatarKey, "ENTER",
                                                                                              regionID);
                                    }
                                }
                            }
                            return "Accepted";
                        }
                        else
                            return ""; //no session exists?
                    }
                case "mute update":
                    {
                        //Check if the user is a moderator
                        if (!CheckModeratorPermission(caps.AgentID, sessionid))
                            return "";

                        OSDMap parameters = (OSDMap) req["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"
                                };

                        ChatSession session = GetSession(sessionid);
                        // Send an update to all users so that they show the correct permissions
                        foreach (ChatSessionMember member in session.Members)
                        {
                            if (member.HasBeenAdded) //Only send to those in the group
                            {
                                UUID regionID = FindRegionID(member.AvatarKey);
                                if (regionID != UUID.Zero)
                                {
                                    m_eventQueueService.ChatterBoxSessionAgentListUpdates(sessionid, new[] {block},
                                                                                          member.AvatarKey, "",
                                                                                          regionID);
                                }
                            }
                        }

                        return "Accepted";
                    }
                case "call":
                    {
                        //Implement voice chat for conferences...

                        IVoiceService voiceService = m_registry.RequestModuleInterface<IVoiceService>();
                        if (voiceService == null)
                            return "";

                        OSDMap resp = voiceService.GroupConferenceCallRequest(caps, sessionid);
                        return OSDParser.SerializeLLSDXmlString(resp);
                    }
                default:
                    MainConsole.Instance.Warn("ChatSessionRequest : " + method);
                    return "";
            }
        }
コード例 #2
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
                Hashtable responsedata = new Hashtable();
                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 "";
            }
        }
コード例 #3
0
        public void ChatterBoxSessionStartReplyMessage()
        {
            ChatterBoxSessionStartReplyMessage s = new ChatterBoxSessionStartReplyMessage();
            s.ModeratedVoice = true;
            s.SessionID = UUID.Random();
            s.SessionName = "Test Session";
            s.Success = true;
            s.TempSessionID = UUID.Random();
            s.Type = 1;
            s.VoiceEnabled = true;

            OSDMap map = s.Serialize();

            ChatterBoxSessionStartReplyMessage t = new ChatterBoxSessionStartReplyMessage();
            t.Deserialize(map);

            Assert.AreEqual(s.ModeratedVoice, t.ModeratedVoice);
            Assert.AreEqual(s.SessionID, t.SessionID);
            Assert.AreEqual(s.SessionName, t.SessionName);
            Assert.AreEqual(s.Success, t.Success);
            Assert.AreEqual(s.TempSessionID, t.TempSessionID);
            Assert.AreEqual(s.Type, t.Type);
            Assert.AreEqual(s.VoiceEnabled, t.VoiceEnabled);
        }