Create and return a websocket with an app stream.
- Source:
Example
const pnut = require("pnut-butter");
pnut.token = "MY_VALID_ACCESS_TOKEN";
const AppStreamSocket = require("pnut-butter/dist/app_stream_socket");
const ws = AppStreamSocket("myfancykeyname");
ws.on("open", event => {
console.log("Opening app stream");
});
ws.on("message", event => {
console.log(event.data);
});
ws.on("close", event => {
console.log("Closing app stream", event.code, event.reason);
});
Parameters:
Name | Type | Description |
---|---|---|
streamKey |
string | A valid stream key |
Returns:
- A connected websocket
- Type
- Object