|
@@ -1,5 +1,5 @@
|
|
import { ROLES, CODEMEG, EVENT, FROMTYPE } from "../../enum/index.js";
|
|
import { ROLES, CODEMEG, EVENT, FROMTYPE } from "../../enum/index.js";
|
|
-import { updateUser, removeRoomAllUsers, getAllRoomUsers, updateRoomUser } from "../../service/userService.js";
|
|
|
|
|
|
+import { getCurrentUser, updateUser, removeRoomAllUsers, getAllRoomUsers, updateRoomUser } from "../../service/userService.js";
|
|
// import { watchRoomService } from "../../service/watchRoomService.js";
|
|
// import { watchRoomService } from "../../service/watchRoomService.js";
|
|
import { setRoomConfig, getRoomConfig, updateRoomConfigByKey } from "../../service/roomConfigService.js";
|
|
import { setRoomConfig, getRoomConfig, updateRoomConfigByKey } from "../../service/roomConfigService.js";
|
|
|
|
|
|
@@ -15,20 +15,28 @@ export class RoomController extends BasicController {
|
|
this.userId = null;
|
|
this.userId = null;
|
|
this.roomConfigId = null;
|
|
this.roomConfigId = null;
|
|
this.debugger = true;
|
|
this.debugger = true;
|
|
|
|
+ this.sysUsers = [];
|
|
this.user = {
|
|
this.user = {
|
|
sig: null,
|
|
sig: null,
|
|
roomId: null,
|
|
roomId: null,
|
|
userId: null,
|
|
userId: null,
|
|
sceneNum: null,
|
|
sceneNum: null,
|
|
isClient: null,
|
|
isClient: null,
|
|
|
|
+ avatar: "",
|
|
role: null,
|
|
role: null,
|
|
userLimitNum: null,
|
|
userLimitNum: null,
|
|
sceneNumber: null,
|
|
sceneNumber: null,
|
|
roomType: null,
|
|
roomType: null,
|
|
from: null,
|
|
from: null,
|
|
|
|
+ onlineStatus: false,
|
|
|
|
+ voiceStatus: 0,
|
|
enableTalk: null,
|
|
enableTalk: null,
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
+ // 以小程序user信息作为主要信息
|
|
|
|
+ get currentUser() {
|
|
|
|
+ return this.sysUsers.find((item) => Number(item.from) === 2);
|
|
|
|
+ }
|
|
|
|
|
|
async run() {
|
|
async run() {
|
|
this.logger.info("socket conetcted has start!");
|
|
this.logger.info("socket conetcted has start!");
|
|
@@ -44,6 +52,7 @@ export class RoomController extends BasicController {
|
|
|
|
|
|
async init() {
|
|
async init() {
|
|
let user = this.socket.handshake.query;
|
|
let user = this.socket.handshake.query;
|
|
|
|
+
|
|
if (user) {
|
|
if (user) {
|
|
this.user = Object.assign({}, user, {
|
|
this.user = Object.assign({}, user, {
|
|
roomType: user.roomType || "",
|
|
roomType: user.roomType || "",
|
|
@@ -53,8 +62,9 @@ export class RoomController extends BasicController {
|
|
const { userId, roomId } = this.user;
|
|
const { userId, roomId } = this.user;
|
|
await this.initParams(userId, roomId, oneSceneNum);
|
|
await this.initParams(userId, roomId, oneSceneNum);
|
|
const userObj = { ...this.user, isConnected: true };
|
|
const userObj = { ...this.user, isConnected: true };
|
|
- // console.log('userObj',userObj)
|
|
|
|
|
|
+
|
|
updateUser(this.userId, userObj);
|
|
updateUser(this.userId, userObj);
|
|
|
|
+ this.sysUsers.push(this.user);
|
|
|
|
|
|
// 只有来源于小程序用户信息才记录到redis
|
|
// 只有来源于小程序用户信息才记录到redis
|
|
if (this.isHoster(this.user.role)) {
|
|
if (this.isHoster(this.user.role)) {
|
|
@@ -113,7 +123,9 @@ export class RoomController extends BasicController {
|
|
});
|
|
});
|
|
|
|
|
|
this.socket.on(EVENT.startCall, async () => {
|
|
this.socket.on(EVENT.startCall, async () => {
|
|
- this.roomAssistant.startCall(this.roomId, this.userId, this.user);
|
|
|
|
|
|
+ const currentUser = await getCurrentUser(this.userId, FROMTYPE.MiniAPP);
|
|
|
|
+ const user = JSON.parse(currentUser) || this.user;
|
|
|
|
+ this.roomAssistant.startCall(this.roomId, this.userId, user);
|
|
if (this.isHoster(this.user.role)) {
|
|
if (this.isHoster(this.user.role)) {
|
|
// 以startCall做为真正的进入房间
|
|
// 以startCall做为真正的进入房间
|
|
await updateRoomConfigByKey(this.roomId, "isStart", true);
|
|
await updateRoomConfigByKey(this.roomId, "isStart", true);
|