{"_id":"56ad37781a7ee417009ced1d","parentDoc":null,"user":"56acd6caa040860d00ac94a2","version":{"_id":"56acd71213ac890d001c3c7d","project":"56acd71213ac890d001c3c7a","__v":15,"createdAt":"2016-01-30T15:30:26.928Z","releaseDate":"2016-01-30T15:30:26.928Z","categories":["56acd71313ac890d001c3c7e","56acd8f113ac890d001c3c81","56acd8f95ac4060d0027865e","56acd93a13ac890d001c3c82","56ad20660ab3c00d00ce3347","56ad356a2a7860170013f714","56ad47eb0ab3c00d00ce334f","56afd523bc304a0d00ace1df","56b29a019621f20d00efb37e","56b657e11bc6970d009feee7","5845cc3c39950c1b002afe77","5845cde163c11b250037967e","5846efd45d064323007b17b4","588604da4674e32300efd160","588627882393d50f00f1322c"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":1,"category":{"_id":"56ad356a2a7860170013f714","__v":5,"version":"56acd71213ac890d001c3c7d","pages":["56ad35e23fc1020d009776e3","56ad37781a7ee417009ced1d","56ad3859693f0a0d0085f0cd","56ad38d71c09150d00a183ad","56ad4721cdbb3d170064eaf9"],"project":"56acd71213ac890d001c3c7a","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-30T22:12:58.236Z","from_sync":false,"order":10,"slug":"singularity-on-demand-events","title":"Singularity: On-Demand Events"},"githubsync":"","project":"56acd71213ac890d001c3c7a","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-30T22:21:44.398Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"This event is used to request channels for which your application wants data. This event is the primary means of channel authorization, and is documented in detail in [Singularity - Connecting to a GameWisp Channel](https://gamewisp.readme.io/docs/connecting-to-a-gamewisp-channel-on-singularity). It is used as follows:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"socket.emit('channel-connect', {\\n    access_token: \\\"channel OAuth2 access token\\\" \\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThis event emits **app-channel-connected** back to your application. See the Successful Authorization section of this README for more discussion about channel authorization.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" socketClient.on('app-channel-connected', function(response){\\n      //Do something with the response                           \\n  });\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThe **response** is a JSON object of the form:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  result: {\\n    status: 1,\\n    message: \\\"Channel authenticated.\\\"\\n  },\\n  data: {\\n    channel_id: \\\"channel identifier\\\",\\n    status: 'authenticated',\\n    listening: true\\n  },\\n  channel:{\\n    names:{\\n      gamewisp: 'gamewisp channel name',\\n      twitch: 'twitch channel name',\\n      youtube: 'youtube channel name'\\n    },\\n    ids:{\\n      gamewisp: 'gamewisp channel id',\\n      twitch: 'twitch channel id',\\n      youtube: 'youtube channel id'\\n    }\\n  }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nSee [Singularity - Connecting to a GameWisp Channel](https://gamewisp.readme.io/docs/connecting-to-a-gamewisp-channel-on-singularity) for more information about this on-demand event.","excerpt":"Used to connect your application to a GameWisp channel's event stream.","slug":"channel-connect","type":"fn","title":"channel-connect"}

channel-connect

Used to connect your application to a GameWisp channel's event stream.

This event is used to request channels for which your application wants data. This event is the primary means of channel authorization, and is documented in detail in [Singularity - Connecting to a GameWisp Channel](https://gamewisp.readme.io/docs/connecting-to-a-gamewisp-channel-on-singularity). It is used as follows: [block:code] { "codes": [ { "code": "socket.emit('channel-connect', {\n access_token: \"channel OAuth2 access token\" \n});", "language": "javascript" } ] } [/block] This event emits **app-channel-connected** back to your application. See the Successful Authorization section of this README for more discussion about channel authorization. [block:code] { "codes": [ { "code": " socketClient.on('app-channel-connected', function(response){\n //Do something with the response \n });", "language": "javascript" } ] } [/block] The **response** is a JSON object of the form: [block:code] { "codes": [ { "code": "{\n result: {\n status: 1,\n message: \"Channel authenticated.\"\n },\n data: {\n channel_id: \"channel identifier\",\n status: 'authenticated',\n listening: true\n },\n channel:{\n names:{\n gamewisp: 'gamewisp channel name',\n twitch: 'twitch channel name',\n youtube: 'youtube channel name'\n },\n ids:{\n gamewisp: 'gamewisp channel id',\n twitch: 'twitch channel id',\n youtube: 'youtube channel id'\n }\n }\n}", "language": "json" } ] } [/block] See [Singularity - Connecting to a GameWisp Channel](https://gamewisp.readme.io/docs/connecting-to-a-gamewisp-channel-on-singularity) for more information about this on-demand event.