Ejemplo n.º 1
0
 public LSL_String llJsonSetValue(LSL_String json, LSL_List specifiers, LSL_String value)
 {
     try {
         OSD o = OSDParser.DeserializeJson(json);
         JsonSetSpecific(o, specifiers, 0, value);
         return(OSDParser.SerializeJsonString(o));
     } catch (Exception) {
     }
     return(ScriptBaseClass.JSON_INVALID);
 }
Ejemplo n.º 2
0
        public void CompressedUnpack(string compressedString)
        {
            //Decompress the info back to json format
            string jsonString = Util.Decompress(compressedString);
            //Build the OSDMap
            OSDMap assetMap = (OSDMap)OSDParser.DeserializeJson(jsonString);

            //Now unpack the contents
            Unpack(assetMap);
        }
        public void HistoricalAgentCircuitDataOSDConversion()
        {
            string           oldSerialization = "{\"agent_id\":\"522675bd-8214-40c1-b3ca-9c7f7fd170be\",\"base_folder\":\"c40b5f5f-476f-496b-bd69-b5a539c434d8\",\"caps_path\":\"http://www.opensimulator.org/Caps/Foo\",\"children_seeds\":[{\"handle\":\"18446744073709551615\",\"seed\":\"http://www.opensimulator.org/Caps/Foo2\"}],\"child\":false,\"circuit_code\":\"949030\",\"first_name\":\"CoolAvatarTest\",\"last_name\":\"test\",\"inventory_folder\":\"c40b5f5f-476f-496b-bd69-b5a539c434d8\",\"secure_session_id\":\"1e608e2b-0ddb-41f6-be0f-926f61cd3e0a\",\"session_id\":\"aa06f798-9d70-4bdb-9bbf-012a02ee2baf\",\"start_pos\":\"<5, 23, 125>\"}";
            AgentCircuitData Agent1Data       = new AgentCircuitData();

            Agent1Data.AgentID          = new UUID("522675bd-8214-40c1-b3ca-9c7f7fd170be");
            Agent1Data.Appearance       = AvAppearance;
            Agent1Data.BaseFolder       = new UUID("c40b5f5f-476f-496b-bd69-b5a539c434d8");
            Agent1Data.CapsPath         = CapsPath;
            Agent1Data.child            = false;
            Agent1Data.ChildrenCapSeeds = ChildrenCapsPaths;
            Agent1Data.circuitcode      = circuitcode;
            Agent1Data.firstname        = firstname;
            Agent1Data.InventoryFolder  = new UUID("c40b5f5f-476f-496b-bd69-b5a539c434d8");
            Agent1Data.lastname         = lastname;
            Agent1Data.SecureSessionID  = new UUID("1e608e2b-0ddb-41f6-be0f-926f61cd3e0a");
            Agent1Data.SessionID        = new UUID("aa06f798-9d70-4bdb-9bbf-012a02ee2baf");
            Agent1Data.startpos         = StartPos;

            OSDMap map2;

            try
            {
                map2 = (OSDMap)OSDParser.DeserializeJson(oldSerialization);

                AgentCircuitData Agent2Data = new AgentCircuitData();
                Agent2Data.UnpackAgentCircuitData(map2);

                Assert.That((Agent1Data.AgentID == Agent2Data.AgentID));
                Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder));

                Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath));
                Assert.That((Agent1Data.child == Agent2Data.child));
                Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count));
                Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode));
                Assert.That((Agent1Data.firstname == Agent2Data.firstname));
                Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder));
                Assert.That((Agent1Data.lastname == Agent2Data.lastname));
                Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID));
                Assert.That((Agent1Data.SessionID == Agent2Data.SessionID));
                Assert.That((Agent1Data.startpos == Agent2Data.startpos));
            }
            catch (LitJson.JsonException)
            {
                //intermittant litjson errors :P
                Assert.That(1 == 1);
            }

            /*
             * Enable this once VisualParams go in the packing method
             * for (int i=0;i<208;i++)
             * Assert.That((Agent1Data.Appearance.VisualParams[i] == Agent2Data.Appearance.VisualParams[i]));
             */
        }
