コード例 #1
0
        private string SetEnvironmentSettings(string request, UUID agentID)
        {
            LLSDEnvironmentSetResponse setResponse = new LLSDEnvironmentSetResponse();

            m_log.WarnFormat("[{0}]: Environment POST handler for agentID {1}", Name, agentID);
            setResponse.regionID = regionID;
            setResponse.success  = false;

            if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false))
            {
                setResponse.fail_reason = "Insufficient estate permissions, settings has not been saved.";
                return(LLSDHelpers.SerializeLLSDReply(setResponse));
            }

            try
            {
                m_scene.StorageManager.DataStore.StoreRegionEnvironmentString(regionID, request);
                setResponse.success = true;
                environString       = request;
                m_log.InfoFormat("[{0}]: Environment settings updated by user {1}", Name, agentID);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[{0}]: Environment settings not been saved for user {1}, Exception: {2} - {3}",
                                  Name, agentID, e.Message, e.StackTrace);

                setResponse.success     = false;
                setResponse.fail_reason = String.Format("Environment settings for '{0}' could not be saved.", m_scene.RegionInfo.RegionName);
            }

            return(LLSDHelpers.SerializeLLSDReply(setResponse));
        }
コード例 #2
0
            /// <summary>
            /// Construct a client response detailing all the capabilities this server can provide.
            /// </summary>
            /// <param name="request"></param>
            /// <param name="path"></param>
            /// <param name="param"></param>
            /// <param name="httpRequest">HTTP request header object</param>
            /// <param name="httpResponse">HTTP response header object</param>
            /// <returns></returns>
            public string SeedCapRequest(string request, string path, string param,
                                         OSHttpRequest httpRequest, OSHttpResponse httpResponse)
            {
                // m_log.DebugFormat("[CAPS]: Seed CAPS Request in region {0} = {1}", m_regionName, request);

                Hashtable capsDetails = m_Caps.CapsHandlers.GetCapsDetails(true);

                string result = LLSDHelpers.SerializeLLSDReply(capsDetails);

                // m_log.DebugFormat("[CAPS] CapsRequest {0}", result);

                return(result);
            }
コード例 #3
0
                /// <summary>
                /// Handle raw uploaded baked texture data.
                /// </summary>
                /// <param name="data"></param>
                /// <param name="path"></param>
                /// <param name="param"></param>
                /// <returns></returns>
                public string BakedTextureUploaded(byte[] data, string path, string param)
                {
                    String result;
                    bool   decodeFailed = false;
                    UUID   newAssetID   = UUID.Random();

                    if (data.Length <= 0)
                    {
                        m_log.ErrorFormat("[CAPS]: Invalid length {0} on UploadBakeRequestPut for {1}", data.Length, path);
                        decodeFailed = true;
                    }
                    else if (m_layerDecoder != null)
                    {
                        decodeFailed = (m_layerDecoder.Decode(newAssetID, data) == false);
                    }

                    if (decodeFailed)
                    {
                        Hashtable badReply = new Hashtable();
                        badReply["state"]     = "error";
                        badReply["new_asset"] = UUID.Zero;
                        result = LLSDHelpers.SerializeLLSDReply(badReply);
                    }
                    else
                    {
                        AssetBase asset = new AssetBase(newAssetID, "Baked Texture", (sbyte)AssetType.Texture, m_Caps.AgentID.ToString());
                        asset.Data = data;
                        //Persist baked textures as we will use them in the baked texture cache
                        //asset.Temporary = true;
                        asset.Local = true;
                        m_assetCache.AddAsset(asset, AssetRequestInfo.GenericNetRequest());

                        LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
                        uploadComplete.new_asset          = newAssetID.ToString();
                        uploadComplete.new_inventory_item = UUID.Zero;
                        uploadComplete.state = "complete";

                        result = LLSDHelpers.SerializeLLSDReply(uploadComplete);
                        // m_log.DebugFormat("[BAKED TEXTURE UPLOADER]: baked texture upload completed for {0}", newAssetID);
                    }

                    m_Caps.HttpListener.RemoveStreamHandler("POST", m_uploaderPath);
                    return(result);
                }
