def create(user_info, params): # 加入房间号 data = ChatService().groupChatCreate(user_info, params) if data: #添加后同步房间 user_room_relation_data = Utils.db_l_to_d(UserRoomRelation.get(data['room_uuid'])) for item in user_room_relation_data: roomList = UserRoomRelation.getRoomList(item['user_id'])['data'] socketio.emit('groupRoom', Utils.formatBody(roomList), namespace='/room', room='@broadcast.'+str(item['user_id'])) return Utils.formatBody(data, msg='创建成功') return Utils.formatError(Code.BAD_REQUEST,msg='创建失败')
def create(params, user_info): # 加入房间号 data = ChatService().groupChatCreate(params, user_info) if data: #添加后同步房间 user_room_relation_data = Utils.db_l_to_d(UserRoomRelation.get(data['room_uuid'])) for item in user_room_relation_data: roomList = UserRoomRelation.getRoomList(item['user_id']) socketio.emit('groupRoom', Utils.formatBody(roomList), namespace='/api', room='@broadcast.'+str(item['user_id'])) return Utils.formatBody(data, msg='创建成功') return Utils.formatError(CONST['CODE']['BAD_REQUEST']['value'],msg='创建失败')
def groupChatCreate(user_info, params): # 加入房间号 data = ChatService().groupChatCreate(user_info, params) if data: #添加后同步房间 user_room_relation_data = Utils.db_l_to_d( UserRoomRelation.get(data['room_uuid'])) for item in user_room_relation_data: roomList = UserRoomRelation.getRoomList(item['user_id']) socketio.emit('groupRoom', Utils.formatBody(roomList), namespace='/api', room='@broadcast.' + str(item['user_id'])) return BaseController().successData(data, msg='创建成功') return BaseController().error(msg='创建失败')
def chat(message, user_info): return ChatService().chat(message, user_info) # 客户端回调函数的参数
def groupChatCreate(user_info, params): # 加入房间号 data = ChatService().groupChatCreate(user_info, params) if data: return BaseController().successData(data, msg='创建成功') return BaseController().error(msg='创建失败')
def input(message, user_info): return ChatService().input(message, user_info) # 客户端回调函数的参数