Ejemplo n.º 4
0
        private void ReadAMBuildFile(string fileName)
        {
            OSDMap map          = (OSDMap)OSDParser.DeserializeJson(File.ReadAllText(fileName));
            string prebuildFile = Path.Combine(Path.GetDirectoryName(fileName), map["PrebuildFile"]);
            string tmpFile      = Path.Combine(Path.GetDirectoryName(fileName), map["TmpFile"]);

            ReadFileAndCreatePrebuildFile(tmpFile, prebuildFile);
            BuildCSProj(tmpFile);
            CreateAndCompileCSProj(tmpFile, prebuildFile, map);
            ConfigureModule(Path.GetDirectoryName(fileName), map);
        }
Ejemplo n.º 5
0
        private object RestrictedCurrencyPurchaseRemove_Event(string functionName, object parameters)
        {
            RestrictedCurrencyInfo pcri = new RestrictedCurrencyInfo();

            pcri.FromOSD((OSDMap)OSDParser.DeserializeJson(parameters.ToString()));
            StarDustUserCurrency starDustUserCurrency = UserCurrencyInfo(pcri.AgentID);

            starDustUserCurrency.RestrictPurchaseAmount -= pcri.Amount;
            m_database.UserCurrencyUpdate(starDustUserCurrency);
            return(true);
        }
        /// <summary>
        ///   Searches for classifieds
        /// </summary>
        /// <param name = "queryText"></param>
        /// <param name = "category"></param>
        /// <param name = "queryFlags"></param>
        /// <param name = "StartQuery"></param>
        /// <returns></returns>
        public DirClassifiedReplyData[] FindClassifieds(string queryText, string category, uint queryFlags, int StartQuery)
        {
            QueryFilter filter = new QueryFilter();

            if (int.Parse(category) != (int)DirectoryManager.ClassifiedCategories.Any) //Check the category
            {
                filter.andFilters["Category"] = category;
            }

            filter.andLikeFilters["Name"] = "%" + queryText + "%";

            List <string> retVal = GD.Query(new string[1] {
                "*"
            }, "userclassifieds", filter, null, (uint)StartQuery, 50);

            if (retVal.Count == 0)
            {
                return(new DirClassifiedReplyData[0] {
                });
            }

            List <DirClassifiedReplyData> Data = new List <DirClassifiedReplyData>();
            DirClassifiedReplyData        replyData;

            for (int i = 0; i < retVal.Count; i += 6)
            {
                //Pull the classified out of OSD
                Classified classified = new Classified();
                classified.FromOSD((OSDMap)OSDParser.DeserializeJson(retVal[i + 5]));

                replyData = new DirClassifiedReplyData
                {
                    classifiedFlags = classified.ClassifiedFlags,
                    classifiedID    = classified.ClassifiedUUID,
                    creationDate    = classified.CreationDate,
                    expirationDate  = classified.ExpirationDate,
                    price           = classified.PriceForListing,
                    name            = classified.Name
                };
                //Check maturity levels
                if ((replyData.classifiedFlags & (uint)DirectoryManager.ClassifiedFlags.Mature) == (uint)DirectoryManager.ClassifiedFlags.Mature)
                {
                    if ((queryFlags & (uint)DirectoryManager.ClassifiedQueryFlags.Mature) == (uint)DirectoryManager.ClassifiedQueryFlags.Mature)
                    {
                        Data.Add(replyData);
                    }
                }
                else
                { //Its PG, add all
                    Data.Add(replyData);
                }
            }
            return(Data.ToArray());
        }
