Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the correct way to listen for a Google+ Hangout state change?

The Hangout API at https://developers.google.com/+/hangouts/writing includes an example to set a callback function when the hangout state has changed, like this:

gapi.hangout.onStateChanged.add(onStateChange);

When run, this results in an error similar to "gapi.hangout.onStateChanged is undefined". A quick check in Firebug shows that the onStateChanged method belongs to gapi.hangout.data not gapi.hangout.

What is the correct way to add a callback function when the state has changed?

like image 600
Rick Viscomi Avatar asked Dec 06 '25 14:12

Rick Viscomi


1 Answers

The method that you're looking for is indeed a member of gapi.hangout.data. The writing article you mention seems to be out of date. I fix it :)

To do something when state changes just attach a callback:

gapi.hangout.data.onStateChanged.add(function() {
  console.log(gapi.hangout.data.getState());
});

You can find working examples of the code in action on the sample apps page.

like image 125
mimming Avatar answered Dec 09 '25 00:12

mimming



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!