本文整理汇总了Python中autobahn.wamp.WampClientFactory类的典型用法代码示例。如果您正苦于以下问题:Python WampClientFactory类的具体用法?Python WampClientFactory怎么用?Python WampClientFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WampClientFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, test, peerIndex, onReady, onGone):
WampClientFactory.__init__(self, test.testee.url)
self.test = test
self.peerIndex = peerIndex
self.onReady = onReady
self.onGone = onGone
self.proto = None
示例2: _connectClient
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)
示例3: __init__
def __init__(self, peerIndex, onReady, onGone, test, result):
assert(self.protocol)
WampClientFactory.__init__(self, test.testee.url)
self.peerIndex = peerIndex
self.onReady = onReady
self.onGone = onGone
self.test = test
self.result = result
self.proto = None
示例4: __init__
def __init__(self, options, debug):
self.options = options
self.user = "admin"
self.password = options["password"]
self.command = options["command"]
if self.command == 'connect':
self.reconnect = True
else:
self.reconnect = False
if options["spec"]:
self.config = json.loads(open(options["spec"]).read())
else:
self.config = None
WampClientFactory.__init__(self, options["wsuri"], debugWamp = debug)
示例5: __init__
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()
示例6: __init__
def __init__(self, config):
WampClientFactory.__init__(self, config.wsuri, debugWamp = config.debug)
self.config = config
self.receivedCnt = 0
self.receivedRtts = []
self.setProtocolOptions(failByDrop = False)
if config.skiputf8validate:
self.setProtocolOptions(utf8validateIncoming = False)
if config.skipmasking:
self.setProtocolOptions(maskClientFrames = False)
示例7: publisher
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()
示例8: __init__
def __init__(self, options, reactor):
self.options = options
self.done = False
WampClientFactory.__init__(self,
self.options.server,
debugWamp = self.options.debug)
示例9: onMessage
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
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: __init__
def __init__(self, case, onReady, onGone, subscribeTopics):
WampClientFactory.__init__(self, case.url, debug=case.debugWs, debugWamp=case.debugWamp)
self.case = case
self.onReady = onReady
self.onGone = onGone
self.subscribeTopics = subscribeTopics
示例12: KeyValueClientProtocol
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()
示例13: __init__
def __init__(self, url, debug = False, debugCodePaths = False, debugWamp = False, debugApp = False):
WampClientFactory.__init__(self, url, debug = debug, debugCodePaths = debugCodePaths)
self.spiders = {}
self.is_first = 0
示例14: logerror
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()
示例15: onPong
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()