def join(message): try: # get presentation json file using room session = Session.query.filter_by(code=message['room'], is_active=True).first() pid = session.presentation.id user_id = session.presenter_id # page_number hamishe 0 barmigardune page_number = session.current_page directory = os.path.join(app.config['DATA_DIR'], "user_" + str(user_id)) file = open(directory + "/presentation_" + str(pid)) presentation_file = js.load(file) join_room(message['room']) print(message['room']) print(presentation_file) print(page_number) emit('my response', {"data": "sb joined"}, room=message['room']) emit('init presentation', {"json": str(presentation_file), "page": page_number}) # print("ok") # emit('init presentation', {"json": "asa", "page": 2}) return 1 except Exception as e: print(e) return 0
def send_members(join_data): room = active_rooms[join_data['room']] join_room(room.name) data = [] for player in room.players: data.append(player.name) emit('users in lobby', data, room=room.name);
def join(message): print("join") join_room(message['room']) session['receive_count'] = session.get('receive_count', 0) + 1 emit('my response', {'data': 'In rooms: ' + ', '.join(rooms()), 'count': session['receive_count']})
def gametype(data): #Todo:validations if data[type]< games.length print("changing to -->") token =data["token"] username = users[token] #from 0 to BINGO gameTypeValue = data["type"] print("gameTypeValue="+str(gameTypeValue)) gameType= games[gameTypeValue]["name"] #get available room from bingo "BINGO_1" #Todo: change harcoded "1" to var available_room playersInRoom= getPlayersInRoom(gameType) gameTypeRoom = str(gameRooms[gameType]["1"]["name"]) playersInRoom[token]= username join_room(gameTypeRoom) player_list= [] for tok, usern in playersInRoom.iteritems(): print(usern) player_list.append(usern) # print("->>>>>") # for room in rooms(): # pprint(room) # print("<<<<-") socketio.send('join room', {'data': gameTypeRoom, 'gametype':gameType, 'players': player_list},room=gameTypeRoom) checkNumPlayers(gameTypeValue,gameType,gameTypeRoom)
def joined(message): """ join """ print 'socketio joined' room = session.get('room') join_room(room) semit('status', {'msg': session.get() + ''}, room=room)
def join(message): global roomsDict if message['username'] in roomsDict: emit('my response', {'user': '******', 'data': 'User "' + message['username'] + '" exists', 'count': session['receive_count']}) return False else: session['username'] = message['username'] # Give some value to the user roomsDict[message['username']] = message['username'] if message['room'] not in roomsDict: roomsDict[message['room']] = { 'users': [], 'start': False } elif len(roomsDict[message['room']]['users']) > 3: emit('my response', {'user': '******', 'data': 'Could not join ' + message['room'] + '(room is full)', 'count': session['receive_count']}) return False roomsDict[message['room']]['users'].append(session['username']) join_room(message['room']) join_room(message['username']) session['receive_count'] = session.get('receive_count', 0) + 1 emit('my response', {'user': '******', 'data': 'Joined ' + message['room'], 'count': session['receive_count']}) emit('my response', {'user': message['room'].capitalize() + 'Bot', 'data': session['username'] + ' has entered the room', 'count': session['receive_count']}, room=message['room']) return True
def handle_user_connection(message): party, user_id, error = init_socket_event(message) if error: return print "on_connect: " + party.party_name + " - " + user_id join_room(get_room(party, user_id)) emit_queue(party)
def join(message): join_room(message['room']) session['receive_count'] = session.get('receive_count', 0) + 1 emit(SERVER_GEN_RESPONSE, {'data': 'In rooms: ' + ', '.join(rooms()), 'count': session['receive_count']}) if message['room'] == ROOM_PGRC_PROD: emit(PROD_RESPONSE, {'data': 'In rooms: ' + ', '.join(rooms()), 'count': session['receive_count']}) show_client_status(CLIENT_STATUS_CODE['JOINED'], request.sid)
def on_connect(): uid = flask.session.get('auth_user', None) if uid is None: app.logger.warn('received socket connection from unauthed user') return app.logger.info('new client connected for user %d', uid) sio.join_room('user-{}'.format(uid))
def chat_connect(): if not session.get('logged_in'): emit('Message', {'prefix': '', 'data': 'Not logged in.'}) return False global userlist session['id'] = request.sid if session.get('user', False): userlist[session['user'].upper()] = session['id'] mailbox = Chatroom(session['user'], True) rooms.append(mailbox) session['rooms'] = [mailbox, rooms[0]] try: prevmode = session['chatmode'] except: prevmode = 'talk' session['activeroom'] = session['rooms'][1] join_room(session['activeroom'].name) session['chatmode'] = prevmode session['activeroom'] = rooms[0] rooms[0].userjoin(session['user']) join_room(rooms[0]) emit('Message', {'data': 'Hello and Welcome to the NosferatuNetwork Chatserver.\n'}) else: disconnect() return False
def join_draft(message): room_to_join = message['room_id'] if room_to_join not in room_map: emit('join_error', { 'message': 'Room {} does not exist'.format(room_to_join) }) return room = room_map[room_to_join] if len(room.player_list) >= 2: emit('join_error', { 'message': 'Room {} already has two players in it'.format(room.id) }) return room.touch() join_room(room.id) room.player_list.append(message['username']) room.post_event("{} has joined the room!".format(message['username'])) emit('join_success', { 'room_id': room.id, 'draft_type': room.draft_type.name }) broadcast_to_room(room.id, "{} has joined the room!".format(message['username'])) broadcast_to_room(room.id, "Players currently in room: {}".format(' and '.join(room.player_list))) if len(room.player_list) == 2: room.start_draft() print "back from draft started" tell_clients_draft_has_started(room)
def room_selection(message): # Sent by clients (users) when they select a role (speaker/listener) role = session.get('role') # The speakers room is going to be the sessionID /chat/<sid> sid = request.sid # This is where 'smart' match-making should occur: # TODO: match un-matched listeners to speakers... # For simplicity, match listeners to the last available speaker... if 'speaker' in role: join_room(sid) available_rooms.append(sid) emit('status', {'message': 'Welcome speaker..'}, room=sid) else: # Find available speakers... # IF a saved speaker is not in the listeners list, then # we have a free speaker to chat to! # This is only used for a count... if available_rooms: import random room = random.choice(available_rooms) join_room(room) listeners[sid] = room emit('status', {'message': 'Joined speaker in ' + str(room)}, room=room) available_rooms.remove(room) else: emit('status', {'message': 'No speakers free. Check back later...'})
def login(user_name): # check if in holder session['room'] = str(user_name[u'data']) join_room(str(session['room'])) conn = holder.getConnectionbyuser(session['room']) if conn is not None: try: if conn.api.stack == '': conn.start() conn.set_sid(request.sid) if conn.api.get_connected(): app.logger.info('created connection for ' + conn.get_user_name()) emit('server log', {'data': 'created connection for: ' + str(session['room'])}) else: app.logger.warning( 'connection failed for user' + ' ' + conn.get_user_name() + ' user phone must be deleted') else: app.logger.warning('already connected ' + conn.get_user_name()) emit('server log', {'data': 'logged in'}) except Exception as ex: app.logger.error(ex) else: app.logger.warning('user %s not exist in database you should add it first', session['room']) emit('server log', {'data': 'the user name entered does not exist'})
def on_add_user(data): name = data['username'] if 'room' in data: room = data['room'] if room not in room_to_state: emit('roomDoesNotExist', { 'room': room, }) return else: room = _create_new_room() join_room(room) sid_to_room[request.sid] = room room_state = _get_room_state(request) model = room_state.model emit('roomJoined', { 'pk': request.sid, 'room': room, 'players': model.get_json_players(), 'board': model.get_json_board(), }) pubsub = room_state.pubsub pubsub.publish( ViewAction.add_player, trigger_queue=True, name=name, pk=request.sid)
def on_join(room): from .database import BTSBlock, TestBlock, SteemBlock # Leave all rooms! for r in rooms: leave_room(r) # Join only one room join_room(room) log("joined " + room) # Send all the stored data for that room if room == "bts": blocks = BTSBlock elif room == "test": blocks = TestBlock else: blocks = SteemBlock block_time = 3 allblocks = [[ b.timestamp, b.num_ops, b.num_txs, b.block_num ] for b in blocks.recent(1000)] socketio.emit( 'init', { "data": sorted(allblocks, key=lambda x: x[0]), "block_time": block_time }, namespace=namespace, room=room, broadcast=True)
def clientConnect(projectId): # Add current user to his project. if projectId in project_users: project_users[projectId].append(request.sid) else: project_users[projectId] = [request.sid] join_room(projectId)
def join(message): room = sanitize_html(message['room']) log.debug("%s joined %s" % (current_user.username, room)) join_room(room) emit('event response room', {'data': room, 'userjoin': current_user.username}, broadcast=True)
def handle_game(): print("Play") if currentGame.playing == 0: leave_room('ready') join_room('play') start_wait() currentGame.start_game(session['id']) notify_players()
def subscribe_group(data): out(data) group = data['group'] join_room(group) room_subscribers[group] += 1 if room_subscribers[group] == 1: Thread(target=group_watcher, args=(group,), daemon=True).start()
def on_join(data): payload = {'status': 'OK'} for e in adapterHandlers.keys(): rs = adapterHandlers[e]('debut') if rs is not None: payload.update(rs) join_room('ready') emit('ALL_DATA', {'data': json.dumps(payload)} )
def on_join(data): """ due to the broadcast nature of our app (single drafter broadcasts to many viewers), we are utilizing rooms in our web sockets library. when emitting a message to a room, anyone who is a member of that room (someone who has explicitly joined the room) will receive the message. """ room = data["id"] join_room(room)
def rematch(msg): """ simple rematch implementation """ user = msg['user'] roomId = msg['matchId'] join_room(roomId) emit(cs.REMATCH, room=roomId, include_self=False)
def join(message): join_room(message['room']) emit('join', {'user': message['user'], 'room': message['room']}, broadcast=True) room_list = [room for room in rooms() if room != request.sid] emit('my response', {'data': 'In rooms: ' + ', '.join(room_list)})
def join(message): join_room(message['room_id']) current_app.config[message['room_id']]['current_user_num'] += 1 data = { 'user_num': current_app.config[message['room_id']]['current_user_num'], 'info': message['nick_name'] + u"加入了房间!" } emit('user update', data, room=message['room_id'])
def on_connect(): room_id = 777 print('SERVER 5001>>> A user has been connected.') join_room(room_id) send('SERVER 5001>>> User has joined the room: ' + str(room_id) + '.', room=room_id) print('SERVER 5001>>> User has joined the room ' + str(room_id) + '.') socketio.emit('my_event', 'data_string1') emit('my_event', 'data_string2')
def handle_server(server): session["room"] = server print("Id: {} is now joining room {}".format(request.__getattr__("sid"), server)) joined_rooms = len(rooms()) if joined_rooms==1: join_room(server) bots[server].force_event()
def on_connect(self, request_id): user = self.app.user_tracker.users[self.app.user_tracker.requests[request_id]] if user.socket_connected: return user.socket_connect() flask_socketio.join_room(request_id)
def on_join(data): username = data['username'] document = data['document'] join_room(document) print ('%s has entered the room (%s).' % (username, document)) # broadcast new userlist and send back current document emit('userlist', ['Markus', username], room=document) emit('document', 'Lorem ipsum dolor sit amet')
def join_chatroom(): if 'uid' not in session: return redirect(url_for('login')) userinfo = get_userinfo(session['uid']) # big room join_room(get_channel(userinfo['room_id'], None)) # personal room join_room(get_channel(userinfo['room_id'], userinfo['play_id']))
def join(message): join_room(message['room']) session['receive_count'] = session.get('receive_count', 0) + 1 emit('my response', {'data': 'In rooms: ' + ', '.join(rooms()), 'count': session['receive_count']}) while(True): emit('my response',{'data': 'In rooms: ','count': 1}) time.sleep(1)
def on_restart(gameCode): room = gameCode if room in ROOMS: join_room(room) emit('restart update', room=room)
def join(msg): join_room(msg["conversation_id"])
def join(message): join_room(message['room'])
def joinedGame(message): username = message['msg'] print("New user: " + username) clientsList.append(username) join_room(username)
def handle_join_room_event(data): app.logger.info("{} has joined the room {}".format(data['username'], data['room'])) join_room(data['room']) socketio.emit('join_room_announcement', data) user_online.append(data['username'])
def renameColumn(data): if "requestID" in data and "sessionID" in data and "column" in data and "newName" in data: join_room(data["sessionID"]) updateSessionID(request.sid, data["sessionID"]) result = tasks.renameColumn.delay(data['sessionID'], data['requestID'], data['column'], data['newName'])
def data(data): if "requestID" in data and "sessionID" in data: print("flask: data") join_room(data["sessionID"]) updateSessionID(request.sid, data["sessionID"]) result = tasks.data.delay(data)
def undo(data): if "requestID" in data and "sessionID" in data: join_room(data["sessionID"]) updateSessionID(request.sid, data["sessionID"]) result = tasks.undo.delay(data["sessionID"], data["requestID"])
def visualize(data): if "requestID" in data and "sessionID" in data and "type" in data: join_room(data["sessionID"]) updateSessionID(request.sid, data["sessionID"]) result = tasks.visualize.delay(data)
def on_join(data): room = data['room'] join_room(room) emit('open_room', {'room': room}, broadcast=True) emit('roomJoined', {'room': room}, broadcast=True)
def executeCommand(data): if "requestID" in data and "sessionID" in data and "command" in data: join_room(data["sessionID"]) updateSessionID(request.sid, data["sessionID"]) result = tasks.executeCommand.delay(data['sessionID'], data['requestID'], data["command"])
def updateclient(roomname): print('updating client for room:', roomname) join_room(roomname) room = rooms[roomname] update(roomname)
def standardize(data): if "requestID" in data and "sessionID" in data and "columnIndex" in data: join_room(data["sessionID"]) updateSessionID(request.sid, data["sessionID"]) result = tasks.standardize.delay(data['sessionID'], data['requestID'], data["columnIndex"])
def deleteRows(data): if "requestID" in data and "sessionID" in data and "rowIndices" in data: join_room(data["sessionID"]) updateSessionID(request.sid, data["sessionID"]) result = tasks.deleteRows.delay(data['sessionID'], data['requestID'], data['rowIndices'])
def on_join(data): room = data['token'] join_room(room) emit('open_room', {'room': room}, broadcast=True) print('join room', room)
def join_chat(): room = session.get("chat_id") join_room(room)
def join_dialogue(data): join_room(data['id_dialogue']) id_dialogue_to_sid[request.sid] = data['id_dialogue'] messages_model.read_all_messages(data['to_whom_id'], data['from_whom_id'])
def on_join(data): username = data['user'] room = data['room'] join_room(room) emit('chat', {'username': username}, room=room) print("room has been alocated")
def join(data): username = data['username'] room = data['room'] join_room(room) socketio.send({'msg': username + " has joined the " + room + ' room'}, room=room)
def on_join(data): username = data['username'] room = data['room'] join_room(room) emit('user joined room', {'username': username, 'room': room}, room = room, broadcast=True)
def on_request_restart(gameCode): room = gameCode if room in ROOMS: join_room(room) emit('accept restart', room=room, include_self=False)
def handle_join_room_event(data): #app.logger.info("{} has joined the room {}".format(data['username'], data['room'])) join_room(data['room']) socketio.emit('join_room_announcement', {'username': current_user.username}, broadcast=True, include_self=True)
def on_change(result, gameCode): room = gameCode if room in ROOMS: join_room(room) emit('update result', json.dumps({'result': result}), room=room)
def join(message): print("room", message) room = message.get('room') join_room(room, namespace='/test')
def handle_create_room(roomKey): if (roomKey != None and roomKey != ''): room = roomKey ROOMS.append(room) join_room(roomKey)
def joined(message): name = flask_login.current_user.id room = session.get('room') join_room(room) emit('status', {'id': name, 'msg': name + ' joined'}, room=room)
def on_join_channel(channel_id): print("join_channel:", channel_id) join_room(channel_id)
def room(target): join_room(target)
def analyze(data): if "requestID" in data and "sessionID" in data and "column" in data: join_room(data["sessionID"]) updateSessionID(request.sid, data["sessionID"]) result = tasks.analyze.delay(data['sessionID'], data['requestID'], data['column'])
def join(message={}): r_id = message.get('room', str(uuid.uuid4())) join_room(r_id) emit('joined', {'room': r_id})