コード例 #4
0
            /// <summary>
            /// Handle a request from the client for a Uri to upload a baked texture.
            /// </summary>
            /// <param name="request"></param>
            /// <param name="path"></param>
            /// <param name="param"></param>
            /// <param name="httpRequest"></param>
            /// <param name="httpResponse"></param>
            /// <returns>The upload response if the request is successful, null otherwise.</returns>
            public string UploadBakedTexture(
                string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
            {
                try
                {
                    IAssetCache          assetCache   = m_Scene.CommsManager.AssetCache;
                    IJ2KDecoder          layerDecoder = m_Scene.RequestModuleInterface <IJ2KDecoder>();
                    String               uploaderPath = m_Caps.CapsBase + "/" + UUID.Random();
                    BakedTextureUploader uploader     = new BakedTextureUploader(m_Caps, uploaderPath, assetCache, layerDecoder);
                    m_Caps.HttpListener.AddStreamHandler(new BinaryStreamHandler("POST", uploaderPath, uploader.BakedTextureUploaded));

                    string uploaderURL = m_Caps.HttpListener.ServerURI + uploaderPath;
                    LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
                    uploadResponse.uploader = uploaderURL;
                    uploadResponse.state    = "upload";
                    return(LLSDHelpers.SerializeLLSDReply(uploadResponse));
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[UPLOAD BAKED TEXTURE HANDLER]: {0}{1}", e.Message, e.StackTrace);
                }

                return(null);
            }
コード例 #5
0
        private string SetEnvironmentSettings(string request, string path, string param,
                                              UUID agentID, Caps caps)
        {
            LLSDEnvironmentSetResponse setResponse = new LLSDEnvironmentSetResponse();

            m_log.WarnFormat("[{0}]: Environment POST handler for agentID {1}", Name, agentID);
            setResponse.regionID = regionID;
            setResponse.success  = false;

            if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false))
            {
                setResponse.fail_reason = "Insufficient estate permissions, settings has not been saved.";
                return(LLSDHelpers.SerializeLLSDReply(setResponse));
            }

            try
            {
                m_scene.StorageManager.DataStore.StoreRegionEnvironmentString(regionID, request);
                setResponse.success = true;

                m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}",
                                 Name, agentID, caps.RegionName);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[{0}]: Environment settings has not been saved for region {1}, Exception: {2} - {3}",
                                  Name, caps.RegionName, e.Message, e.StackTrace);

                setResponse.success     = false;
                setResponse.fail_reason = String.Format("Environment Set for region {0} has failed, settings has not been saved.", caps.RegionName);
            }

            string response = LLSDHelpers.SerializeLLSDReply(setResponse);

            return(response);
        }
コード例 #6
0
        /// <summary>
        /// Callback for a client request for ParcelVoiceInfo
        /// </summary>
        /// <param name="scene">current scene object of the client</param>
        /// <param name="request"></param>
        /// <param name="path"></param>
        /// <param name="param"></param>
        /// <param name="agentID"></param>
        /// <param name="caps"></param>
        /// <returns></returns>
        public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param,
                                             UUID agentID, Caps caps)
        {
            ScenePresence avatar     = scene.GetScenePresence(agentID);
            string        avatarName = avatar.Name;

            // - check whether we have a region channel in our cache
            // - if not:
            //       create it and cache it
            // - send it to the client
            // - send channel_uri: as "sip:regionID@m_sipDomain"
            try
            {
                LLSDParcelVoiceInfoResponse parcelVoiceInfo;
                string channelUri;

                if (null == scene.LandChannel)
                {
                    throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available",
                                                      scene.RegionInfo.RegionName, avatarName));
                }



                // get channel_uri: check first whether estate
                // settings allow voice, then whether parcel allows
                // voice, if all do retrieve or obtain the parcel
                // voice channel
                LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);

                m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}",
                                  scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param);

                // TODO: EstateSettings don't seem to get propagated...
                // if (!scene.RegionInfo.EstateSettings.AllowVoice)
                // {
                //     m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings",
                //                       scene.RegionInfo.RegionName);
                //     channel_uri = String.Empty;
                // }
                // else

                if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0)
                {
                    m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel",
                                      scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName);
                    channelUri = String.Empty;
                }
                else
                {
                    channelUri = ChannelUri(scene, land);
                }

                // fill in our response to the client
                Hashtable creds = new Hashtable();
                creds["channel_uri"] = channelUri;

                parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds);
                string r = LLSDHelpers.SerializeLLSDReply(parcelVoiceInfo);

                m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}",
                                  scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r);
                return(r);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later",
                                  scene.RegionInfo.RegionName, avatarName, e.Message);
                m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed",
                                  scene.RegionInfo.RegionName, avatarName, e.ToString());

                return("<llsd>undef</llsd>");
            }
        }
