equal
deleted
inserted
replaced
19 |
19 |
20 # You should have received a copy of the GNU Lesser General Public |
20 # You should have received a copy of the GNU Lesser General Public |
21 # License along with this library; if not, write to the Free Software |
21 # License along with this library; if not, write to the Free Software |
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
23 |
23 |
|
24 |
|
25 from __future__ import print_function |
24 import sys |
26 import sys |
25 from autobahn.twisted import wamp |
27 from autobahn.twisted import wamp |
26 from autobahn.twisted.websocket import WampWebSocketClientFactory, connectWS |
28 from autobahn.twisted.websocket import WampWebSocketClientFactory, connectWS |
27 from twisted.internet.defer import inlineCallbacks |
29 from twisted.internet.defer import inlineCallbacks |
28 from autobahn.wamp import types |
30 from autobahn.wamp import types |
66 @inlineCallbacks |
68 @inlineCallbacks |
67 def onJoin(self, details): |
69 def onJoin(self, details): |
68 global _WampSession |
70 global _WampSession |
69 _WampSession = self |
71 _WampSession = self |
70 ID = self.config.extra["ID"] |
72 ID = self.config.extra["ID"] |
71 print 'WAMP session joined by :', ID |
73 print('WAMP session joined by :', ID) |
72 for name in ExposedCalls: |
74 for name in ExposedCalls: |
73 reg = yield self.register(GetCallee(name), '.'.join((ID, name))) |
75 reg = yield self.register(GetCallee(name), '.'.join((ID, name))) |
74 |
76 |
75 for name in SubscribedEvents: |
77 for name in SubscribedEvents: |
76 reg = yield self.subscribe(GetCallee(name), name) |
78 reg = yield self.subscribe(GetCallee(name), name) |
79 yield func(self) |
81 yield func(self) |
80 |
82 |
81 def onLeave(self, details): |
83 def onLeave(self, details): |
82 global _WampSession |
84 global _WampSession |
83 _WampSession = None |
85 _WampSession = None |
84 print 'WAMP session left' |
86 print('WAMP session left') |
85 |
87 |
86 |
88 |
87 class ReconnectingWampWebSocketClientFactory(WampWebSocketClientFactory, ReconnectingClientFactory): |
89 class ReconnectingWampWebSocketClientFactory(WampWebSocketClientFactory, ReconnectingClientFactory): |
88 def clientConnectionFailed(self, connector, reason): |
90 def clientConnectionFailed(self, connector, reason): |
89 print("WAMP Client connection failed .. retrying ..") |
91 print("WAMP Client connection failed .. retrying ..") |
123 debug=False, |
125 debug=False, |
124 debug_wamp=False) |
126 debug_wamp=False) |
125 |
127 |
126 # start the client from a Twisted endpoint |
128 # start the client from a Twisted endpoint |
127 conn = connectWS(transport_factory) |
129 conn = connectWS(transport_factory) |
128 print "WAMP client connecting to :", WSClientConf["url"] |
130 print("WAMP client connecting to :", WSClientConf["url"]) |
129 return conn |
131 return conn |
130 |
132 |
131 |
133 |
132 def GetSession(): |
134 def GetSession(): |
133 global _WampSession |
135 global _WampSession |