Simple question is, how do i detect in actionscript if user have blocked from writing data to shared object?
sharedObj = SharedObject.getLocal("rememberme");
This return always shared object but it's size is 0, even I have blocked shared object.
When I'm trying to save data to shared object and flush it, it throws me an error, because writing is blocked. So what would be the right way check if writing to shared object is disabled?
Error: Error #2130: Unable to flush SharedObject.
var my_so:SharedObject = SharedObject.getLocal("mySpace");
var flushStatus:String = null;
try {
flushStatus = my_so.flush();
} catch (error:Error) {
trace("Error...Could not write SharedObject to disk\n");
}
if (flushStatus != null) {
switch (flushStatus) {
case SharedObjectFlushStatus.PENDING :
trace("Requesting permission to save object...\n");
my_so.addEventListener(NetStatusEvent.NET_STATUS, onFlushStatus);
break;
case SharedObjectFlushStatus.FLUSHED :
trace("Value flushed to disk.\n");
break;
}
}
function onFlushStatus(event:NetStatusEvent):void {
trace("User closed permission dialog...\n");
switch (event.info.code) {
case "SharedObject.Flush.Success" :
trace("User granted permission -- value saved.\n");
break;
case "SharedObject.Flush.Failed" :
trace("User denied permission -- value not saved.\n");
break;
}
my_so.removeEventListener(NetStatusEvent.NET_STATUS, onFlushStatus);
}
If shared object is blocked u can catch the error report else if 0 it goes to SharedObjectFlushStatus.PENDING.
SOURCE
Related
In my gaming Unity ( 2021.3.2f1 version) project, I'm using remote config SDK ( 9.5.0) for finetuning the game data. Players can play on offline mode, in order to do that I'm setting default values of each config key from json local path. Below code shows the implementation of config method. SetupRemoteConfig() is called when the firebase app is initiliazed.
public void SetupRemoteConfig()
{
var remoteConfig = FirebaseRemoteConfig.DefaultInstance;
Dictionary<string, object> configDefaults = new Dictionary<string, object>();
configDefaults.Add(ConfigKeys.adjust_testMode.ToString(), true);
configDefaults.Add(ConfigKeys.ShopPageCoinPackConfigs.ToString(), GetDefaultJsonString(ConfigKeys.ShopPageCoinPackConfigs));
var configSettings = new ConfigSettings();
if (Debug.isDebugBuild)
{
configSettings.MinimumFetchInternalInMilliseconds = 0;
configSettings.FetchTimeoutInMilliseconds = 0;
}
else
{
configSettings.MinimumFetchInternalInMilliseconds = 900000;
configSettings.FetchTimeoutInMilliseconds = 12000;
}
remoteConfig.SetConfigSettingsAsync(configSettings).ContinueWithOnMainThread(task =>
{
//Set Default Config Values
remoteConfig.SetDefaultsAsync(configDefaults).ContinueWithOnMainThread(task =>
{
remoteConfig.FetchAndActivateAsync().ContinueWithOnMainThread(task =>
{
var info = remoteConfig.Info;
if (task.IsCanceled)
{
Debug.Log("Fetch canceled.");
}
else if (task.IsFaulted)
{
Debug.Log("Fetch encountered an error.");
}
else if (task.IsCompletedSuccessfully)
{
Debug.Log(String.Format("Remote data loaded and ready (last fetch time {0}).", info.FetchTime));
}
switch (info.LastFetchStatus)
{
case LastFetchStatus.Failure:
switch (info.LastFetchFailureReason)
{
case FetchFailureReason.Error:
Debug.Log("Fetch failed for unknown reason");
break;
case FetchFailureReason.Throttled:
Debug.Log("Fetch throttled until " + info.ThrottledEndTime);
break;
}
break;
case LastFetchStatus.Pending:
Debug.Log("Latest Fetch call still pending.");
break;
}
IDictionary<string, ConfigValue> values = remoteConfig.AllValues;
Debug.Log("Fetching firebase remote config data successful.");
OnDataFetched?.Invoke(values);
});
});
});
}
It works perfectly when Unity editor connects to Internet. However, when I test the offline mode of my game on the Unity Editor, all the default config values are loaded perfectly but remote config SDK throws an exception like this:
fetching failure: http code 0
UnityEngine.Debug:LogError (object)
Firebase.Platform.FirebaseLogger:LogMessage (Firebase.Platform.PlatformLogLevel,string)
Firebase.LogUtil:LogMessage (Firebase.LogLevel,string)
Firebase.LogUtil:LogMessageFromCallback (Firebase.LogLevel,string)
Firebase.AppUtil:PollCallbacks ()
Firebase.Platform.FirebaseAppUtils:PollCallbacks ()
Firebase.Platform.FirebaseHandler:Update ()
Firebase.Platform.FirebaseMonoBehaviour:Update ()
I try to catch this exception and continue loading the game, because default config values are loaded perfectly. However I couldn't catch the exception, it throws anyway. And Editor only logged "task.IsFaulted" condition. How can I catch this exception or how should I handle this error when firebase offline?
I am using QXmlSchemaValidator to validate my xml against different xsds.
My code is as follows:
bool MyClass::verify(QByteArray message)
{
bool successfulValidated = false;
for(QByteArray& xsd: _xsds)
{
QXmlSchema schema;
schema.load(xsd);
if(!schema.isValid())
throw Exception("schema not valid");
QXmlSchemaValidator msgValidator(schema);
if(msgValidator.validate(message))
{
successfulValidated = true;
break;
}
}
return successfulValidated;
}
If msgValidator.validate(message) is false I get and application output like
Error XSDError in file:///MyApplication.exe, at line 1, column 47: No definition for element MyXMLElement available.
I do not want these application output messages as they clutter my output window. Is there any way that I can either suppress these messages or handle them myself?
In case anyone has the same problem:
Just add your own MessageHandler to the QXmlSchema as described in this Topic.
I am working on the code that interacts with Aws s3 to perform various operations like create bucket, Delete bucket, upload and download files and so on.
An issue is occurring while trying to delete the bucket; Access Denied
At present, I am using Root user credentials to create and delete the bucket. No versioning is enabled and could not see any bucket Policy in AWS Console attached to this bucket.
It is showing strange behaviour; sometimes gives access denied error while trying to delete the empty bucket , sometime it just gets delete effortlessly.
I am able to delete the bucket via AWs s3 console without any trouble. It is just through the code it is behaving random.
Can please somebody explain; what could be the reason?
here is my code
public string DeleteBucket(string bucketName, string S3Region)
{
string sts = "";
Chilkat.Http http = new Chilkat.Http();
// Insert your access key here:
http.AwsAccessKey = "AccessKey";
http.AwsSecretKey = "SecretKey"; //root user
http.AwsRegion = S3Region;
bool success = http.S3_DeleteBucket(bucketName);
if (success != true)
{
return sts = "{\"Status\":\"Failed\",\"Message\":\""http.lastErrorText"\"}";
}
else
{
return sts = "{\"Status\":\"Success\",\"Message\":\"Bucket deleted!\"}";
}
}
You should examine the HTTP response body to see the error message from AWS.
For example:
http.KeepResponseBody = true;
bool success = http.S3_DeleteBucket(bucketName);
if (success != true) {
Debug.WriteLine(http.LastErrorText);
// Also examine the error response body from AWS:
Debug.WriteLine(http.LastResponseBody);
}
else {
Debug.WriteLine("Bucket created.");
}
I am working on a project that retrieve Google Drive docs list using ASP.NET, but I'm getting an error:
An error occurred: Google.Apis.Requests.RequestError Daily Limit for
Unauthenticated Use Exceeded. Continued use requires signup. [403]
This is my site (getting error on this link) : http://www.netdesklive.com/
I am trying DrEdit code for this, but not working proper.
I set all the credential as per https://developers.google.com/drive/examples/dotnet but still i m getting an error
So Please, Suggest me
Code :
-> I am getting null value in state and code
public ActionResult Index(string state, string code)
{
try
{
IAuthenticator authenticator = Utils.GetCredentials(code, state);
// Store the authenticator and the authorized service in session
Session["authenticator"] = authenticator;
Session["service"] = Utils.BuildService(authenticator);
}
catch (CodeExchangeException)
{
if (Session["service"] == null || Session["authenticator"] == null)
{
Response.Redirect(Utils.GetAuthorizationUrl("", state));
}
}
catch (NoRefreshTokenException e)
{
Response.Redirect(e.AuthorizationUrl);
}
DriveState driveState = new DriveState();
if (!string.IsNullOrEmpty(state))
{
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
driveState = jsonSerializer.Deserialize<DriveState>(state);
}
if (driveState.action == "open")
{
return OpenWith(driveState);
}
else
{
return CreateNew(driveState);
}
}
Your error message suggests that your requests are not authorized. You should authorize them using Oauth2 :
Authorizing Drive requests
Google Oauth2 documentation
Cant find any solution for this. Im trying to store some data on remote shared object and retrieve it. At the moment im working locally. Anyway, i read probably all posts on internet about that and still cant understand where is my problem. I managed to store arguments on rso, but when i tried to receive those values, im only getting undefined.
Here is my code for the version when im only working with client side and on server side just watching when client connects to shared objects or changes the value.
protected function application1_creationCompleteHandler(event:FlexEvent):void {
var room_id:Number = vars("room");
connection = new NetConnection();
connection.connect("rtmp://127.0.0.1/video/" + room_id);
connection.addEventListener(NetStatusEvent.NET_STATUS, onConnected);
connection.client = this;
}
private function onConnected(event:NetStatusEvent) : void {
if(event.info.code == "NetConnection.Connect.Success") {
so = SharedObject.getRemote("video", connection.uri, true);
so.addEventListener(SyncEvent.SYNC, onSync);
so.connect(connection);
// if i try to trace so in there it will be undefined
} else {
Alert.show("Unsuccessful Connection", "Information");
}
And finally:
private function onSync(event:SyncEvent):void {
for(var i:Object in event.changeList) {
var changeObj:Object = event.changeList[i];
switch(changeObj.code) {
case "success":
if(so.data.cameras) {
Alert.show(this.so.data.cameras.toString(), "I changed it");
} else {
Alert.show("I changed", "Information");
}
break;
case "change":
if(so.data.cameras)
Alert.show(so.data.cameras.toString(), "First");
else if (this.so.data.cameras) {
Alert.show(this.so.data.cameras.toString(), "Second");
} else {
Alert.show("Can't found changed value", "Error");
}
break;
}
}
}
And here we go, i always get the undefined value of cameras, unless im the client who is changing the value, but everybody else gets undefined value. So i cant understand, all listeners a noticed about changes, on the server side code i see that i have changes, and i even opened persistent red5 shared object file and i see there is value, but i just cant retrieve it. Anybody has a solution? I would be very grateful.
Updated:
Answer is here: rso between flex and red5. I can create but cant read