Ejemplo n.º 7
0
        /// -----------------------------------------------------------------
        /// <summary>
        /// </summary>
        // -----------------------------------------------------------------
        public ResponseBase SetAvatarAppearanceHandler(RequestBase irequest)
        {
            if (irequest.GetType() != typeof(SetAvatarAppearanceRequest))
            {
                return(OperationFailed("wrong type"));
            }

            SetAvatarAppearanceRequest request = (SetAvatarAppearanceRequest)irequest;

            // Get the scenepresence for the avatar we are going to update
            UUID          id = request.AvatarID == UUID.Zero ? request._UserAccount.PrincipalID : request.AvatarID;
            ScenePresence sp = m_scene.GetScenePresence(id);

            if (sp == null || sp.IsChildAgent)
            {
                return(OperationFailed(String.Format("cannot find user {0}", request._UserAccount.PrincipalID)));
            }

            // Clean out the current outfit folder, this is to keep v3 viewers from
            // reloading the old appearance
            CleanCurrentOutfitFolder(sp);

            // Delete existing npc attachments
            m_scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false);

            // ---------- Update the appearance and save it ----------
            int    serial = sp.Appearance.Serial;
            OSDMap osd    = (OSDMap)OSDParser.DeserializeJson(request.SerializedAppearance);

            sp.Appearance        = new AvatarAppearance(osd);
            sp.Appearance.Serial = serial + 1;

            m_scene.AvatarService.SetAppearance(sp.UUID, sp.Appearance);
            m_scene.EventManager.TriggerAvatarAppearanceChanged(sp);

            // ---------- Send out the new appearance to everyone ----------

            // Rez needed attachments
            m_scene.AttachmentsModule.RezAttachments(sp);

            // this didn't work, still looking for a way to get the viewer to change its appearance
            //sp.ControllingClient.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++);

            // this didn't work either,
            //AddWearablesToCurrentOutfitFolder(sp);

            sp.SendAvatarDataToAllAgents();
            sp.SendAppearanceToAllOtherAgents();
            sp.SendAppearanceToAgent(sp); // the viewers seem to ignore this packet when it describes their own avatar

            return(new ResponseBase(ResponseCode.Success, ""));
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Gets a Generic type as set by T
        /// </summary>
        /// <param name="OwnerID"></param>
        /// <param name="Type"></param>
        /// <param name="Key"></param>
        /// <param name="GD"></param>
        /// <returns></returns>
        public static OSDMap GetGeneric(UUID OwnerID, string Type, string Key, IGenericData GD)
        {
            QueryFilter filter = new QueryFilter();
            filter.andFilters["OwnerID"] = OwnerID;
            filter.andFilters["Type"] = Type;
            filter.andFilters["`Key`"] = Key;
            List<string> retVal = GD.Query(new string[1] {"`value`"}, "generics", filter, null, null, null);

            if (retVal.Count == 0)
                return null;

            return (OSDMap) OSDParser.DeserializeJson(retVal[0]);
        }
