{"_id":"56acf23d2a7860170013f6f3","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"},"project":"56acd71213ac890d001c3c7a","parentDoc":null,"githubsync":"","__v":3,"category":{"_id":"56ad20660ab3c00d00ce3347","__v":11,"pages":["56ad21651c09150d00a183a0","56ad235c693f0a0d0085f0c3","56ad24afd21f1b0d00fd2f86","56ad2e5b1c09150d00a183a6","56ad305879011b0d00c32aaa","56ad30c81a7ee417009ced18","56ad31432a7860170013f711","56ad33b21a7ee417009ced1a","56ad34a0b9ac5517006b6962","56ad35503fc1020d009776e1","56e7266bdbc36117006a41ff"],"project":"56acd71213ac890d001c3c7a","version":"56acd71213ac890d001c3c7d","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-30T20:43:18.400Z","from_sync":false,"order":9,"slug":"singularity-real-time-events","title":"Singularity: Real-Time Events"},"user":"56acd6caa040860d00ac94a2","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-30T17:26:21.533Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"These events work for all connected channels\",\n  \"body\": \"Remember, if you're connected to multiple GameWisp channels on Singularity, the following real-time events will fire per channel. This makes it possible to use the same event listeners to handle data from multiple channels in real time!\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Basic Real-Time Event Structure\"\n}\n[/block]\nSingularity's real-time events are those fire automatically whenever an event occurs in the GameWisp application. Currently there are ten real-time events your application can listen on in order to receive data. Pick and choose the events that pertain to your particular use case. Data from real-time events is JSON formatted, and will have the following basic structure:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    event: \\\"event-name\\\",\\n    channel_id: \\\"channel identifier\\\",\\n    channel: {\\n      names: {\\n         gamewisp: \\\"GameWisp channel name\\\",\\n         twitch: \\\"twitch channel name\\\",\\n         youtube: \\\"youtube channel name\\\"\\n      },\\n      ids: {\\n         gamewisp: \\\"channel identifier\\\",\\n         twitch: \\\"12312312q\\\",\\n         youtube: \\\"UCiqp4J8asdkssssssssdfae\\\"\\n        }\\n    }\\n    data: {\\n        //data for the particular event.\\n    }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe **channel** object contains channel identifying information for GameWisp and any platform the channel may have linked to GameWisp (i.e., Twitch and/or YouTube).\n\nThe **data** object contains information pertaining to the event. This object is unique for every event type, but contains some common elements that are described as follows:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"ids: {\\n         gamewisp: \\\"1111\\\",\\n         twitch: \\\"22222222\\\",\\n  \\t\\t\\t youtube: \\\"39sdfadfs\\\"\\n      },\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Property\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"gamewisp\",\n    \"0-1\": \"integer - potentially string formatted\",\n    \"0-2\": \"The unique GameWisp ID of the contained object. This could be a channel ID, subscriber ID, user ID, etc.\",\n    \"1-0\": \"twitch\",\n    \"1-1\": \"integer - potentially string formatted\",\n    \"1-2\": \"The twitch ID of the object (e.g., user, twitch channel, etc.)\\n\\nIs **null** if the contained object is not linked to Twitch\",\n    \"2-0\": \"youtube\",\n    \"2-1\": \"string\",\n    \"2-2\": \"The YouTube identifier of the object.\\n\\nThis can be **null** if the object does not have a link to YouTube.\"\n  },\n  \"cols\": 3,\n  \"rows\": 3\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" names: {\\n         gamewisp: \\\"GameWisp channel name\\\",\\n         twitch: \\\"twitch channel name\\\",\\n         youtube: \\\"youtube channel name\\\"\\n      },\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nSimilar to the table above, each entry is the channel name for the channel's GameWisp, Twitch, and YouTube channel. Fields will be null if the channel has not linked the corresponding service.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"What Next?\"\n}\n[/block]\nNow that you know the basic structure of each real-time event. Check out the Singularity: Real-Time Events section of this documentation for a thorough description of each event.","excerpt":"Once your app is connected to a GameWisp channel, you can listen on the following events to receive data about that channel in real time.","slug":"real-time-events","type":"basic","title":"Real-Time Events Basics"}

Real-Time Events Basics

Once your app is connected to a GameWisp channel, you can listen on the following events to receive data about that channel in real time.

[block:callout] { "type": "info", "title": "These events work for all connected channels", "body": "Remember, if you're connected to multiple GameWisp channels on Singularity, the following real-time events will fire per channel. This makes it possible to use the same event listeners to handle data from multiple channels in real time!" } [/block] [block:api-header] { "type": "basic", "title": "Basic Real-Time Event Structure" } [/block] Singularity's real-time events are those fire automatically whenever an event occurs in the GameWisp application. Currently there are ten real-time events your application can listen on in order to receive data. Pick and choose the events that pertain to your particular use case. Data from real-time events is JSON formatted, and will have the following basic structure: [block:code] { "codes": [ { "code": "{\n event: \"event-name\",\n channel_id: \"channel identifier\",\n channel: {\n names: {\n gamewisp: \"GameWisp channel name\",\n twitch: \"twitch channel name\",\n youtube: \"youtube channel name\"\n },\n ids: {\n gamewisp: \"channel identifier\",\n twitch: \"12312312q\",\n youtube: \"UCiqp4J8asdkssssssssdfae\"\n }\n }\n data: {\n //data for the particular event.\n }\n}", "language": "json" } ] } [/block] The **channel** object contains channel identifying information for GameWisp and any platform the channel may have linked to GameWisp (i.e., Twitch and/or YouTube). The **data** object contains information pertaining to the event. This object is unique for every event type, but contains some common elements that are described as follows: [block:code] { "codes": [ { "code": "ids: {\n gamewisp: \"1111\",\n twitch: \"22222222\",\n \t\t\t youtube: \"39sdfadfs\"\n },", "language": "json" } ] } [/block] [block:parameters] { "data": { "h-0": "Property", "h-1": "Type", "h-2": "Description", "0-0": "gamewisp", "0-1": "integer - potentially string formatted", "0-2": "The unique GameWisp ID of the contained object. This could be a channel ID, subscriber ID, user ID, etc.", "1-0": "twitch", "1-1": "integer - potentially string formatted", "1-2": "The twitch ID of the object (e.g., user, twitch channel, etc.)\n\nIs **null** if the contained object is not linked to Twitch", "2-0": "youtube", "2-1": "string", "2-2": "The YouTube identifier of the object.\n\nThis can be **null** if the object does not have a link to YouTube." }, "cols": 3, "rows": 3 } [/block] [block:code] { "codes": [ { "code": " names: {\n gamewisp: \"GameWisp channel name\",\n twitch: \"twitch channel name\",\n youtube: \"youtube channel name\"\n },", "language": "json" } ] } [/block] Similar to the table above, each entry is the channel name for the channel's GameWisp, Twitch, and YouTube channel. Fields will be null if the channel has not linked the corresponding service. [block:api-header] { "type": "basic", "title": "What Next?" } [/block] Now that you know the basic structure of each real-time event. Check out the Singularity: Real-Time Events section of this documentation for a thorough description of each event.