runtime/WampClient.py
branch#2486
changeset 2194 35d6b9321ffd
parent 2193 259df9ecf9ca
child 2195 2cef75d036c2
equal deleted inserted replaced
2193:259df9ecf9ca 2194:35d6b9321ffd
    71 
    71 
    72 
    72 
    73 class WampSession(wamp.ApplicationSession):
    73 class WampSession(wamp.ApplicationSession):
    74     def onConnect(self):
    74     def onConnect(self):
    75         if "secret" in self.config.extra:
    75         if "secret" in self.config.extra:
    76             user = self.config.extra["ID"].encode('utf8')
    76             user = self.config.extra["ID"]
    77             self.join(u"Automation", [u"wampcra"], user)
    77             self.join(u"Automation", [u"wampcra"], user)
    78         else:
    78         else:
    79             self.join(u"Automation")
    79             self.join(u"Automation")
    80 
    80 
    81     def onChallenge(self, challenge):
    81     def onChallenge(self, challenge):
    89     @inlineCallbacks
    89     @inlineCallbacks
    90     def onJoin(self, details):
    90     def onJoin(self, details):
    91         global _WampSession
    91         global _WampSession
    92         _WampSession = self
    92         _WampSession = self
    93         ID = self.config.extra["ID"]
    93         ID = self.config.extra["ID"]
    94         print('WAMP session joined by :', ID)
       
    95         for name in ExposedCalls:
    94         for name in ExposedCalls:
    96             regoption = types.RegisterOptions(u'exact', u'last')
    95             regoption = types.RegisterOptions(u'exact', u'last')
    97             yield self.register(GetCallee(name), u'.'.join((ID, name)), regoption)
    96             yield self.register(GetCallee(name), u'.'.join((ID, name)), regoption)
    98 
    97 
    99         for name in SubscribedEvents:
    98         for name in SubscribedEvents:
   100             yield self.subscribe(GetCallee(name), unicode(name))
    99             yield self.subscribe(GetCallee(name), unicode(name))
   101 
   100 
   102         for func in DoOnJoin:
   101         for func in DoOnJoin:
   103             yield func(self)
   102             yield func(self)
       
   103 
       
   104         print(_('WAMP session joined (%s) by:' % time.ctime()), ID)
   104 
   105 
   105     def onLeave(self, details):
   106     def onLeave(self, details):
   106         global _WampSession
   107         global _WampSession
   107         _WampSession = None
   108         _WampSession = None
   108         print(_('WAMP session left'))
   109         print(_('WAMP session left'))