equal
deleted
inserted
replaced
68 return obj |
68 return obj |
69 |
69 |
70 |
70 |
71 class WampSession(wamp.ApplicationSession): |
71 class WampSession(wamp.ApplicationSession): |
72 def onConnect(self): |
72 def onConnect(self): |
73 secret = self.config.extra["secret"] |
73 if self.config.extra.has_key("secret"): |
74 if secret: |
|
75 user = self.config.extra["ID"].encode('utf8') |
74 user = self.config.extra["ID"].encode('utf8') |
76 self.join(u"Automation", [u"wampcra"], user) |
75 self.join(u"Automation", [u"wampcra"], user) |
77 else: |
76 else: |
78 self.join(u"Automation") |
77 self.join(u"Automation") |
79 |
78 |
141 def RegisterWampClient(wampconf, secretfname): |
140 def RegisterWampClient(wampconf, secretfname): |
142 |
141 |
143 WSClientConf = LoadWampClientConf(wampconf) |
142 WSClientConf = LoadWampClientConf(wampconf) |
144 |
143 |
145 if not WSClientConf: |
144 if not WSClientConf: |
146 print _("WAMP client connection not established!") |
145 print(_("WAMP client connection not established!")) |
147 return |
146 return |
148 |
147 |
149 WampSecret = LoadWampSecret(secretfname) |
148 WampSecret = LoadWampSecret(secretfname) |
150 |
149 |
151 # create a WAMP application session factory |
150 # create a WAMP application session factory |
162 url=WSClientConf["url"], |
161 url=WSClientConf["url"], |
163 serializers=[MsgPackSerializer()]) |
162 serializers=[MsgPackSerializer()]) |
164 |
163 |
165 # start the client from a Twisted endpoint |
164 # start the client from a Twisted endpoint |
166 conn = connectWS(transport_factory) |
165 conn = connectWS(transport_factory) |
167 print(_("WAMP client connecting to :"), _WSClientConf["url"]) |
166 print(_("WAMP client connecting to :"), WSClientConf["url"]) |
168 return conn |
167 return conn |
169 |
168 |
170 |
169 |
171 def GetSession(): |
170 def GetSession(): |
172 return _WampSession |
171 return _WampSession |