コード例 #7
0
        /// <summary>
        /// Callback for a client request for Voice Account Details
        /// </summary>
        /// <param name="scene">current scene object of the client</param>
        /// <param name="request"></param>
        /// <param name="path"></param>
        /// <param name="param"></param>
        /// <param name="agentID"></param>
        /// <param name="caps"></param>
        /// <returns></returns>
        public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param,
                                                   UUID agentID, Caps caps)
        {
            ScenePresence avatar = scene.GetScenePresence(agentID);

            if (avatar == null)
            {
                System.Threading.Thread.Sleep(2000);
                avatar = scene.GetScenePresence(agentID);

                if (avatar == null)
                {
                    return("<llsd>undef</llsd>");
                }
            }
            string avatarName = avatar.Name;

            try
            {
                m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}",
                                  request, path, param);

                //XmlElement    resp;
                string agentname = "x" + Convert.ToBase64String(agentID.GetBytes());
                string password  = "******";//temp hack//new UUID(Guid.NewGuid()).ToString().Replace('-','Z').Substring(0,16);

                // XXX: we need to cache the voice credentials, as
                // FreeSwitch is later going to come and ask us for
                // those
                agentname = agentname.Replace('+', '-').Replace('/', '_');

                lock (m_UUIDName)
                {
                    if (m_UUIDName.ContainsKey(agentname))
                    {
                        m_UUIDName[agentname] = avatarName;
                    }
                    else
                    {
                        m_UUIDName.Add(agentname, avatarName);
                    }
                }

                // LLSDVoiceAccountResponse voiceAccountResponse =
                //     new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api");
                LLSDVoiceAccountResponse voiceAccountResponse =
                    new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm,
                                                 String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress,
                                                               m_freeSwitchServicePort, m_freeSwitchAPIPrefix));

                string r = LLSDHelpers.SerializeLLSDReply(voiceAccountResponse);

                m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r);

                return(r);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}, retry later", avatarName, e.Message);
                m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1} failed", avatarName, e.ToString());

                return("<llsd>undef</llsd>");
            }
        }
