Ejemplo n.º 1
0
 def open(self):
     log.info("//////////// CollarSocket.open")
     self.socket_id = strings.random_string(10)
     CollarSocket.sockets[self.socket_id] = self
     self.device_id = None
     log.info("--> new collar socket_id %s" % self.socket_id)
     CollarSocket.send(self.socket_id, {'socket_id': self.socket_id})
Ejemplo n.º 2
0
 def open(self):
     log.info("//////////// WebSocket.open")
     user_id = strings.random_string(10)
     WebSocket.sockets[user_id] = self
     log.info("--> new user_id %s" % user_id)
     available_users = [uid for uid in WebSocket.users.keys() if WebSocket.users[uid] is None]
     log.info("--> available users: %s" % available_users)
     if len(available_users):
         partner_id = random.choice(available_users)
         WebSocket.users[partner_id] = user_id
         WebSocket.users[user_id] = partner_id
         log.info("--> entangled %s with %s" % (user_id, partner_id))
         WebSocket.send(user_id, "entangled")
         WebSocket.send(partner_id, "entangled")
     else:
         WebSocket.users[user_id] = None
         log.debug("--> no partner to entangle")
     log.debug("--> users %s" % WebSocket.users)
     WebSocket.send(user_id, user_id)
Ejemplo n.º 3
0
 def open(self):
     log.info("//////////// DisplaySocket.open")
     self.socket_id = strings.random_string(10)
     DisplaySocket.sockets[self.socket_id] = self
     log.info("--> new display socket_id %s" % self.socket_id)
     DisplaySocket.send(self.socket_id, {'socket_id': self.socket_id})