# clients to channels by having a reference to an object of theirs. # # Only Bridge clients using the private API key may call the join command. # However, those clients may join other clients using the public API key on their behalf. # def start(): class TestHandler(object): def log(self, msg): print('Got message: %s' % (msg)); bridge.join_channel('testChannel', TestHandler(), callback=ready) # # Getting and calling a Bridge channel # # This can be done from any Bridge client connected to the same # Bridge server, regardless of language. # When a function call is made to a channel object, the requested # function will be executed on everyone in the channel # # Only Bridge clients using the private API key may call the join command. # def ready(*args): testChannel = bridge.get_channel('testChannel') print 'Sending message' testChannel.log('hello') bridge.connect(start)
from BridgePython.bridge import Bridge bridge = Bridge(api_key='f99ede2465de4114') def message_cb(msg): print msg forjs = """ handler.run = function(message_cb, start, end) { var temp = start + end; console.log(temp); message_cb(temp); } """ channel = bridge.get_channel('function-channel') channel.message(forjs) cluster = bridge.get_service('cluster') cluster.run(message_cb, 1, 3) cluster.run(message_cb, 5, 3) bridge.connect()