コード例 #8
0
        public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param,
                                             UUID agentID, Caps caps)
        {
            m_log.DebugFormat(
                "[FreeSwitchVoice][PARCELVOICE]: ParcelVoiceInfoRequest() request: {0}, path: {1}, param: {2}", request, path, param);

            ScenePresence avatar = scene.GetScenePresence(agentID);

            if (avatar == null) // seen on the main grid, perhaps on user disconnect or viewer crash
            {
                return(EMPTY_RESPONSE);
            }

            string avatarName = avatar.Name;

            // - check whether we have a region channel in our cache
            // - if not:
            //       create it and cache it
            // - send it to the client
            // - send channel_uri: as "sip:regionID@m_sipDomain"
            try
            {
                LLSDParcelVoiceInfoResponse parcelVoiceInfo;
                string channel_uri;

                if (null == scene.LandChannel)
                {
                    throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available",
                                                      scene.RegionInfo.RegionName, avatarName));
                }

                // If the avatar is in transit between regions, avatar.AbsolutePosition calls below can return undefined values.
                if (avatar.IsInTransit)
                {
                    m_log.WarnFormat("[FreeSwitchVoice][PARCELVOICE]: Cannot process voice info request - avatar {0} is still in transit between regions.", avatarName);
                    return(EMPTY_RESPONSE);
                }

                // get channel_uri: check first whether estate
                // settings allow voice, then whether parcel allows
                // voice, if all do retrieve or obtain the parcel
                // voice channel
                Vector3  pos  = avatar.AbsolutePosition; // take a copy to avoid double recalc
                LandData land = scene.GetLandData(pos.X, pos.Y);
                if (land == null)
                {
                    // m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar\"{1}\" at ({2}): Land parcel not found.",
                    //                scene.RegionInfo.RegionName, avatarName, pos.ToString());
                    return(EMPTY_RESPONSE);
                }

                // TODO: EstateSettings don't seem to get propagated...
                if (!scene.RegionInfo.EstateSettings.AllowVoice)
                {
                    m_log.InfoFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings",
                                     scene.RegionInfo.RegionName);
                    channel_uri = String.Empty;
                }

                if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0)
                {
                    m_log.InfoFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel",
                                     scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName);
                    channel_uri = String.Empty;
                }
                else
                {
                    channel_uri = RegionGetOrCreateChannel(scene, land);
                }

                // fill in our response to the client
                Hashtable creds = new Hashtable();
                creds["channel_uri"] = channel_uri;

                parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds);
                string r = LLSDHelpers.SerializeLLSDReply(parcelVoiceInfo);

                return(r);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed",
                                  scene.RegionInfo.RegionName, avatarName, e.Message);
                m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} exception",
                                  scene.RegionInfo.RegionName, avatarName, e.ToString());

                return(EMPTY_RESPONSE);
            }
        }
コード例 #9
0
        public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param,
                                                   UUID agentID, Caps caps)
        {
            m_log.DebugFormat(
                "[FreeSwitchVoice][PROVISIONVOICE]: ProvisionVoiceAccountRequest() request: {0}, path: {1}, param: {2}", request, path, param);

            try
            {
                ScenePresence avatar     = null;
                string        avatarName = null;
                int           avatarWait = 10000; // milliseconds
                int           sleepWait  = 100;   // milliseconds

                if (scene == null)
                {
                    throw new Exception("[FreeSwitchVoice][PROVISIONVOICE] Invalid scene");
                }

                avatar = scene.GetScenePresence(agentID);
                while (avatar == null || avatar.IsInTransit)
                {
                    if (avatarWait <= 0)
                    {
                        m_log.WarnFormat("[FreeSwitchVoice][PROVISIONVOICE]: Timeout waiting for agent {0} to enter scene.", agentID);
                        return(EMPTY_RESPONSE);
                    }

                    Thread.Sleep(sleepWait);
                    avatarWait -= sleepWait;
                    avatar      = scene.GetScenePresence(agentID);
                }

                avatarName = avatar.Name;

                if (!scene.EventManager.TriggerOnBeforeProvisionVoiceAccount(agentID, avatarName))
                {
                    return(EMPTY_RESPONSE);
                }

                m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: scene = {0}, agentID = {1}", scene, agentID);
                m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}",
                                  request, path, param);

                string agentname = "x" + Convert.ToBase64String(agentID.GetBytes());
                string code      = String.Empty;

                agentname = agentname.Replace('+', '-').Replace('/', '_');

                UserAccount account = null;

                if (GetVoiceAccountInfo(agentname, avatarName, out account))
                {
                    LLSDVoiceAccountResponse voiceAccountResponse =
                        new LLSDVoiceAccountResponse(agentname, account.password, account.realm, String.Format("http://{0}/{1}", m_realm, m_apiPrefix));

                    string r = LLSDHelpers.SerializeLLSDReply(voiceAccountResponse);

                    m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r);

                    return(r);
                }

                m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: Get Account Request failed for \"{0}\"", avatarName);
                throw new Exception("Unable to execute request");
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[FreeSwitchVoice][PROVISIONVOICE]: : {0}, retry later", e.Message);
                m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: : {0} failed", e.ToString());
                return(EMPTY_RESPONSE);
            }
        }