Updating Chromecast receiver status text after start - chromecast

On my Chromecast custom receiver, I can set the status text like so:
const instance = cast.framework.CastReceiverContext.getInstance();
const options = new cast.framework.CastReceiverOptions();
options.statusText = 'Custom status text!!';
instance.start(options);
This text is displayed on potential cast senders.
I'd like to be able to change this text after the receiver instance has already been started. Is this possible? If so, how can it be done?

Having the application started, is possible to use CastReceiverContext to change the application status:
// call setApplicationState and pass the new statusText
instance.setApplicationState('New custom status text');
setApplicationState(statusText)
Sets the application state. The application should call this when its
state changes. If undefined or set to an empty string, the value of
the Application Name established during application registration is
used for the application state by default.
Parameter
statusText:string
The status text.
More information on the official docs.

Related

Variable inside socket.on('connect') not updating

This React with Socket.io.
[canPass, setCanPass] = useState(true)
[example, setExample] = useState('')
useEffect(()=>{
if(socket !== ''){
setCanPass(false)
console.log(example)
if(canPass){
socket.on('connect', ()=>{
console.log(example)
})
}
}
},[socket, example])
This code is inside of a Provider, so the variable "example" will change often.
Initial value of "socket" is an empty string. After the socket is created, the effect will set the listener "connect".
The flag "canPass" avoids setting the listener over and over any time the effect gets triggered.
NOW THE PROBLEM IS: Variable "example" updates normally inside of the Effect, but when the listener function is triggered (let's say server drops and reestablish, or user turn off and on wifi) variable "example" INSIDE of the listener function remains unchanged.
Any ideas how to fix this? Thanks!!
EDIT -> FIXED!
I don't really understand why this question is not that frecuent as I expected. Ok, so, the thing is an event can link more than one listener, and each listener is an instance of the function, it means, it creates a separated scope and the variables inside wont update.
To fix it, I just added another effect, observing the changes of variable "example", ereasing the listener with the method removeAllListeners() and set it again with the new values of "example". And that's it.

How to force synchronize MailItem with underlying MAPI object

I have developed a VSTO plug-in. We have hooked the ItemSend event in our code. When I try to send mail, I am trying to remove all attachments before sending it. However mail is still having all attachments which were removed. I can see them in send folder as well as in inbox.
Strange thing is that when I print count for number of attachments, it is giving 0. But when I print mime using MAPI object and APIs, it is still showing attachment there. It seems that MailItem object of OOM is not in synch with MAPI object.
Is there any way to enforce this synchronization.
I have written following code --
int numOfAttachments = mailItem.Attachments.Count;
for (int index = numOfAttachments; index > 0; --index)
{
Attachment attachment = mailItem.Attachments[index];
attachment.Delete();
Marshal.ReleaseComObject(attachment);
}
PrintInfo("Attachment count - " +
mailItem.Attachments.Count.ToString());
mailItem.Save();
string mimeSource = MimeParser.GetMimeSource(mailItem);
File.WriteAllText("C:\\Test\\Mime2.txt", mimeSource);
Marshal.ReleaseComObject(mailItem);
return;
I guess the Attachments.Remove method leads to same results, right?
First of all, I'd recommend releasing all underlying COM objects instantly. For example:
int numOfAttachments = mailItem.Attachments.Count;
The Attachments property returns an instance of the Attachments collection which is left alive. You need to release only objects you get from the Outlook object model via properties and methods. Use System.Runtime.InteropServices.Marshal.ReleaseComObject to release an Outlook object when you have finished using it. Then set a variable to Nothing in Visual Basic (null in C#) to release the reference to the object. You can read more about this in the Systematically Releasing Objects article in MSDN.
Finally, the ItemSend event handler allows to cancel the default action by setting the cancel parameter to true. So, you could do any modifications and send submit the mail item anew.

Set Recipient in MS Outlook Addin

I am attempting to add a recipient dynamically to the requiredAttendees for an Outlook appointment
var arr = [{emailAddress: 'test#example.com', displayName: 'Test Name'}]
Office.context.mailbox.item.requiredAttendees.addAsync(arr)
(also fails with arr = ['test#example.com'])
and it is throwing an error
Sys.ArgumentException: Sys.ArgumentException:
Value does not fall within the expected range.
How might that be accomplished?
Cf. docs which I am following
Cf. Radio-silence Github issue
UPDATE SCREEN SHOTS
PRE-THROW
You can notice that n is correctly defined as an array with 1 value (right panel)
Checking the same array as arr from the console evaluates to true
Throw
The script is throwing on evaluation (as indicated by the light green highlight)
To get dynamic URL params, I am loading an iframe onInit when Office is done initializing.
Though the rest of the API is available to the loaded iframe when passed in, there is something inherent to this particular piece of the API that must be dependent on window.
Moving the API call outside of the iframe fixes the issue and causes it to work as expected.

Changing the ACL on a PFObject does not persist to the Parse Server

When I save a change to the ACL on a PFObject (in this case, making it publicly writeable), the completion block runs successfully but the change is not actually saved to the server. Re-fetching the object, or viewing it via Parse Dashboard, shows that the ACL change is not persisted. In fact, I have verified via server logging that Parse server never even receives a request.
// first fetch an object from the parse server, then...
print("before: \(object.acl?.hasPublicWriteAccess)") // "false"
object.acl?.hasPublicWriteAccess = true
object.saveInBackground { (success, error) in
// confirm that success is true and error is nil
print("after: \(object.acl?.hasPublicWriteAccess)") // "true" - object is updated client-side
// now, re-fetch the same object or check it in Parse Dashboard. It is not saved as publicly editable.
}
When changing an object's ACL, the object itself is not marked as 'dirty', so saving it does not result in a request to the server. You can verify this by checking the isDirty property on the object after changing the ACL.
This is in common with other PFObjects - a change to a pointer property does not mark the parent object as dirty. This is not normally encountered since it is natural to simply save the pointer object itself. Since there is no PFACL.save() function, we can instead re-set the acl property on the object to ensure that it is marked as dirty:
object.acl?.hasPublicWriteAccess = toggle.isOn
object.acl = object.acl
object.saveEventually()
Additional discussion of this can be found in this issue.

Object reference not set to an instance of an object Xamarin.Forms using Acr.XamForms.UserDialog

In my app I fetch the data from the internet. While the data are being fetched I display a Loading dialog. For this I use Acr.XamForms.UserDiaologs library.
The code that I use is like below:
string Url = String.Format(category_url);
HttpClient hc = new HttpClient();
using (UserDialogs.Instance.Loading("Duke u ngarkuar..."))
contents = await hc.GetStringAsync(Url);
It works fine when I used in the inner pages of the app, but when I use in the first page it throws me the following error:
Object reference not set to an instance of an object
It must be something with a null reference value, have a look on the debugger to category_url, UserDialogs and double check if hc is being created correctly, step by step on your debugger.

Resources