Did you properly get a channel's access_token?
Remember, an access_token is required to connect to a GameWisp Channel on Singularity.
Once you have an OAuth2 access_token for a GameWisp channel, you can connect to that channel through Singularity like so:
socket.emit('channel-connect', {
access_token: 'channel oauth2 access token'
});
If the token has expired, you will receive a message indicating as such. If thatās the case, you will need to refresh the token.
You can connect to multiple GameWisp channels
Want your app to connect to multiple GameWisp channels? Just use the 'channel-connect' event with another channel's access token and you'll receive real-time data from that channel, too!
Successful Authorization
Upon verifying the channelās access token, Singularity will emit the app-channel-connected event to your application, which you can listen for as follows:
socketClient.on('app-channel-connected', function(response){
//Do something with the response
});
The response is a JSON object of the form:
{
result: {
status: 1,
message: "Channel authenticated."
},
data: {
channel_id: "channel identifier",
status: 'authenticated',
listening: true
},
channel:{
names:{
gamewisp: 'gamewisp channel name',
twitch: 'twitch channel name',
youtube: 'youtube channel name'
},
ids:{
gamewisp: 'gamewisp channel id',
twitch: 'twitch channel id',
youtube: 'youtube channel id'
}
}
}
result contains the overall status of the call. A status of 1 indicates success, 0 indicates failure.
data contains the following:
parameter | type | description |
---|---|---|
id | string | The channelās identifying key. |
status | string | The status of the authorization attempt. āauthenticatedā for a successful authorization, āinvalidā if there is a problem with the key-identifier pair you passed in for that channel in channels-listen. |
listening | boolean | Indicates that you will receive real time data for the channel as it occurs. If you receive a listening: true for a channel, you will receive data for that channel from singularity in real-time as it occurs. |
The channel object identifies the channelās gamewisp name and id as well as twitch and youtube identifying information if available.
What Next?
Why not connect the channel you created in the Registering an Application step to your application and then try to send some test events?