def setup_frame(self, frame):
     print('AdminManager::setup_frame')
     users = Users.get_by_frame_id(frame['_id'])
     # for each user, if the user is connected, send frame:updated event to
     # websocket client (i.e. to admin page)
     for user in users:
         user_id = user['_id']
         if user_id in self.admins:
             for ws_uuid in self.admins[user_id]:
                 data = {'frame': frame}
                 self.admins[user_id][ws_uuid].send('frame:setup', data)
 def remove_frame_connection(self, frame_ws):
     print('AdminManager::remove_frame_connection: ' + frame_ws.frame_id)
     # get frame object from db
     frame = Frames.get_by_id(frame_ws.frame_id)
     # get users for this frame
     users = Users.get_by_frame_id(frame_ws.frame_id)
     # for each user, if the user is connected,
     # send frame:disconnected to the
     # websocket client
     for user in users:
         user_id = user['_id']
         if user_id in self.admins:
             for ws_uuid in self.admins[user_id]:
                 self.admins[user_id][ws_uuid].send(
                     'frame:disconnected', frame)
 def update_admin_frame(self, frame=None, frame_id=None):
     print('AdminManager::update_admin_frame')
     print(frame)
     if frame_id is not None:
         frame = Frames.get_by_id(frame_id)
     # get users for this frame
     users = Users.get_by_frame_id(frame['_id'])
     # for each user, if the user is connected, send frame:updated event to
     # websocket client (i.e. to admin page)
     for user in users:
         user_id = user['_id']
         if user_id in self.admins:
             for ws_uuid in self.admins[user_id]:
                 self.admins[user_id][ws_uuid].send(
                     'frame:frame_updated', frame)
 def add_frame_connection(self, frame_ws):
     print('AdminManager::add_frame_connection: ' + frame_ws.frame_id)
     # get frame object from websocket object
     frame = frame_ws.frame
     # get users for this frame
     users = Users.get_by_frame_id(frame['_id'])
     # for each user, if the user is connected,
     # send frame:connected event to each
     # websocket client they have open (i.e. to admin page)
     for user in users:
         user_id = user['_id']
         if user_id in self.admins:
             for ws_uuid in self.admins[user_id]:
                 self.admins[user_id][ws_uuid].send(
                     'frame:connected', frame)