Ably is the platform that powers synchronized digital experiences in realtime. Whether attending an event in a virtual venue, receiving realtime financial information, or monitoring live car performance data – consumers simply expect realtime digital experiences as standard. Ably provides a suite of APIs to build, extend, and deliver powerful digital experiences in realtime for more than 250 million devices across 80 countries each month. Organizations like Bloomberg, HubSpot, Verizon, and Hopin depend on Ably’s platform to offload the growing complexity of business-critical realtime data synchronization at global scale. For more information, see the Ably documentation.
This repository is a proof-of-concept demo of subscribing to Ably channels on Roku platform using Brightscript.
Bitflyer, Coindesk and Weather Data channels from Ably Hub are used to power this demo.
Note: this is an experimental proof of concept and is not intended for production use at this time.
Example screen capture from a Roku device:
If you would like to view the live examples on your own Roku device you can follow the steps listed in the Contributing -> Development Requirements section.
This proof of concept supports the following platforms:
Roku: Firmware versions 9.2 and greater
If you would like to try out this experimental work in your own channel you can copy the contents of source/components
into your channel's components
folder.
Example running and listening to an AblyTask
:
sub init()
' Create the AblyTask
m.ablyTask = createObject("roSGNode", "AblyTask")
' Assign the API to the task used for authentication
m.ablyTask.key = "xVLyHw.XuwW-w:yOPxtXWlsZn10nzy"
' Assign the channels you wish to subscribe to
m.ablyTask.channels = [
"[product:ably-bitflyer/bitcoin]bitcoin:jpy",
"[product:ably-coindesk/bitcoin]bitcoin:usd",
"[product:ably-openweathermap/weather]weather:5128581"
]
' Observe the event fields
m.ablyTask.observeField("messages", "onMessages")
m.ablyTask.observeField("error", "onError")
m.ablyTask.observeField("connected", "onConnected")
' Start the task
m.ablyTask.control = "RUN"
end sub
' Triggered when there is an error event
' @param {Object} event - The RoSGNodeEvent object with the callback data
sub onError(event as Object)
print "------------------ onError -----------------"
print event.getRoSGNode().channel, event.getData()
end sub
' Triggered when connected and subscribed to the channel
' @param {Object} event - The RoSGNodeEvent object with the callback data
sub onConnected(event as Object)
print "--------------- onConnected ----------------"
print event.getRoSGNode().channel, event.getData()
end sub
' Triggered when there are new messages to be handled.
' @param {Object} event - The RoSGNodeEvent object with the callback data
sub onMessages(event as Object)
print "---------------- onMessages ----------------"
messages = event.getData()
for each message in messages
print message.data
end for
end sub
If you want to use Ably on Roku platform please get in touch with the Ably team.
Ably is an enterprise-ready pub/sub messaging platform with integrated services to easily build complete realtime functionality delivered directly to end-users. We power the apps people and enterprises depend on everyday. Developers from startups to industrial giants build on Ably to simplify engineering, minimize DevOps overhead, and increase development velocity.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push the branch (
git push origin my-new-feature
) - Create a new Pull Request
For development and side loading of the channel we use VS Code with the BrightScript Language Extension.
You will also need to Enabling Developer Mode on your device.
Note: We will not be using the browser-based Development Application Installer shown in the video ourselves. The extension will be taking care of all of that for us in VS Code.
You will also need to create a .env
in the root of the project. This .env
file can be empty but if you wish to speed up side loading you can add the following values:
# This can ether be the IP address of your Roku
# or you can set it to ${promptForHost} and the
# extension will show you a list of devices on
# your network to pick from
ROKU_IP=111.111.111.111
# The password you set on the device when
# installing developer mode
ROKU_PASSWORD=aaaa
Once you have created your .env
file you are now ready to side load the channel. Simply click on Run
-> Start Debugging
or press F5
by default. The extension should take over from here.
- The ability to supply your own token is not yet supported
- Unlike the client libraries for other platforms messages are returned as array bundles
- If we get an update with many messages we send one
messageEvent
event object that has amessages
array containing all the messages rather than onemessage
event per message received. This is to reduce the number of times we need to cross thread boundaries - This means all events
messages
will be returned as an array
- If we get an update with many messages we send one