コード例 #1
0
        protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, ulong regionhandle)
        {
            OSDMap args = RegionClient.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            UUID userID = UUID.Zero, itemID = UUID.Zero;

            if (args["userid"] != null)
            {
                userID = args["userid"].AsUUID();
            }
            if (args["itemid"] != null)
            {
                itemID = args["itemid"].AsUUID();
            }

            //UUID regionID = m_localBackend.GetRegionID(regionhandle);

            // This is the meaning of PUT object
            bool result = m_localBackend.SendCreateObject(regionhandle, userID, itemID);

            responsedata["int_response_code"]   = 200;
            responsedata["str_response_string"] = result.ToString();
        }
コード例 #2
0
        protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle)
        {
            OSDMap args = RegionClient.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            string sogXmlStr = "", extraStr = "", stateXmlStr = "";

            if (args["sog"] != null)
            {
                sogXmlStr = args["sog"].AsString();
            }
            if (args["extra"] != null)
            {
                extraStr = args["extra"].AsString();
            }

            UUID             regionID = m_localBackend.GetRegionID(regionhandle);
            SceneObjectGroup sog      = null;

            try
            {
                sog = SceneObjectSerializer.FromXml2Format(sogXmlStr);
                sog.ExtraFromXmlString(extraStr);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[REST COMMS]: exception on deserializing scene object {0}", ex.Message);
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            if ((args["state"] != null) && m_aScene.m_allowScriptCrossings)
            {
                stateXmlStr = args["state"].AsString();
                if (stateXmlStr != "")
                {
                    try
                    {
                        sog.SetState(stateXmlStr, regionID);
                    }
                    catch (Exception ex)
                    {
                        m_log.InfoFormat("[REST COMMS]: exception on setting state for scene object {0}", ex.Message);
                    }
                }
            }
            // This is the meaning of POST object
            bool result = m_localBackend.SendCreateObject(regionhandle, sog, false);

            responsedata["int_response_code"]   = 200;
            responsedata["str_response_string"] = result.ToString();
        }
コード例 #3
0
        protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
        {
            OSDMap args = RegionClient.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            // retrieve the regionhandle
            ulong regionhandle = 0;
            bool  authorize    = false;

            if (args.ContainsKey("destination_handle"))
            {
                UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
            }
            if (args.ContainsKey("authorize_user")) // not implemented on the sending side yet
            {
                bool.TryParse(args["authorize_user"].AsString(), out authorize);
            }

            AgentCircuitData aCircuit = new AgentCircuitData();

            try
            {
                aCircuit.UnpackAgentCircuitData(args);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildCreate message {0}", ex.Message);
                return;
            }

            OSDMap resp   = new OSDMap(2);
            string reason = String.Empty;

            // This is the meaning of POST agent
            bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit, authorize, out reason);

            resp["reason"]  = OSD.FromString(reason);
            resp["success"] = OSD.FromBoolean(result);

            // TODO: add reason if not String.Empty?
            responsedata["int_response_code"]   = 200;
            responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
        }
コード例 #4
0
        protected virtual void DoRegionPost(Hashtable request, Hashtable responsedata, UUID id)
        {
            OSDMap args = RegionClient.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            // retrieve the regionhandle
            ulong regionhandle = 0;

            if (args["destination_handle"] != null)
            {
                UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
            }

            RegionInfo aRegion = new RegionInfo();

            try
            {
                aRegion.UnpackRegionInfoData(args);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[REST COMMS]: exception on unpacking HelloNeighbour message {0}", ex.Message);
                return;
            }

            // This is the meaning of POST region
            bool result = m_localBackend.SendHelloNeighbour(regionhandle, aRegion);

            responsedata["int_response_code"]   = 200;
            responsedata["str_response_string"] = result.ToString();
        }
