protected override void UnpackData(OSDMap args, AgentDestinationData d, Hashtable request)
        {
            base.UnpackData(args, d, request);
            ExtendedAgentDestinationData data = (ExtendedAgentDestinationData)d;
            try
            {
                if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null)
                    data.host = args["gatekeeper_host"].AsString();
                if (args.ContainsKey("gatekeeper_port") && args["gatekeeper_port"] != null)
                    Int32.TryParse(args["gatekeeper_port"].AsString(), out data.port);
                if (args.ContainsKey("gatekeeper_serveruri") && args["gatekeeper_serveruri"] != null)
                    data.gatekeeperServerURI = args["gatekeeper_serveruri"];
                if (args.ContainsKey("destination_serveruri") && args["destination_serveruri"] != null)
                    data.destinationServerURI = args["destination_serveruri"];

            }
            catch (InvalidCastException)
            {
                m_log.ErrorFormat("[HOME AGENT HANDLER]: Bad cast in UnpackData");
            }

            string callerIP = GetCallerIP(request);
            // Verify if this call came from the login server
            if (callerIP == m_LoginServerIP)
                data.fromLogin = true;

        }
 protected virtual void UnpackData(OSDMap args, AgentDestinationData data, Hashtable request)
 {
     // retrieve the input arguments
     if (args.ContainsKey("destination_x") && args["destination_x"] != null)
     {
         Int32.TryParse(args["destination_x"].AsString(), out data.x);
     }
     else
     {
         m_log.WarnFormat("  -- request didn't have destination_x");
     }
     if (args.ContainsKey("destination_y") && args["destination_y"] != null)
     {
         Int32.TryParse(args["destination_y"].AsString(), out data.y);
     }
     else
     {
         m_log.WarnFormat("  -- request didn't have destination_y");
     }
     if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
     {
         UUID.TryParse(args["destination_uuid"].AsString(), out data.uuid);
     }
     if (args.ContainsKey("destination_name") && args["destination_name"] != null)
     {
         data.name = args["destination_name"].ToString();
     }
     if (args.ContainsKey("teleport_flags") && args["teleport_flags"] != null)
     {
         data.flags = args["teleport_flags"].AsUInteger();
     }
 }
Beispiel #3
0
        protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
        {
            m_log.InfoFormat("[AGENTPOST]; DoAgentPost for {0} ", id);

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

            if (args == null)
            {
                responsedata["int_response_code"]   = HttpStatusCode.BadRequest;
                responsedata["str_response_string"] = "Bad request";
                return;
            }

            AgentDestinationData data = CreateAgentDestinationData();

            UnpackData(args, data, request);

            GridRegion destination = new GridRegion();

            destination.RegionID   = data.uuid;
            destination.RegionLocX = data.x;
            destination.RegionLocY = data.y;
            destination.RegionName = data.name;

            GridRegion gatekeeper = ExtractGatekeeper(data);

            AgentCircuitData aCircuit = new AgentCircuitData();

            try
            {
                aCircuit.UnpackAgentCircuitData(args);
            }
            catch (Exception ex)
            {
                m_log.ErrorFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message);
                responsedata["int_response_code"]   = HttpStatusCode.BadRequest;
                responsedata["str_response_string"] = "Bad request";
                return;
            }

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

            // This is the meaning of POST agent
            //m_regionClient.AdjustUserInformation(aCircuit);
            //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason);
            bool result = CreateAgent(gatekeeper, destination, aCircuit, data.flags, data.fromLogin, out reason);

            resp["reason"]  = OSD.FromString(reason);
            resp["success"] = OSD.FromBoolean(result);
            // Let's also send out the IP address of the caller back to the caller (HG 1.5)
            resp["your_ip"] = OSD.FromString(GetCallerIP(request));

            // TODO: add reason if not String.Empty?
            responsedata["int_response_code"]   = HttpStatusCode.OK;
            responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
        }
Beispiel #4
0
        protected virtual void UnpackData(OSDMap args, AgentDestinationData data)
        {
            OSD tmpOSD;

            // retrieve the input arguments
            if (args.TryGetValue("destination_x", out tmpOSD) && tmpOSD != null)
            {
                Int32.TryParse(tmpOSD.AsString(), out data.x);
            }
            else
            {
                m_log.WarnFormat("  -- request didn't have destination_x");
            }

            if (args.TryGetValue("destination_y", out tmpOSD) && tmpOSD != null)
            {
                Int32.TryParse(tmpOSD.AsString(), out data.y);
            }
            else
            {
                m_log.WarnFormat("  -- request didn't have destination_y");
            }

            if (args.TryGetValue("destination_uuid", out tmpOSD) && tmpOSD != null)
            {
                UUID.TryParse(tmpOSD.AsString(), out data.uuid);
            }

            if (args.TryGetValue("destination_name", out tmpOSD) && tmpOSD != null)
            {
                data.name = tmpOSD.ToString();
            }

            if (args.TryGetValue("teleport_flags", out tmpOSD) && tmpOSD != null)
            {
                data.flags = tmpOSD.AsUInteger();
            }
        }
 protected virtual GridRegion ExtractGatekeeper(AgentDestinationData data)
 {
     return(null);
 }
