Exemplo n.º 1
0
 def open(self):
     ''' When we receive a new websocket connect '''
     if self.session is not None and 'team_id' in self.session:
         logging.debug("[Web Socket] Opened new websocket with user id: %s" % (
             self.session['user_id'],
         ))
         notifications = Notification.new_messages(self.session['user_id'])
         logging.debug("[Web Socket] %d new notification(s) for user id %d" % (
             len(notifications), self.session['user_id']),
         )
         for notify in notifications:
             self.write_message(notify.to_dict())
             Notification.delivered(notify.user_id, notify.event_uuid)
     else:
         logging.debug("[Web Socket] Opened public notification socket.")
     self.start_time = datetime.now()
     self.manager.add_connection(self)