コード例 #5
0
        protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata)
        {
            OSDMap args = RegionClient.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            // retrieve the regionhandle
            ulong regionhandle = 0;

            if (args["destination_handle"] != null)
            {
                UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
            }

            string messageType;

            if (args["message_type"] != null)
            {
                messageType = args["message_type"].AsString();
            }
            else
            {
                m_log.Warn("[REST COMMS]: Agent Put Message Type not found. ");
                messageType = "AgentData";
            }

            bool result = true;

            if ("AgentData".Equals(messageType))
            {
                AgentData agent = new AgentData();
                try
                {
                    agent.Unpack(args);
                }
                catch (Exception ex)
                {
                    m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
                    return;
                }

                //agent.Dump();
                // This is one of the meanings of PUT agent
                result = m_localBackend.SendChildAgentUpdate(regionhandle, agent);
            }
            else if ("AgentPosition".Equals(messageType))
            {
                AgentPosition agent = new AgentPosition();
                try
                {
                    agent.Unpack(args);
                }
                catch (Exception ex)
                {
                    m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
                    return;
                }
                //agent.Dump();
                // This is one of the meanings of PUT agent
                result = m_localBackend.SendChildAgentUpdate(regionhandle, agent);
            }

            responsedata["int_response_code"]   = 200;
            responsedata["str_response_string"] = result.ToString();
        }
コード例 #6
0
        protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
        {
            if (m_safemode)
            {
                // Authentication
                string authority = string.Empty;
                string authToken = string.Empty;
                if (!GetAuthentication(request, out authority, out authToken))
                {
                    m_log.InfoFormat("[REST COMMS]: Authentication failed for agent message {0}", request["uri"]);
                    responsedata["int_response_code"]   = 403;
                    responsedata["str_response_string"] = "Forbidden";
                    return;
                }
                if (!VerifyKey(id, authority, authToken))
                {
                    m_log.InfoFormat("[REST COMMS]: Authentication failed for agent message {0}", request["uri"]);
                    responsedata["int_response_code"]   = 403;
                    responsedata["str_response_string"] = "Forbidden";
                    return;
                }
                m_log.DebugFormat("[REST COMMS]: Authentication succeeded for {0}", id);
            }

            OSDMap args = RegionClient.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            // retrieve the regionhandle
            ulong regionhandle = 0;

            if (args["destination_handle"] != null)
            {
                UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
            }

            AgentCircuitData aCircuit = new AgentCircuitData();

            try
            {
                aCircuit.UnpackAgentCircuitData(args);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildCreate message {0}", ex.Message);
                return;
            }

            OSDMap resp   = new OSDMap(2);
            string reason = String.Empty;

            // This is the meaning of POST agent
            m_regionClient.AdjustUserInformation(aCircuit);
            bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit, out reason);

            resp["reason"]  = OSD.FromString(reason);
            resp["success"] = OSD.FromBoolean(result);

            // TODO: add reason if not String.Empty?
            responsedata["int_response_code"]   = 200;
            responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
        }
コード例 #7
0
        protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle)
        {
            OSDMap args = RegionClient.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            Vector3 pos = Vector3.Zero;
            string  sogXmlStr = String.Empty, extraStr = String.Empty, stateXmlStr = String.Empty;

            if (args.ContainsKey("sog"))
            {
                sogXmlStr = args["sog"].AsString();
            }
            if (args.ContainsKey("extra"))
            {
                extraStr = args["extra"].AsString();
            }
            if (args.ContainsKey("pos"))
            {
                pos = args["pos"].AsVector3();
            }

            UUID             regionID = m_localBackend.GetRegionID(regionhandle);
            SceneObjectGroup sog      = null;

            try
            {
                sog = SceneObjectSerializer.FromXml2Format(sogXmlStr);
                sog.ExtraFromXmlString(extraStr);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[REST COMMS]: exception on deserializing scene object {0}", ex.Message);
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            if (args.ContainsKey("pos"))
            {
                sog.AbsolutePosition = pos;
            }

            if (args.ContainsKey("avatars"))
            {
                sog.AvatarsToExpect = args["avatars"].AsInteger();
            }

            if ((args.ContainsKey("state")) && m_aScene.m_allowScriptCrossings)
            {
                stateXmlStr = args["state"].AsString();
                if (!String.IsNullOrEmpty(stateXmlStr))
                {
                    try
                    {
                        sog.SetState(stateXmlStr, regionID);
                    }
                    catch (Exception ex)
                    {
                        m_log.InfoFormat("[REST COMMS]: exception on setting state for scene object {0}", ex.Message);
                    }
                }
            }
            // This is the meaning of POST object
            bool result = m_localBackend.SendCreateObject(regionhandle, sog, null, false, pos, args["pos"] == null);

            responsedata["int_response_code"]   = 200;
            responsedata["str_response_string"] = result.ToString();
        }