Beispiel #6
0
        protected void DoAgentPost(OSDMap args, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID)
        {
            OSD tmpOSD;
            EntityTransferContext ctx = new EntityTransferContext();

            if (args.TryGetValue("context", out tmpOSD) && tmpOSD is OSDMap)
            {
                ctx.Unpack((OSDMap)tmpOSD);
            }

            AgentDestinationData data = CreateAgentDestinationData();

            UnpackData(args, data);

            GridRegion destination = new GridRegion();

            destination.RegionID   = data.uuid;
            destination.RegionLocX = data.x;
            destination.RegionLocY = data.y;
            destination.RegionName = data.name;

            GridRegion gatekeeper = ExtractGatekeeper(data);

            AgentCircuitData aCircuit = new AgentCircuitData();

            try
            {
                aCircuit.UnpackAgentCircuitData(args);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message);
                httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
                httpResponse.RawBuffer  = Util.UTF8.GetBytes("false");
                return;
            }

            GridRegion source = null;

            if (args.TryGetValue("source_uuid", out tmpOSD))
            {
                source            = new GridRegion();
                source.RegionID   = UUID.Parse(tmpOSD.AsString());
                source.RegionLocX = Int32.Parse(args["source_x"].AsString());
                source.RegionLocY = Int32.Parse(args["source_y"].AsString());
                source.RegionName = args["source_name"].AsString();

                if (args.TryGetValue("source_server_uri", out tmpOSD))
                {
                    source.RawServerURI = tmpOSD.AsString();
                }
                else
                {
                    source.RawServerURI = null;
                }
            }

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

            bool result = CreateAgent(source, gatekeeper, destination, aCircuit, data.flags, data.fromLogin, ctx, out reason);

            resp["reason"]  = OSD.FromString(reason);
            resp["success"] = OSD.FromBoolean(result);
            // Let's also send out the IP address of the caller back to the caller (HG 1.5)
            resp["your_ip"] = OSD.FromString(httpRequest.RemoteIPEndPoint.Address.ToString());

            httpResponse.StatusCode = (int)HttpStatusCode.OK;
            httpResponse.RawBuffer  = Util.UTF8.GetBytes(OSDParser.SerializeJsonString(resp));
        }
 protected virtual GridRegion ExtractGatekeeper(AgentDestinationData data)
 {
     return null;
 }
 protected virtual void UnpackData(OSDMap args, AgentDestinationData data, Hashtable request)
 {
     // retrieve the input arguments
     if (args.ContainsKey("destination_x") && args["destination_x"] != null)
         Int32.TryParse(args["destination_x"].AsString(), out data.x);
     else
         m_log.WarnFormat("  -- request didn't have destination_x");
     if (args.ContainsKey("destination_y") && args["destination_y"] != null)
         Int32.TryParse(args["destination_y"].AsString(), out data.y);
     else
         m_log.WarnFormat("  -- request didn't have destination_y");
     if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
         UUID.TryParse(args["destination_uuid"].AsString(), out data.uuid);
     if (args.ContainsKey("destination_name") && args["destination_name"] != null)
         data.name = args["destination_name"].ToString();
     if (args.ContainsKey("teleport_flags") && args["teleport_flags"] != null)
         data.flags = args["teleport_flags"].AsUInteger();
 }
Beispiel #9
0
        protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
        {
            EntityTransferContext ctx = new EntityTransferContext();

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

            if (args == null)
            {
                responsedata["int_response_code"]   = HttpStatusCode.BadRequest;
                responsedata["str_response_string"] = "Bad request";
                return;
            }

            if (args.ContainsKey("context"))
            {
                ctx.Unpack((OSDMap)args["context"]);
            }

            AgentDestinationData data = CreateAgentDestinationData();

            UnpackData(args, data, request);

            GridRegion destination = new GridRegion();

            destination.RegionID   = data.uuid;
            destination.RegionLocX = data.x;
            destination.RegionLocY = data.y;
            destination.RegionName = data.name;

            GridRegion gatekeeper = ExtractGatekeeper(data);

            AgentCircuitData aCircuit = new AgentCircuitData();

            try
            {
                aCircuit.UnpackAgentCircuitData(args);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message);
                responsedata["int_response_code"]   = HttpStatusCode.BadRequest;
                responsedata["str_response_string"] = "Bad request";
                return;
            }

            GridRegion source = null;

            if (args.ContainsKey("source_uuid"))
            {
                source            = new GridRegion();
                source.RegionLocX = Int32.Parse(args["source_x"].AsString());
                source.RegionLocY = Int32.Parse(args["source_y"].AsString());
                source.RegionName = args["source_name"].AsString();
                source.RegionID   = UUID.Parse(args["source_uuid"].AsString());

                if (args.ContainsKey("source_server_uri"))
                {
                    source.RawServerURI = args["source_server_uri"].AsString();
                }
                else
                {
                    source.RawServerURI = null;
                }
            }

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

            // This is the meaning of POST agent
            //m_regionClient.AdjustUserInformation(aCircuit);
            //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason);

            bool result = CreateAgent(source, gatekeeper, destination, aCircuit, data.flags, data.fromLogin, ctx, out reason);

            resp["reason"]  = OSD.FromString(reason);
            resp["success"] = OSD.FromBoolean(result);
            // Let's also send out the IP address of the caller back to the caller (HG 1.5)
            resp["your_ip"] = OSD.FromString(GetCallerIP(request));

            // TODO: add reason if not String.Empty?
            responsedata["int_response_code"]   = HttpStatusCode.OK;
            responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
        }
Beispiel #10
0
        protected override GridRegion ExtractGatekeeper(AgentDestinationData d)
        {
            if (d is ExtendedAgentDestinationData)
            {
                ExtendedAgentDestinationData data = (ExtendedAgentDestinationData)d;
                GridRegion gatekeeper = new GridRegion();
                gatekeeper.ServerURI = data.gatekeeperServerURI;
                gatekeeper.ExternalHostName = data.host;
                gatekeeper.HttpPort = (uint)data.port;
                gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);

                return gatekeeper;
            }
            else
                m_log.WarnFormat("[HOME AGENT HANDLER]: Wrong data type");

            return null;
        }