def on_leave_room(data): leave_room(session["room"]) session["room"] = None rc.zrem( app.config["ROOM_ONLINE_USER_CHANNEL"].format(room=session["room"]), current_user.username) redirect(url_for("index"))
def left(message): """Sent by clients when they leave a room. A status message is broadcast to all people in the room.""" room = message.get('room') user = message.get('user') leave_room(room) emit('user left', {'msg': user + ' has left the room.'}, room=room)
def left(message): """Sent by clients when they leave a room. A status message is broadcast to all people in the room.""" room = session.get('room') leave_room(room) emit('status', {'msg': session.get('name') + ' has left the room.'}, room=room)
def leave_the_room(message): """removes user from room, from rooms dictionary, alerts other client in room""" leave_room(message['room']) rooms[message['room']].remove(session['login']) emit('display_disconnect_alert', {'leaving_usr':session['login']}, room=message['room'])
def on_leave(data): room = data['room'] socketio.leave_room(room) message = {} insert_user_info(message) leave_room(room, message['user_id']) socketio.emit('userLeave', message, namespace='/chat', room=room)
def leave_the_room(message): """removes user from room, from rooms dictionary, alerts other client in room""" leave_room(message['room']) rooms[message['room']].remove(session['login']) emit('display_disconnect_alert', {'leaving_usr': session['login']}, room=message['room'])
def on_join(room): db = connectToDB() cur = db.cursor(cursor_factory=psycopg2.extras.DictCursor) global messages subbedRooms = [] cur.execute( "SELECT rooms.roomname FROM rooms JOIN subscriptions ON rooms.id = subscriptions.room_id JOIN users ON subscriptions.user_id = users.id WHERE users.username = %s;", (users[session['uuid']]['username'], )) subbedRooms = cur.fetchall() print subbedRooms if room in subbedRooms: leave_room(users[session['uuid']]['room']) print 'Leaving room ' + users[session['uuid']]['room'] for message in messages: emit('refreshMessages') messages = [] users[session['uuid']]['room'] = room[0] join_room(users[session['uuid']]['room']) print users[session['uuid']]['username'] + ' joined room ' + users[ session['uuid']]['room'] cur.execute("select * from issmessages where room = %s;", (users[session['uuid']]['room'], )) results = cur.fetchall() if (len(results) > 0): for result in results: tmp = {'text': result[2], 'name': result[1]} messages.append(tmp) emit('message', tmp, room=users[session['uuid']]['room']) emit('joined', users[session['uuid']]['room']) else: print 'You are not subscribed to that chatroom'
def on_leave(room): if str(room) in clients: if request.namespace.socket.sessid in clients[str(room)]: logger('Client id ' + request.namespace.socket.sessid + ' has left the room ' + str(room)) print 'Client id ' + request.namespace.socket.sessid + ' has left the room ' + str(room) leave_room(str(room)) clients[str(room)].remove(request.namespace.socket.sessid)
def chat_window_close(message): """Sent by clients when they leave a room. A status message is broadcast to all people in the room.""" room = int(message["sender_id"][0:4]) + int(message["sender_id"][5:9]) room = room + int(message["receiver_id"][0:4]) + int(message["receiver_id"][5:9]) leave_room(room) emit('status', {"status":"close"}, room = room)
def on_join(room): db = connectToDB() cur = db.cursor(cursor_factory=psycopg2.extras.DictCursor) global messages subbedRooms = [] cur.execute("SELECT rooms.roomname FROM rooms JOIN subscriptions ON rooms.id = subscriptions.room_id JOIN users ON subscriptions.user_id = users.id WHERE users.username = %s;", (users[session['uuid']]['username'],)) subbedRooms = cur.fetchall() print subbedRooms if room in subbedRooms: leave_room(users[session['uuid']]['room']) print 'Leaving room ' + users[session['uuid']]['room'] for message in messages: emit('refreshMessages') messages = [] users[session['uuid']]['room'] = room[0] join_room(users[session['uuid']]['room']) print users[session['uuid']]['username'] + ' joined room ' + users[session['uuid']]['room'] cur.execute("select * from issmessages where room = %s;", (users[session['uuid']]['room'],)) results = cur.fetchall() if(len(results) > 0): for result in results: tmp = {'text': result[2], 'name': result[1]} messages.append(tmp) emit('message', tmp, room=users[session['uuid']]['room']) emit('joined', users[session['uuid']]['room']) else: print 'You are not subscribed to that chatroom'
def left(message): """Sent by clients when they leave a room. A status message is broadcast to all people in the room.""" room = session.get('room') user_name = session.get('name') leave_room(room) msg = CreateAddMessage(' has left the room.', room, user_name, True) emit('status', {'msg': msg }, room=room)
def left(message): """Sent by clients when they leave a room. A status message is broadcast to all people in the room.""" room = session.get('room') session['room']='' session['name']='' leave_room(room) emit('status', {'msg': session.get('name') + ' has left the room.'}, room=room)
def on_leave(data): name = session['username'] session['receive_count'] = session.get('receive_count', 0) - 1 room = data['room'] leave_room(room) global broadcasting broadcasting = False emit('my response', {'data': name + ' has left the room.' + room}, broadcast=broadcasting)
def leave(message): time = datetime.datetime.now() leave_room(message['room']) emit('my response', {'data': 'Leave rooms: ' + ', '.join(request.namespace.rooms), 'username': message['username'], 'server_time': time}, room=message['room'])
def clear_user(user): try: game = user_games[user] except KeyError: return emit('left', {}, room=game.room) leave_room(game.room) del user_games[user]
def leave(data): room = data['room'] if not room in g.games: return socketio.send('Room {} does not exist.'.format(room)) leave_room(data['room']) print('{username} has left the room {room}'.format(**data))
def ui_state_update(key_val): leave_room("raSlaves") key, val = key_val print 'ui state SET', key UI_STATE[key.replace("reduxPersist:", "")] = json.loads(val) emit("state_update", json.dumps(UI_STATE), namespace="/ui_state", room="raSlaves")
def handle_leave(data): """User leaves the room.""" username = data['username'] room = 'room' leave_room(room) if username in USERS: USERS.remove(username) emit('users', {'users': sorted(USERS)}, room=room)
def room_leave(message): if current_user.activeRoomId: leave_room(current_user.activeRoomId) current_user.activeRoomId = None db.session.commit() emit('left_room', {})
def on_leave(data): Before_request() leave_room(data["room"]) roomStatus = g.user.user_name + " has left room " + data["room"] print roomStatus emit('room status', roomStatus, room = data["room"])
def left(message): '''A user has left the room. Broadcast the status message to everybody in the room and update&broadcast the list of active logged-in users to the room''' room = session.get('room') leave_room(room) active_users[room].remove(session['name']) emit('status', {'msg': session.get('name') + ' has left the room.'}, room=room) emit('active', {'msg': '\n'.join(list(active_users[room])) }, room=room)
def left(message): """Sent by clients when they leave a room. A status message is broadcast to all people in the room.""" room = session.get('room') if room in active_bots.keys(): active_bots[room] = None leave_room(room) emit('status', {'msg': session.get('name') + ' has left the room.'}, room=room)
def leave(message): leave_room(message['room']) session['receive_count'] = session.get('receive_count', 0) + 1 emit( 'my response', { 'data': 'In rooms: ' + ', '.join(request.namespace.rooms), 'count': session['receive_count'] })
def dc(): room = session.get('room') leave_room(room) rooms[room].remove(session.get('user')) if len(rooms[room] == 0): del (rooms[room]) msg = '<' + session.get('user') + ' left the chat>' emit('message', {'msg': msg}, room=room)
def left(message): '''A user has left the room. Broadcast the status message to everybody in the room and update&broadcast the list of active logged-in users to the room''' room = session.get('room') leave_room(room) active_users[room].remove(session['name']) emit('status', {'msg': session.get('name') + ' has left the room.'}, room=room) emit('active', {'msg': '\n'.join(list(active_users[room]))}, room=room)
def on_leave(): username = session["username"] room = session["room"] emin( "server_response", {"owner": server_name, "text": username + " has left the room " + room}, room=room ) leave_room(room)
def on_leave(data): """ Sent by clients when the leave a room """ username = session["login"][0] room = find_room(data["bookgroup_id"], data.get("chapter_number")) leave_room(room) emit('leave_status', {'msg': username + " has left room " + str(room)}, room=room)
def on_leave_jobs(): """ Somebody left a room """ if 'room' in flask.session: room = flask.session['room'] del flask.session['room'] #print '>>> Somebody left room %s' % room leave_room(room)
def leave(): #registers as a user leaving if user has 'logged into' chat if 'name' in session: emit('remove', {'user' : session['name']}, room=room) del(cursors[session['name']]) global ctr ctr -= 1 emit('msg', {'message' : session['name'] + " has left!", 'online' : ctr} , room=room) leave_room(room)
def OnLeave(data): BeforeRequest() leave_room(data["room"]) emit('room left response', { 'status': u'ok', 'message': g.user.user_name + " has left room " + data["room"] }, room=data["room"])
def dc(): room = session.get('room') leave_room(room) rooms[room].remove(session.get('user')) if len(rooms[room] == 0): del(rooms[room]) msg = '<' + session.get('user') +' left the chat>' emit('message', {'msg': msg}, room=room)
def test_disconnect(): print('Client disconnected') try: user = session['user'] users.remove(user) leave_room(user) except (KeyError, ValueError) as e: print('There was an error =(') print(users) emit('userLeft', {'users': sorted(users)}, broadcast=True)
def ui_state_update(key_val): print request.sid, 'leaving slaves room' leave_room('raSlaves') key, val = key_val print 'ui state SET', key UI_STATE[key.replace("reduxPersist:", "")] = json.loads(val) #print ' '*10,json.loads(val) emit("state_update", json.dumps(UI_STATE), namespace="/ui_state", room="raSlaves")
def on_leave(data): global players username = session['username'] email = session['email'] room = data['room'] leave_room(room) if players.has_key(room): for i in range(players[room][0].__len__()): print i if players[room][0][i].email == email: check_out_player(players[room][0].pop(i)) send(username + ' has left the room.', room=room)
def request_join(message): print (message) from_room = message['from'] to_room = message['to'] leave_room(from_room) join_room(to_room) if to_room not in peers: peers[to_room] = [] if from_room: peers[from_room].remove(message['peer']) peers[to_room].append(message['peer']) emit('join confirm', {'room': to_room, 'peers': peers[to_room]}, room=to_room)
def leave(message): leave_room(message['room']) if not socketio.rooms or ('/console' in socketio.rooms.keys() and message['room'] not in socketio.rooms['/console'].keys()): console = Console.query.filter_by(name=message['room']).first() for button in console.buttons: try: greenlets.pop('serving-{}'.format(button.id)).kill() except KeyError: pass for shell in console.shells: shell_kill(shell.id)
def leave(): #registers as a user leaving if user has 'logged into' chat if 'name' in session: emit('remove', {'user': session['name']}, room=room) del (cursors[session['name']]) global ctr ctr -= 1 emit('msg', { 'message': session['name'] + " has left!", 'online': ctr }, room=room) leave_room(room)
def left(message): """Sent by clients when they leave a room. A status message is broadcast to all people in the room.""" room = session.get('room') username = session.get('name') leave_room(room) backend = utils.get_backend() backend.leave_room(username,room) end_chat() app.logger.debug("Testing logger: User {} left room {}.".format(username,room)) emit('status', {'msg': session.get('name') + ' has left the room or been disconnected. Please ' 'click the link below to find a new opponent.'}, room=room)
def on_join(roomname): print "Joining room" oldroom = session['roomname'] username = session['username'] conn = connectToMessageDB() cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor) session['roomname'] = roomname leave_room(oldroom) join_room(roomname) cur.execute("SELECT * FROM messages WHERE room = %s;", (roomname,)) messages = cur.fetchall() for message in messages: emit('message', message)
def left(message): """Sent by clients when they leave a room. A status message is broadcast to all people in the room.""" room = session.get('room') leave_room(room) msg = find_links_in_message( u'<i> has left the <strong>${}</strong> room.</i>'.format(room), session.get('name'), session.get('avatar') ) emit('status', { 'msg': msg }, room=room)
def joinRoom(roomName): print("joining room", roomName) #print(rooms()) tempMessages = getMessages(roomName) leave_room(session['room']) join_room(roomName) session['room'] = roomName print(tempMessages) emit('joinRoom', roomName) joinMessage = {'text': session['username'] + ' has joined the room', 'name': 'Bot'} emit('message', joinMessage, broadcast=True, room=roomName) for message in tempMessages: print(message) emit('message', message)
def add_room(message): b=int(message['data']) try: leave_room(b) if session['room'] == b: emit('send_room_form_update',{'code': -1}) to_delete=User_list.query.filter_by(chat_id=b).first() db.session.delete(to_delete) db.session.commit() update_room_list() except IntegrityError: return False except: raise
def onNewRoom(oldRoom, newRoom, name): print("room change: " + newRoom) global newroom global oldroom newroom = newRoom oldroom = oldRoom conn = connectToDB() cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor) leave_room(oldRoom) emit('resetMessages') if (newRoom == 'general'): emit('enableMessagePosts') join_room('general') query = "SELECT name1, message, room FROM messages WHERE room='general';" cur.execute(query) message = {} results = cur.fetchall() for result in results: message['name'] = result['name1'] message['text'] = result['message'] message['room'] = result['room'] emit('sendMessages', message) else: query = """SELECT * from subscription WHERE roomid = (SELECT id FROM rooms WHERE room1 = %s) AND userid = (SELECT id FROM users where username = %s);""" cur.execute(query, (newRoom, name)) if (cur.fetchone()): join_room(newRoom) emit('enableMessagePosts') query = "SELECT name1, message, room FROM messages WHERE room = '%s';" cur.execute(query % newRoom) message = {} results = cur.fetchall() for result in results: message['name'] = result['name1'] message['text'] = result['message'] message['room'] = result['room'] emit('sendMessages', message) print(message) else: emit('disableMessagePosts')
def left(message): """Sent by clients when they leave a room. A status message is broadcast to all people in the room.""" room = session.get('room') username = session.get('name') leave_room(room) backend = utils.get_backend() backend.leave_room(username, room) end_chat() app.logger.debug("Testing logger: User {} left room {}.".format( username, room)) emit('status', { 'msg': session.get('name') + ' has left the room or been disconnected. Please ' 'click the link below to find a new opponent.' }, room=room)
def leave(message): """ leave function catches any a left signal emitted by socketIO client It emits a signal to all users in that room notifying that the user has left the chat conversation :param message: Leave Message """ chatID = session.get('room') leave_room(chatID) ts = time.time() st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') client, db = open_db_connection() db['chat_log'][session['room']].insert( dict(room=session['room'].encode("utf-8"), message=session.get('net_id') + ' has now left the conversation.', by=session.get('net_id'), time=st.encode("utf-8"))) close_db_connection(client) emit('status', {'msg': session.get('net_id') + ' has now left the conversation.'}, room=session['room'])
def leaveGame(msg, db, gameMsg): gameId = msg['gameId'] name = msg['name'] leave_room(gameId) gameMsg.buildLeaveGame() send( { 'event': 'leaveGame', 'message': gameMsg.message, 'game': None # no game returned since it doesn't change the game state }, json=True) send( { 'event': 'leaveGame', 'message': gameMsg.message, 'game': None # no game returned since it doesn't change the game state }, json=True, room=gameId)
def leave(message): leave_room(message['room'])
def on_leave(data): room = data['room'] leave_room(room) send(username + ' has left the room.', room=room) print('leave')
def on_leave(): if 'room' in session: room = session['room'] del session['room'] #print '>>> Somebody left room %s' % room leave_room(room)
def unsubscribe(message): leave_room(message['channel'])
def on_leave_room(data): leave_room(data['room'])
def on_leave(data): room = data.get('room') user = data.get('user') leave_room(room) emit('status', {'msg': user + ' has left the room.'}, room=room) send(user + ' has left the room.', room=room)
def on_leave(data): story_id = data['story_id'] leave_room(story_id) emit('user_left', {'user': current_user.name}, room=story_id, broadcast=True)
def on_leave(data): #username = data['username'] room = data leave_room(room)