本文整理汇总了Python中autobahn.wamp.WampClientFactory.protocol方法的典型用法代码示例。如果您正苦于以下问题:Python WampClientFactory.protocol方法的具体用法?Python WampClientFactory.protocol怎么用?Python WampClientFactory.protocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autobahn.wamp.WampClientFactory
的用法示例。
在下文中一共展示了WampClientFactory.protocol方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _connectClient
# 需要导入模块: from autobahn.wamp import WampClientFactory [as 别名]
# 或者: from autobahn.wamp.WampClientFactory import protocol [as 别名]
def _connectClient(self, connected, opened, clientDisconnected):
factory = WampClientFactory('ws://localhost:9000', debugWamp=True)
factory.protocol = ClientProtocol
factory.onConnectionMade = connected
factory.onSessionOpen = opened
factory.onConnectionLost = clientDisconnected
self.factory = factory
return connectWS(factory)
示例2: __init__
# 需要导入模块: from autobahn.wamp import WampClientFactory [as 别名]
# 或者: from autobahn.wamp.WampClientFactory import protocol [as 别名]
def __init__( self, host, auth=None ):
DEBUG = False
f = WampClientFactory( "ws://%s:2001" % host,
debugWamp = DEBUG)
f.protocol = WorkflowClientProtocol
f.rpcAuth = auth
f.cnx = self
self.session = None
self.__factory = f
self.nextRequestId = 1
self.__pending = { 0: [None,threading.Event()] }
self.__thread = threading.Thread( target=self.__run )
self.__thread.daemon = True
self.__thread.start()
示例3: publisher
# 需要导入模块: from autobahn.wamp import WampClientFactory [as 别名]
# 或者: from autobahn.wamp.WampClientFactory import protocol [as 别名]
def publisher(c_name="all", debug=True):
log.startLogging(sys.stdout)
if c_name != "all":
channel_name = "notifications:%s" % c_name
else:
channel_name = "notifications:all"
#print "user name in Publisher: ", channel_name
PUBSUB.subscribe(channel_name)
'''
factory = WampClientFactory("ws://%s:9000" % socket.gethostname(),
debugWamp=debug)
'''
factory = WampClientFactory("ws://localhost:9000", debugWamp=debug)
factory.protocol = PubSubClient1
connectWS(factory)
reactor.run()
示例4: start
# 需要导入模块: from autobahn.wamp import WampClientFactory [as 别名]
# 或者: from autobahn.wamp.WampClientFactory import protocol [as 别名]
def start( cls ):
f = WampClientFactory( "ws://localhost:2001", debugWamp=True )
f.protocol = NotificationProtocol
connectWS(f)
示例5: logerror
# 需要导入模块: from autobahn.wamp import WampClientFactory [as 别名]
# 或者: from autobahn.wamp.WampClientFactory import protocol [as 别名]
def logerror(self, e):
erroruri, errodesc, errordetails = e.value.args
print "ERROR: %s ('%s') - %s" % (erroruri, errodesc, errordetails)
def done(self, *args):
self.sendClose()
reactor.stop()
def onSessionOpen(self):
# Set the App Prefix
self.prefix("moirai", "http://%s/%s/" % (app_domain, app_name))
query = "START n=node(*) RETURN n;"
params = {}
self.call("moirai:cypher", query, params).addCallbacks(self.nodesFirst)
############## STUFF HAPPENS HERE #############
if __name__ == '__main__':
log.startLogging(sys.stdout)
factory = WampClientFactory("ws://%s:%s" % (ws_host, ws_port), debugWamp = True)
factory.protocol = SimpleClientProtocol
connectWS(factory)
reactor.run()
示例6: onPong
# 需要导入模块: from autobahn.wamp import WampClientFactory [as 别名]
# 或者: from autobahn.wamp.WampClientFactory import protocol [as 别名]
def onPong(self, payload):
id = payload[:16]
l = len(payload) - 16
now = datetime.datetime.utcnow()
if self.beats.has_key(id):
rtt_ms = (now - self.beats[id]).total_seconds() * 1000.
print "Got heartbeat: " + id, l, rtt_ms
if __name__ == '__main__':
if len(sys.argv) < 2:
print "Need the WebSocket server address, i.e. ws://localhost:9000"
sys.exit(1)
log.startLogging(sys.stdout)
debug = False
#factory = WebSocketClientFactory(sys.argv[1], debug = True, debugCodePaths = True)
factory = WampClientFactory(sys.argv[1],
debug = debug,
debugCodePaths = True,
debugWamp = debug)
factory.protocol = HeartbeatClientProtocol
connectWS(factory)
reactor.run()
示例7: printEvent
# 需要导入模块: from autobahn.wamp import WampClientFactory [as 别名]
# 或者: from autobahn.wamp.WampClientFactory import protocol [as 别名]
def printEvent(self, topicUri, event):
print "printEvent", topicUri, event
def sendSimpleEvent(self):
self.publish("http://example.com/simple", None)
reactor.callLater(2, self.sendSimpleEvent)
def onEvent1(self, topicUri, event):
self.counter += 1
self.publish("event:myevent2", {"trigger": event, "counter": self.counter})
def onSessionOpen(self):
self.counter = 0
self.subscribe("http://example.com/simple", self.printEvent)
self.sendSimpleEvent()
self.prefix("event", "http://example.com/event#")
self.subscribe("event:myevent1", self.onEvent1)
self.subscribe("event:myevent2", self.printEvent)
if __name__ == '__main__':
log.startLogging(sys.stdout)
factory = WampClientFactory("ws://localhost:9000")
factory.protocol = MyClientProtocol
connectWS(factory)
reactor.run()
示例8: addPuppy
# 需要导入模块: from autobahn.wamp import WampClientFactory [as 别名]
# 或者: from autobahn.wamp.WampClientFactory import protocol [as 别名]
self.prefix("pups", "http://spkvexample.com/pups")
self.addPuppy()
## Make changes to the list of dogs here, then run the script to publish them to the server
## NOTE: currently the client is hard-coded to talk to localhost
def addPuppy(self):
self.publish("pups:/", {
str(15): {
"name": "Dozer",
"about": "Victorian bulldog",
"favorite": False
}
# , str(13): {
# "name": "Mozart",
# "about": "The prodigal pup",
# "favorite": False
# }
})
if __name__ == '__main__':
log.startLogging(sys.stdout)
debug = len(sys.argv) > 1 and sys.argv[1] == 'debug'
factory = WampClientFactory("ws://localhost:9000", debugWamp = debug)
factory.protocol = PubSubClient1
connectWS(factory)
reactor.run()
示例9: onMessage
# 需要导入模块: from autobahn.wamp import WampClientFactory [as 别名]
# 或者: from autobahn.wamp.WampClientFactory import protocol [as 别名]
print "connected to Gephi"
def onMessage(self, msg, binary):
if not binary:
obj = json.loads(msg)
self.factory.forwarder.publish(GEPHI_TOPIC_URI + "1", obj)
class GephiForwardingProtocol(WampClientProtocol):
def onSessionOpen(self):
print "connected to WAMP server"
factory = WebSocketClientFactory(GEPHI_SERVER_URL)
factory.protocol = GephiClientProtocol
factory.forwarder = self
connectWS(factory)
if __name__ == '__main__':
log.startLogging(sys.stdout)
debug = len(sys.argv) > 1 and sys.argv[1] == 'debug'
factory = WampClientFactory(WAMP_SERVER_URL, debugWamp = debug)
factory.protocol = GephiForwardingProtocol
connectWS(factory)
reactor.run()
示例10: dataReceived
# 需要导入模块: from autobahn.wamp import WampClientFactory [as 别名]
# 或者: from autobahn.wamp.WampClientFactory import protocol [as 别名]
def dataReceived(self, data):
self.resetTimeout()
print len(data)
if len(data) == 11:
packet = Packet(data)
print packet
self._publish(packet.toDict())
reactor.callLater(0.1, self.sendCMD, 'GET')
else:
log.msg("Received Gargabe")
log.msg("LEN: %s " % len(data))
log.msg(data)
def lineReceived(self, line):
log.msg("Line Received")
log.msg(line)
if __name__ == '__main__':
##Setup Server
wampServerFactory = WampServerFactory("ws://localhost:9000")
wampServerFactory.protocol = TSPublisher
listenWS(wampServerFactory)
##Setup Client
wampClientFactory = WampClientFactory("ws://localhost:9000")
wampClientFactory.protocol = TSClient
connectWS(wampClientFactory)
reactor.run()
示例11: KeyValueClientProtocol
# 需要导入模块: from autobahn.wamp import WampClientFactory [as 别名]
# 或者: from autobahn.wamp.WampClientFactory import protocol [as 别名]
class KeyValueClientProtocol(WampClientProtocol):
def done(self, *args):
self.sendClose()
reactor.stop()
def show(self, key, value):
print key, value
def get(self, keys):
defs = []
for key in keys:
d = self.call("keyvalue:get", key).addCallback(lambda value, key = key: self.show(key, value))
defs.append(d)
return DeferredList(defs)
def onSessionOpen(self):
self.prefix("keyvalue", "http://example.com/simple/keyvalue#")
self.call("keyvalue:keys").addCallbacks(self.get).addCallback(self.done)
if __name__ == '__main__':
log.startLogging(sys.stdout)
factory = WampClientFactory("ws://localhost:8080/ws")
factory.protocol = KeyValueClientProtocol
connectWS(factory)
reactor.run()