This module uses XBMC JSON-RPC Api V6 to provice a rich and simple API to communicate with XMBC instances.
xbmc module contains the following classes:
XbmcApi: API wrapper of available actions, notifications and media handling
TCPConnection: TCP Client to communicate with XBMC
All classes are created asynchronously.
All classes are sharing an
XbmcApi.emit are wrappers to the shared PubSub. For instance:
In CoffeeScript :
require 'xbmc'connection =host: '127.0.0.1'port: 9090verbose: truexbmc =xbmcsetConnection connectionxbmcon 'connection:open'-> consolelog 'Connection is open'xbmcon 'connection:data' consolelog 'Received data:'dataxbmcon 'connection:notification' consolelog 'Received notification:'notification
var Xbmc = ;var connection =host: '127.0.0.1'port: 9000verbose: false;var xbmcApi = ;xbmcApi;xbmcApi;xbmcApi;xbmcApi;
TCPConnection uses a deferred (promise) mechanism. Following two examples are both working:
require 'xbmc'connection =host: '127.0.0.1'port: 9090verbose: truexbmc =xbmcsetConnection connection# run actions after received a 'connection:open' eventxbmcon 'connection:open'->xbmcmessage 'Hello World'
connection =host: '127.0.0.1'port: 9090verbose: truexbmc =xbmcsetConnection connection# enqueu actions so they are called a soon as connection is openedxbmcmessage 'Hello World'
More actions, new helpers, tests, ...