equal
deleted
inserted
replaced
26 from __future__ import absolute_import |
26 from __future__ import absolute_import |
27 from __future__ import print_function |
27 from __future__ import print_function |
28 import sys |
28 import sys |
29 import traceback |
29 import traceback |
30 from threading import Thread, Event |
30 from threading import Thread, Event |
|
31 from builtins import str as text |
31 |
32 |
32 from twisted.internet import reactor, threads |
33 from twisted.internet import reactor, threads |
33 from autobahn.twisted import wamp |
34 from autobahn.twisted import wamp |
34 from autobahn.twisted.websocket import WampWebSocketClientFactory, connectWS |
35 from autobahn.twisted.websocket import WampWebSocketClientFactory, connectWS |
35 from autobahn.wamp import types |
36 from autobahn.wamp import types |
81 # start logging to console |
82 # start logging to console |
82 # log.startLogging(sys.stdout) |
83 # log.startLogging(sys.stdout) |
83 |
84 |
84 # create a WAMP application session factory |
85 # create a WAMP application session factory |
85 component_config = types.ComponentConfig( |
86 component_config = types.ComponentConfig( |
86 realm=unicode(realm), |
87 realm=text(realm), |
87 extra={"ID": ID}) |
88 extra={"ID": ID}) |
88 session_factory = wamp.ApplicationSessionFactory( |
89 session_factory = wamp.ApplicationSessionFactory( |
89 config=component_config) |
90 config=component_config) |
90 session_factory.session = WampSession |
91 session_factory.session = WampSession |
91 |
92 |
107 _WampConnection = RegisterWampClient() |
108 _WampConnection = RegisterWampClient() |
108 AddToDoBeforeQuit(reactor.stop) |
109 AddToDoBeforeQuit(reactor.stop) |
109 reactor.run(installSignalHandlers=False) |
110 reactor.run(installSignalHandlers=False) |
110 |
111 |
111 def WampSessionProcMapper(funcname): |
112 def WampSessionProcMapper(funcname): |
112 wampfuncname = unicode('.'.join((ID, funcname))) |
113 wampfuncname = text('.'.join((ID, funcname))) |
113 |
114 |
114 def catcher_func(*args, **kwargs): |
115 def catcher_func(*args, **kwargs): |
115 if _WampSession is not None: |
116 if _WampSession is not None: |
116 try: |
117 try: |
117 return threads.blockingCallFromThread( |
118 return threads.blockingCallFromThread( |