Ejemplo n.º 9
0
        public void TestAgentCircuitDataOSDConversion()
        {
            AgentCircuitData Agent1Data = new AgentCircuitData();

            Agent1Data.AgentID          = AgentId;
            Agent1Data.Appearance       = AvAppearance;
            Agent1Data.BaseFolder       = BaseFolder;
            Agent1Data.CapsPath         = CapsPath;
            Agent1Data.child            = false;
            Agent1Data.ChildrenCapSeeds = ChildrenCapsPaths;
            Agent1Data.circuitcode      = circuitcode;
            Agent1Data.firstname        = firstname;
            Agent1Data.InventoryFolder  = BaseFolder;
            Agent1Data.lastname         = lastname;
            Agent1Data.SecureSessionID  = SecureSessionId;
            Agent1Data.SessionID        = SessionId;
            Agent1Data.startpos         = StartPos;

            OSDMap map2;
            OSDMap map = Agent1Data.PackAgentCircuitData();

            try
            {
                string str = OSDParser.SerializeJsonString(map);
                map2 = (OSDMap)OSDParser.DeserializeJson(str);
            }
            catch (System.NullReferenceException)
            {
                map2 = map;
                Assert.That(1 == 1);
                return;
            }

            AgentCircuitData Agent2Data = new AgentCircuitData();

            Agent2Data.UnpackAgentCircuitData(map2);

            Assert.That((Agent1Data.AgentID == Agent2Data.AgentID));
            Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder));

            Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath));
            Assert.That((Agent1Data.child == Agent2Data.child));
            Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count));
            Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode));
            Assert.That((Agent1Data.firstname == Agent2Data.firstname));
            Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder));
            Assert.That((Agent1Data.lastname == Agent2Data.lastname));
            Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID));
            Assert.That((Agent1Data.SessionID == Agent2Data.SessionID));
            Assert.That((Agent1Data.startpos == Agent2Data.startpos));
        }
        /// <summary>
        /// Searches for classifieds
        /// </summary>
        /// <param name="queryText"></param>
        /// <param name="category"></param>
        /// <param name="queryFlags"></param>
        /// <param name="StartQuery"></param>
        /// <returns></returns>
        public DirClassifiedReplyData[] FindClassifieds(string queryText, string category, string queryFlags, int StartQuery)
        {
            List <DirClassifiedReplyData> Data = new List <DirClassifiedReplyData>();

            string whereClause      = "";
            string classifiedClause = "";
            uint   cqf = uint.Parse(queryFlags);

            if (int.Parse(category) != (int)DirectoryManager.ClassifiedCategories.Any) //Check the category
            {
                classifiedClause = " and Category = '" + category + "'";
            }

            whereClause = " Name LIKE '%" + queryText + "%'" + classifiedClause + " LIMIT " + StartQuery.ToString() + ",50 ";
            List <string> retVal = GD.Query(whereClause, "userclassifieds", "*");

            if (retVal.Count == 0)
            {
                return(Data.ToArray());
            }

            DirClassifiedReplyData replyData = null;

            for (int i = 0; i < retVal.Count; i += 6)
            {
                //Pull the classified out of OSD
                Classified classified = new Classified();
                classified.FromOSD((OSDMap)OSDParser.DeserializeJson(retVal[i + 5]));

                replyData = new DirClassifiedReplyData();
                replyData.classifiedFlags = classified.ClassifiedFlags;
                replyData.classifiedID    = classified.ClassifiedUUID;
                replyData.creationDate    = classified.CreationDate;
                replyData.expirationDate  = classified.ExpirationDate;
                replyData.price           = classified.PriceForListing;
                replyData.name            = classified.Name;
                //Check maturity levels
                if ((replyData.classifiedFlags & (uint)DirectoryManager.ClassifiedFlags.Mature) == (uint)DirectoryManager.ClassifiedFlags.Mature)
                {
                    if ((cqf & (uint)DirectoryManager.ClassifiedQueryFlags.Mature) == (uint)DirectoryManager.ClassifiedQueryFlags.Mature)
                    {
                        Data.Add(replyData);
                    }
                }
                else //Its PG, add all
                {
                    Data.Add(replyData);
                }
            }
            return(Data.ToArray());
        }
        public override byte[] Handle(string path, Stream requestData,
                                      OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            StreamReader sr   = new StreamReader(requestData);
            string       body = sr.ReadToEnd();

            sr.Close();
            body = body.Trim();

            //MainConsole.Instance.DebugFormat("[XXX]: query String: {0}", body);
            try
            {
                OSDMap map = (OSDMap)OSDParser.DeserializeJson(body);
                //Make sure that the person who is calling can access the web service
                if (VerifyPassword(map))
                {
                    string method = map["Method"].AsString();
                    if (method == "Validate")
                    {
                        return(Validate(map));
                    }
                    if (method == "IPNData")
                    {
                        return(Validate2(map));
                    }
                    if (method == "CheckPurchaseStatus")
                    {
                        return(PrePurchaseCheck(map));
                    }
                    if (method == "OrderSubscription")
                    {
                        return(OrderSubscription(map));
                    }
                }
                else
                {
                    MainConsole.Instance.Error("[Stardust] Web password did not match.");
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.ErrorFormat("[Stardust] Error processing method: {0}", e.ToString());
            }
            OSDMap resp = new OSDMap {
                { "response", OSD.FromString("Failed") }
            };
            string       xmlString = OSDParser.SerializeJsonString(resp);
            UTF8Encoding encoding  = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
Ejemplo n.º 12
0
        public UserInfo Get(string userID)
        {
            List <string> query = GD.Query("UserID", userID, m_realm, "*");

            if (query.Count == 0)
            {
                return(null);
            }
            UserInfo user = new UserInfo();

            user.UserID          = query[0];
            user.CurrentRegionID = UUID.Parse(query[1]);
            user.IsOnline        = query[3] == "1" ? true : false;
            user.LastLogin       = Util.ToDateTime(int.Parse(query[4]));
            user.LastLogout      = Util.ToDateTime(int.Parse(query[5]));
            user.Info            = (OSDMap)OSDParser.DeserializeJson(query[6]);
            try
            {
                user.CurrentRegionID = UUID.Parse(query[7]);
                if (query[8] != "")
                {
                    user.CurrentPosition = Vector3.Parse(query[8]);
                }
                if (query[9] != "")
                {
                    user.CurrentLookAt = Vector3.Parse(query[9]);
                }
                user.HomeRegionID = UUID.Parse(query[10]);
                if (query[11] != "")
                {
                    user.HomePosition = Vector3.Parse(query[11]);
                }
                if (query[12] != "")
                {
                    user.HomeLookAt = Vector3.Parse(query[12]);
                }
            }
            catch
            {
            }

            //Check LastSeen
            if (m_checkLastSeen && user.IsOnline && (Util.ToDateTime(int.Parse(query[2])).AddHours(1) < DateTime.Now))
            {
                m_log.Warn("[UserInfoService]: Found a user (" + user.UserID + ") that was not seen within the last hour! Logging them out.");
                user.IsOnline = false;
                Set(user);
            }
            return(user);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Gets a list of generic T's from the database
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="OwnerID"></param>
        /// <param name="Type"></param>
        /// <param name="GD"></param>
        /// <param name="data">a default T</param>
        /// <returns></returns>
        public static List <T> GetGenerics <T>(UUID OwnerID, string Type, IGenericData GD, T data) where T : IDataTransferable
        {
            List <T>      Values = new List <T>();
            List <string> retVal = GD.Query(new string[] { "OwnerID", "Type" }, new object[] { OwnerID, Type }, "generics", "`value`");

            foreach (string ret in retVal)
            {
                OSDMap map = (OSDMap)OSDParser.DeserializeJson(ret);
                data.FromOSD(map);
                T dataCopy = (T)data.Duplicate();
                Values.Add(dataCopy);
            }
            return(Values);
        }
Ejemplo n.º 14
0
        public JsonStore(string value)
        {
            m_TakeStore = new List <TakeValueCallbackClass>();
            m_ReadStore = new List <TakeValueCallbackClass>();

            if (String.IsNullOrEmpty(value))
            {
                m_ValueStore = new OSDMap();
            }
            else
            {
                m_ValueStore = OSDParser.DeserializeJson(value);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Gets a Generic type as set by T
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="OwnerID"></param>
        /// <param name="Type"></param>
        /// <param name="Key"></param>
        /// <param name="GD"></param>
        /// <param name="data">a default T to copy all data into</param>
        /// <returns></returns>
        public static T GetGeneric <T>(UUID OwnerID, string Type, string Key, IGenericData GD, T data) where T : IDataTransferable
        {
            List <string> retVal = GD.Query(new string[] { "OwnerID", "Type", "`Key`" }, new object[] { OwnerID, Type, Key }, "generics", "`value`");

            if (retVal.Count == 0)
            {
                return(null);
            }

            OSDMap map = (OSDMap)OSDParser.DeserializeJson(retVal[0]);

            data.FromOSD(map);
            return(data);
        }
Ejemplo n.º 16
0
        public bool GetOSDMap(string url, OSDMap map, out OSDMap response)
        {
            response = null;
            string resp = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                    url,
                                                                    OSDParser.SerializeJsonString(map));

            if (resp == "")
            {
                return(false);
            }
            response = (OSDMap)OSDParser.DeserializeJson(resp);
            return(response["Success"]);
        }
Ejemplo n.º 17
0
        public void HandleWebSocketLoginEvents(string path, WebSocketHttpServerHandler sock)
        {
            sock.MaxPayloadSize    = 16384; //16 kb payload
            sock.InitialMsgTimeout = 5000;  //5 second first message to trigger at least one of these events
            sock.NoDelay_TCP_Nagle = true;
            sock.OnData           += delegate(object sender, WebsocketDataEventArgs data) { sock.Close("fail"); };
            sock.OnPing           += delegate(object sender, PingEventArgs pingdata) { sock.Close("fail"); };
            sock.OnPong           += delegate(object sender, PongEventArgs pongdata) { sock.Close("fail"); };
            sock.OnText           += delegate(object sender, WebsocketTextEventArgs text)
            {
                OSD request = null;
                try
                {
                    request = OSDParser.DeserializeJson(text.Data);
                    if (!(request is OSDMap))
                    {
                        sock.SendMessage(OSDParser.SerializeJsonString(FailedOSDResponse()));
                    }
                    else
                    {
                        OSDMap     req      = request as OSDMap;
                        string     first    = req["firstname"].AsString();
                        string     last     = req["lastname"].AsString();
                        string     passwd   = req["passwd"].AsString();
                        string     start    = req["startlocation"].AsString();
                        string     version  = req["version"].AsString();
                        string     channel  = req["channel"].AsString();
                        string     mac      = req["mac"].AsString();
                        string     id0      = req["id0"].AsString();
                        UUID       scope    = UUID.Zero;
                        IPEndPoint endPoint =
                            (sender as WebSocketHttpServerHandler).GetRemoteIPEndpoint();
                        LoginResponse reply = null;
                        reply = m_LocalService.Login(first, last, passwd, start, scope, version,
                                                     channel, mac, id0, endPoint, false);
                        sock.SendMessage(OSDParser.SerializeJsonString(reply.ToOSDMap()));
                    }
                }
                catch (Exception)
                {
                    sock.SendMessage(OSDParser.SerializeJsonString(FailedOSDResponse()));
                }
                finally
                {
                    sock.Close("success");
                }
            };

            sock.HandshakeAndUpgrade();
        }
Ejemplo n.º 18
0
 public JsonStore(string value) : this()
 {
     // This is going to throw an exception if the value is not
     // a valid JSON chunk. Calling routines should catch the
     // exception and handle it appropriately
     if (String.IsNullOrEmpty(value))
     {
         ValueStore = new OSDMap();
     }
     else
     {
         ValueStore = OSDParser.DeserializeJson(value);
     }
 }
Ejemplo n.º 19
0
        private static List <UserInfo> ParseQuery(List <string> query)
        {
            List <UserInfo> users = new List <UserInfo>();

            if (query.Count % 14 == 0)
            {
                for (int i = 0; i < query.Count; i += 14)
                {
                    UserInfo user = new UserInfo
                    {
                        UserID          = query[i],
                        CurrentRegionID = UUID.Parse(query[i + 1]),
                        IsOnline        = query[i + 3] == "1",
                        LastLogin       = Util.ToDateTime(int.Parse(query[i + 4])),
                        LastLogout      = Util.ToDateTime(int.Parse(query[i + 5])),
                        Info            = (OSDMap)OSDParser.DeserializeJson(query[i + 6])
                    };
                    try
                    {
                        user.CurrentRegionID = UUID.Parse(query[i + 7]);
                        if (query[i + 8] != "")
                        {
                            user.CurrentPosition = Vector3.Parse(query[i + 8]);
                        }
                        if (query[i + 9] != "")
                        {
                            user.CurrentLookAt = Vector3.Parse(query[i + 9]);
                        }
                        user.HomeRegionID = UUID.Parse(query[i + 10]);
                        if (query[i + 11] != "")
                        {
                            user.HomePosition = Vector3.Parse(query[i + 11]);
                        }
                        if (query[i + 12] != "")
                        {
                            user.HomeLookAt = Vector3.Parse(query[i + 12]);
                        }
                        user.CurrentRegionURI = query[i + 13];
                    }
                    catch
                    {
                    }

                    users.Add(user);
                }
            }

            return(users);
        }
        public bool RetrieveAgent(GridRegion destination, UUID id, bool agentIsLeaving, out AgentData agent,
                                  out AgentCircuitData circuitData)
        {
            agent = null;
            // Try local first
            if (m_localBackend.RetrieveAgent(destination, id, agentIsLeaving, out agent, out circuitData))
            {
                return(true);
            }

            // else do the remote thing
            if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
            {
                // Eventually, we want to use a caps url instead of the agentID
                string uri = MakeUri(destination, true) + id + "/" + destination.RegionID.ToString() + "/" +
                             agentIsLeaving.ToString() + "/";

                try
                {
                    string resultStr = WebUtils.GetFromService(uri);
                    if (resultStr != "")
                    {
                        OSDMap result = OSDParser.DeserializeJson(resultStr) as OSDMap;
                        if (result["Result"] == "Not Found")
                        {
                            return(false);
                        }
                        agent = new AgentData();

                        if (!result.ContainsKey("AgentData"))
                        {
                            return(false); //Disable old simulators
                        }
                        agent.Unpack((OSDMap)result["AgentData"]);
                        circuitData = new AgentCircuitData();
                        circuitData.UnpackAgentCircuitData((OSDMap)result["CircuitData"]);
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    MainConsole.Instance.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e);
                }

                return(false);
            }

            return(false);
        }
Ejemplo n.º 21
0
 private OSDMap CreateWebResponse(OSDMap request)
 {
     if (request == null)
     {
         return(null);
     }
     try
     {
         return((OSDMap)OSDParser.DeserializeJson(request["_RawResult"]));
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 22
0
        private string HandlePlusParcelRequest(bool isClaim, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            if (!Util.CheckHttpAuthorization(_gridSendKey, httpRequest.Headers))
            {
                httpResponse.StatusCode = 401;
                return("Unauthorized");
            }

            OSDMap map = (OSDMap)OSDParser.DeserializeJson(httpRequest.InputStream);

            UUID parcelID = map["parcel_id"].AsUUID();
            UUID userID   = map["user_id"].AsUUID();

            return(HandlePlusParcelChange(isClaim, userID, parcelID));
        }
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            if (message.ContainsKey("Method") && message["Method"] == "NegotiateUrl")
            {
                //We got a message, now display it
                //string user = message["User"].AsString();
                string value = message["Value"].AsString();

                IConfigurationService service = m_registry.RequestModuleInterface <IConfigurationService>();
                if (service != null)
                {
                    service.AddNewUrls("default", (OSDMap)OSDParser.DeserializeJson(value));
                }
            }
            return(null);
        }
Ejemplo n.º 24
0
        public virtual string RegisterRegion(GridRegion regionInfo, UUID SecureSessionID, out UUID SessionID)
        {
            OSDMap map = new OSDMap();

            map["Region"]          = regionInfo.ToOSD();
            map["SecureSessionID"] = SecureSessionID;
            map["Method"]          = "Register";

            List <string> serverURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("RegistrationURI");

            foreach (string m_ServerURI in serverURIs)
            {
                OSDMap result = WebUtils.PostToService(m_ServerURI + "/grid", map);
                if (result["Success"].AsBoolean())
                {
                    try
                    {
                        OSD r = OSDParser.DeserializeJson(result["_RawResult"]);
                        if (r is OSDMap)
                        {
                            OSDMap innerresult = (OSDMap)r;
                            if (innerresult["Result"].AsString() == "")
                            {
                                object[] o = new object[2];
                                o[0] = regionInfo;
                                o[1] = innerresult;
                                m_registry.RequestModuleInterface <ISimulationBase>().EventManager.FireGenericEventHandler("GridRegionRegistered", o);
                                SessionID = innerresult["SecureSessionID"].AsUUID();
                                m_registry.RequestModuleInterface <IConfigurationService>().AddNewUrls(regionInfo.RegionHandle.ToString(), (OSDMap)innerresult["URLs"]);
                                return("");
                            }
                            else
                            {
                                SessionID = UUID.Zero;
                                return(innerresult["Result"].AsString());
                            }
                        }
                    }
                    catch (Exception)//JsonException
                    {
                        m_log.Warn("[GridServiceConnector]: Exception on parsing OSDMap from server, legacy (OpenSim) server?");
                    }
                }
            }
            SessionID = UUID.Zero;
            return(OldRegisterRegion(regionInfo));
        }
        private string IncomingCommand(byte[] data, string path, string param)
        {
            using (MemoryStream str = new MemoryStream(data))
            {
                OSDMap map = (OSDMap)OSDParser.DeserializeJson(str);

                UUID sessionID = map["sessionId"].AsUUID();
                UUID userID    = map["userId"].AsUUID();
                UUID regionID  = map["regionId"].AsUUID();

                Scene scene = _scenes.FirstOrDefault((s) => s.RegionInfo.RegionID == regionID);
                if (scene == null)//No scene found...
                {
                    return(BuildCommandResponse(RemoteCommandResponse.NOTFOUND, null));
                }

                if (!scene.ConnectionManager.IsAuthorized(userID, sessionID))
                {
                    //They might not be in the scene, check if they have left recently
                    LeavingRegionInfo info = null;
                    if (!_avatarRegionCache.TryGetValue(userID, out info) || info.SessionID != sessionID)
                    {
                        return(BuildCommandResponse(RemoteCommandResponse.UNAUTHORIZED, null));//Wrong sessionID or was never here
                    }
                    //They moved out of this region
                    return(BuildMovedCommandResponse(userID));
                }

                ScenePresence presence = scene.GetScenePresence(userID);
                if (presence == null || presence.IsChildAgent)//Make sure that they are actually in the region
                {
                    return(BuildMovedCommandResponse(userID));
                }

                //Process the command
                RemoteCommandType commandID = (RemoteCommandType)map["id"].AsInteger();
                switch (commandID)
                {
                case RemoteCommandType.AvatarChatCommand:
                    return(ProcessAvatarChatCommand(presence, map));

                case RemoteCommandType.AvatarTeleportCommand:
                    return(ProcessAvatarTeleportCommand(presence, map));
                }
            }
            return(BuildCommandResponse(RemoteCommandResponse.INVALID, null));
        }
Ejemplo n.º 26
0
        /// <summary>
        ///     Gets a list of OSDMaps from the database
        /// </summary>
        /// <param name="OwnerID"></param>
        /// <param name="Type"></param>
        /// <param name="GD"></param>
        /// <returns></returns>
        public static List<OSDMap> GetGenerics(UUID OwnerID, string Type, IGenericData GD)
        {
            QueryFilter filter = new QueryFilter();
            filter.andFilters["OwnerID"] = OwnerID;
            filter.andFilters["Type"] = Type;
            List<string> retVal = GD.Query(new string[1] {"`value`"}, "generics", filter, null, null, null);

            List<OSDMap> Values = new List<OSDMap>();
            foreach (string ret in retVal)
            {
                OSDMap map = (OSDMap) OSDParser.DeserializeJson(ret);
                if (map != null)
                    Values.Add(map);
            }

            return Values;
        }
Ejemplo n.º 27
0
 public LSL_String llJsonGetValue(LSL_String json, LSL_List specifiers)
 {
     try {
         OSD o       = OSDParser.DeserializeJson(json);
         OSD specVal = JsonGetSpecific(o, specifiers, 0);
         if (specVal != null)
         {
             return(specVal.AsString());
         }
         else
         {
             return(ScriptBaseClass.JSON_INVALID);
         }
     } catch (Exception) {
         return(ScriptBaseClass.JSON_INVALID);
     }
 }
        public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
        {
            // MainConsole.Instance.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: CreateAgent start");

            myipaddress = String.Empty;
            reason      = String.Empty;

            if (destination == null)
            {
                MainConsole.Instance.Debug("[GATEKEEPER SERVICE CONNECTOR]: Given destination is null");
                return(false);
            }

            string uri = (destination.ServerURI.EndsWith("/") ? destination.ServerURI : (destination.ServerURI + "/"))
                         + AgentPath() + aCircuit.AgentID + "/";

            try
            {
                OSDMap args = aCircuit.PackAgentCircuitData();

                args["destination_x"]    = OSD.FromString(destination.RegionLocX.ToString());
                args["destination_y"]    = OSD.FromString(destination.RegionLocY.ToString());
                args["destination_name"] = OSD.FromString(destination.RegionName);
                args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
                args["teleport_flags"]   = OSD.FromString(flags.ToString());

                string r        = WebUtils.PostToService(uri, args);
                OSDMap unpacked = OSDParser.DeserializeJson(r) as OSDMap;
                if (unpacked != null)
                {
                    reason      = unpacked["reason"].AsString();
                    myipaddress = unpacked["your_ip"].AsString();
                    return(unpacked["success"].AsBoolean());
                }

                reason = unpacked["Message"] != null ? unpacked["Message"].AsString() : "error";
                return(false);
            }
            catch (Exception e)
            {
                MainConsole.Instance.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString());
                reason = e.Message;
            }

            return(false);
        }
        public RegionInfo GetRegionInfo(string regionName)
        {
            QueryFilter filter = new QueryFilter();

            filter.andFilters["RegionName"] = regionName;
            List <string> RetVal = GD.Query(new[] { "RegionInfo" }, "simulator", filter, null, null, null);

            if (RetVal.Count == 0)
            {
                return(null);
            }

            RegionInfo replyData = new RegionInfo();

            replyData.UnpackRegionInfoData((OSDMap)OSDParser.DeserializeJson(RetVal[0]));
            return(replyData);
        }
Ejemplo n.º 30
0
        public Dictionary <uint, uint> DeserializeAgentCache(string osdMap)
        {
            Dictionary <uint, uint> cache = new Dictionary <uint, uint> ();

            try {
                OSDMap cachedMap = (OSDMap)OSDParser.DeserializeJson(osdMap);
                foreach (KeyValuePair <string, OSD> kvp in cachedMap)
                {
                    cache [uint.Parse(kvp.Key)] = kvp.Value.AsUInteger();
                }
            } catch {
                //It has an error, destroy the cache
                //null will tell the caller that it has errors and needs to be removed
                cache = null;
            }
            return(cache);
        }