From b135f97ba2bd21cffc212bade59db51627ddd2c3 Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Sun, 16 Jun 2024 13:25:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=9A=E4=BA=BA=E9=9F=B3=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../implatform/dto/WebrtcGroupDeviceDTO.java | 5 +- .../service/impl/WebrtcGroupServiceImpl.java | 31 +- .../bx/implatform/session/WebrtcUserInfo.java | 3 + im-ui/src/App.vue | 27 + im-ui/src/api/enums.js | 47 +- im-ui/src/assets/iconfont/iconfont.css | 34 +- im-ui/src/assets/iconfont/iconfont.ttf | Bin 4740 -> 7116 bytes im-ui/src/components/chat/ChatBox.vue | 1622 +++++++++-------- im-ui/src/components/common/HeadImage.vue | 28 +- im-ui/src/components/group/AddGroupMember.vue | 28 +- .../src/components/rtc/RtcPrivateAcceptor.vue | 2 +- im-ui/src/main.js | 1 + im-ui/src/view/Home.vue | 30 +- im-uniapp/pages/chat/chat-box.vue | 22 +- 14 files changed, 1017 insertions(+), 863 deletions(-) diff --git a/im-platform/src/main/java/com/bx/implatform/dto/WebrtcGroupDeviceDTO.java b/im-platform/src/main/java/com/bx/implatform/dto/WebrtcGroupDeviceDTO.java index 7ddcf63..bc8ec79 100644 --- a/im-platform/src/main/java/com/bx/implatform/dto/WebrtcGroupDeviceDTO.java +++ b/im-platform/src/main/java/com/bx/implatform/dto/WebrtcGroupDeviceDTO.java @@ -21,6 +21,9 @@ public class WebrtcGroupDeviceDTO { private Long groupId; @ApiModelProperty(value = "是否开启摄像头") - private Boolean isCamera = false; + private Boolean isCamera; + + @ApiModelProperty(value = "是否开启麦克风") + private Boolean isMicroPhone; } diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/WebrtcGroupServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/WebrtcGroupServiceImpl.java index 41e92f5..423cefc 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/WebrtcGroupServiceImpl.java +++ b/im-platform/src/main/java/com/bx/implatform/service/impl/WebrtcGroupServiceImpl.java @@ -59,6 +59,9 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService { @Override public void setup(WebrtcGroupSetupDTO dto) { UserSession userSession = SessionContext.getSession(); + if(!imClient.isOnline(userSession.getUserId())){ + throw new GlobalException("您已断开连接,请重新登陆"); + } if (dto.getUserInfos().size() > webrtcConfig.getMaxChannel()) { throw new GlobalException("最多支持" + webrtcConfig.getMaxChannel() + "人进行通话"); } @@ -78,8 +81,8 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService { List busyUserIds = new LinkedList<>(); for (WebrtcUserInfo userInfo : dto.getUserInfos()) { if (!imClient.isOnline(userInfo.getId())) { - //userInfos.add(userInfo); - offlineUserIds.add(userInfo.getId()); + userInfos.add(userInfo); + //offlineUserIds.add(userInfo.getId()); } else if (userStateUtils.isBusy(userInfo.getId())) { busyUserIds.add(userInfo.getId()); } else { @@ -99,7 +102,7 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService { if (!offlineUserIds.isEmpty()) { WebrtcGroupFailedVO vo = new WebrtcGroupFailedVO(); vo.setUserIds(offlineUserIds); - vo.setReason("用户不在线"); + vo.setReason("用户当前不在线"); sendRtcMessage2(MessageType.RTC_GROUP_FAILED, dto.getGroupId(), userInfo, JSON.toJSONString(vo)); } if (!busyUserIds.isEmpty()) { @@ -209,20 +212,24 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService { if (Objects.isNull(member) || member.getQuit()) { throw new GlobalException("您不在群里中"); } - // 防止重复进入 - if (isInchat(webrtcSession, userSession.getUserId())) { - throw new GlobalException("您已在通话中"); + IMUserInfo mine = findInChatUser(webrtcSession, userSession.getUserId()); + if(!Objects.isNull(mine) && mine.getTerminal() != userSession.getTerminal()){ + throw new GlobalException("已在其他设备加入通话"); } WebrtcUserInfo userInfo = new WebrtcUserInfo(); userInfo.setId(userSession.getUserId()); userInfo.setNickName(member.getAliasName()); userInfo.setHeadImage(member.getHeadImage()); + // 默认是开启麦克风,关闭摄像头 userInfo.setIsCamera(false); + userInfo.setIsMicroPhone(true); // 将当前用户加入通话用户列表中 if (!isExist(webrtcSession, userSession.getUserId())) { webrtcSession.getUserInfos().add(userInfo); } - webrtcSession.getInChatUsers().add(new IMUserInfo(userSession.getUserId(), userSession.getTerminal())); + if (!isInchat(webrtcSession, userSession.getUserId())) { + webrtcSession.getInChatUsers().add(new IMUserInfo(userSession.getUserId(), userSession.getTerminal())); + } saveWebrtcSession(groupId, webrtcSession); // 进入忙线状态 userStateUtils.setBusy(userSession.getUserId()); @@ -237,7 +244,7 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService { public void invite(WebrtcGroupInviteDTO dto) { UserSession userSession = SessionContext.getSession(); WebrtcGroupSession webrtcSession = getWebrtcSession(dto.getGroupId()); - if (dto.getUserInfos().size() + dto.getUserInfos().size() > webrtcConfig.getMaxChannel()) { + if (webrtcSession.getUserInfos().size() + dto.getUserInfos().size() > webrtcConfig.getMaxChannel()) { throw new GlobalException("最多支持" + webrtcConfig.getMaxChannel() + "人进行通话"); } if (!groupMemberService.isInGroup(dto.getGroupId(), getRecvIds(dto.getUserInfos()))) { @@ -259,7 +266,9 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService { continue; } if (!imClient.isOnline(userInfo.getId())) { - offlineUserIds.add(userInfo.getId()); + // offlineUserIds.add(userInfo.getId()); + userStateUtils.setBusy(userInfo.getId()); + newUserInfos.add(userInfo); } else if (userStateUtils.isBusy(userInfo.getId())) { busyUserIds.add(userInfo.getId()); } else { @@ -275,7 +284,7 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService { if (!offlineUserIds.isEmpty()) { WebrtcGroupFailedVO vo = new WebrtcGroupFailedVO(); vo.setUserIds(offlineUserIds); - vo.setReason("用户不在线"); + vo.setReason("用户当前不在线"); IMUserInfo reciver = new IMUserInfo(userSession.getUserId(), userSession.getTerminal()); sendRtcMessage2(MessageType.RTC_GROUP_FAILED, dto.getGroupId(), reciver, JSON.toJSONString(vo)); } @@ -417,6 +426,7 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService { } // 更新设备状态 userInfo.setIsCamera(dto.getIsCamera()); + userInfo.setIsMicroPhone(dto.getIsMicroPhone()); saveWebrtcSession(dto.getGroupId(), webrtcSession); // 广播信令 List recvIds = getRecvIds(webrtcSession.getUserInfos()); @@ -446,7 +456,6 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService { host.setId(hostId); host.setNickName(member.getAliasName()); host.setHeadImage(member.getHeadImage()); - host.setIsCamera(false); } vo.setHost(host); } diff --git a/im-platform/src/main/java/com/bx/implatform/session/WebrtcUserInfo.java b/im-platform/src/main/java/com/bx/implatform/session/WebrtcUserInfo.java index fc5ad57..75b16fb 100644 --- a/im-platform/src/main/java/com/bx/implatform/session/WebrtcUserInfo.java +++ b/im-platform/src/main/java/com/bx/implatform/session/WebrtcUserInfo.java @@ -23,4 +23,7 @@ public class WebrtcUserInfo { @ApiModelProperty(value = "是否开启摄像头") private Boolean isCamera; + + @ApiModelProperty(value = "是否开启麦克风") + private Boolean isMicroPhone; } diff --git a/im-ui/src/App.vue b/im-ui/src/App.vue index b60f612..60aa2b0 100644 --- a/im-ui/src/App.vue +++ b/im-ui/src/App.vue @@ -85,4 +85,31 @@ .el-button { padding: 8px 15px !important; } + +.el-checkbox { + display: flex; + align-items: center; + + //修改选中框的大小 + .el-checkbox__inner { + width: 20px; + height: 20px; + + //修改选中框中的对勾的大小和位置 + &::after { + height: 12px; + left: 7px; + } + } + + //修改点击文字颜色不变 + .el-checkbox__input.is-checked+.el-checkbox__label { + color: #333333; + } + + .el-checkbox__label { + line-height: 20px; + padding-left: 8px; + } +} \ No newline at end of file diff --git a/im-ui/src/api/enums.js b/im-ui/src/api/enums.js index 0e6a1b1..0157962 100644 --- a/im-ui/src/api/enums.js +++ b/im-ui/src/api/enums.js @@ -1,18 +1,17 @@ - const MESSAGE_TYPE = { TEXT: 0, - IMAGE:1, - FILE:2, - AUDIO:3, - VIDEO:4, - RT_VOICE:5, - RT_VIDEO:6, - RECALL:10, - READED:11, - RECEIPT:12, - TIP_TIME:20, - TIP_TEXT:21, - LOADDING:30, + IMAGE: 1, + FILE: 2, + AUDIO: 3, + VIDEO: 4, + RT_VOICE: 5, + RT_VIDEO: 6, + RECALL: 10, + READED: 11, + RECEIPT: 12, + TIP_TIME: 20, + TIP_TEXT: 21, + LOADDING: 30, RTC_CALL_VOICE: 100, RTC_CALL_VIDEO: 101, RTC_ACCEPT: 102, @@ -20,7 +19,19 @@ const MESSAGE_TYPE = { RTC_CANCEL: 104, RTC_FAILED: 105, RTC_HANDUP: 106, - RTC_CANDIDATE: 107 + RTC_CANDIDATE: 107, + RTC_GROUP_SETUP: 200, + RTC_GROUP_ACCEPT: 201, + RTC_GROUP_REJECT: 202, + RTC_GROUP_FAILED: 203, + RTC_GROUP_CANCEL: 204, + RTC_GROUP_QUIT: 205, + RTC_GROUP_INVITE: 206, + RTC_GROUP_JOIN: 207, + RTC_GROUP_OFFER: 208, + RTC_GROUP_ANSWER: 209, + RTC_GROUP_CANDIDATE: 210, + RTC_GROUP_DEVICE: 211 } const RTC_STATE = { @@ -28,7 +39,7 @@ const RTC_STATE = { WAIT_CALL: 1, // 呼叫后等待 WAIT_ACCEPT: 2, // 被呼叫后等待 ACCEPTED: 3, // 已接受聊天,等待建立连接 - CHATING:4 // 聊天中 + CHATING: 4 // 聊天中 } const TERMINAL_TYPE = { @@ -39,8 +50,8 @@ const TERMINAL_TYPE = { const MESSAGE_STATUS = { UNSEND: 0, SENDED: 1, - RECALL:2, - READED:3 + RECALL: 2, + READED: 3 } @@ -49,4 +60,4 @@ export { RTC_STATE, TERMINAL_TYPE, MESSAGE_STATUS -} +} \ No newline at end of file diff --git a/im-ui/src/assets/iconfont/iconfont.css b/im-ui/src/assets/iconfont/iconfont.css index ff4113e..8c5b819 100644 --- a/im-ui/src/assets/iconfont/iconfont.css +++ b/im-ui/src/assets/iconfont/iconfont.css @@ -1,6 +1,6 @@ @font-face { font-family: "iconfont"; /* Project id 3791506 */ - src: url('iconfont.ttf?t=1714220334746') format('truetype'); + src: url('iconfont.ttf?t=1718373714629') format('truetype'); } .iconfont { @@ -11,6 +11,38 @@ -moz-osx-font-smoothing: grayscale; } +.icon-invite-rtc:before { + content: "\e65f"; +} + +.icon-quit:before { + content: "\e606"; +} + +.icon-camera-off:before { + content: "\e6b5"; +} + +.icon-speaker-off:before { + content: "\ea3c"; +} + +.icon-microphone-on:before { + content: "\e63b"; +} + +.icon-speaker-on:before { + content: "\e6a4"; +} + +.icon-camera-on:before { + content: "\e627"; +} + +.icon-microphone-off:before { + content: "\efe5"; +} + .icon-chat:before { content: "\e600"; } diff --git a/im-ui/src/assets/iconfont/iconfont.ttf b/im-ui/src/assets/iconfont/iconfont.ttf index 63ec967c2b7a9bbfc8dc6b19d650bedd6824092b..1697727cd9bc8b7cd880261c65193ec0389fb641 100644 GIT binary patch delta 3009 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 KJKN|<9Qij=93Ghf delta 643 zcmZvYJ!lj`7>3_(X7~QroPv6sTdWunAzh*tIgoTItgIvox+XD)pQzx=`7ED|1As6^tZ`qv$for&`HAc zelVU`T$&B5V@E!7{t;up6?WP(idU@H7zcO4*1TVR*LV+%ut6=fm+mc3M^|=%!!aA) zJlj4seK0vV*xwn(_CHy1 z{#S{
  • - +
@@ -36,8 +36,8 @@
- +
@@ -49,6 +49,9 @@
+
+
@@ -57,9 +60,10 @@
x + @compositionstart="onEditorCompositionStart" + @compositionend="onEditorCompositionEnd" @input="onEditorInput" + :placeholder="placeholder" @blur="onEditBoxBlur()" @keydown.down="onKeyDown" + @keydown.up="onKeyUp" @keydown.enter.prevent="onKeyEnter">x
@@ -85,853 +89,905 @@ - + + +
\ No newline at end of file + \ No newline at end of file diff --git a/im-ui/src/components/common/HeadImage.vue b/im-ui/src/components/common/HeadImage.vue index eccba60..91eec68 100644 --- a/im-ui/src/components/common/HeadImage.vue +++ b/im-ui/src/components/common/HeadImage.vue @@ -28,6 +28,16 @@ type: Number, default: 50 }, + width: { + type: Number + }, + height: { + type: Number + }, + radius:{ + type: String, + default: "10%" + }, url: { type: String }, @@ -54,12 +64,18 @@ } }, computed:{ - avatarImageStyle(){ - return `width:${this.size}px; height:${this.size}px;` + avatarImageStyle() { + let w = this.width ? this.width : this.size; + let h = this.height ? this.height : this.size; + return `width:${w}px; height:${h}px; + border-radius: ${this.radius};` }, - avatarTextStyle(){ - return `width: ${this.size}px;height:${this.size}px; - color:${this.textColor};font-size:${this.size*0.6}px;` + avatarTextStyle() { + let w = this.width ? this.width : this.size; + let h = this.height ? this.height : this.size; + return `width: ${w}px;height:${h}px; + color:${this.textColor};font-size:${w*0.6}px; + border-radius: ${this.radius};` }, textColor(){ let hash = 0; @@ -79,7 +95,7 @@ .avatar-image { position: relative; overflow: hidden; - border-radius: 10%; + display: block; } .avatar-text{ diff --git a/im-ui/src/components/group/AddGroupMember.vue b/im-ui/src/components/group/AddGroupMember.vue index d60be28..d41f815 100644 --- a/im-ui/src/components/group/AddGroupMember.vue +++ b/im-ui/src/components/group/AddGroupMember.vue @@ -136,33 +136,7 @@ border-radius: 5px; overflow: hidden; - .el-checkbox { - display: flex; - align-items: center; - - //修改选中框的大小 - .el-checkbox__inner { - width: 20px; - height: 20px; - - //修改选中框中的对勾的大小和位置 - &::after { - height: 12px; - left: 7px; - } - } - - //修改点击文字颜色不变 - .el-checkbox__input.is-checked+.el-checkbox__label { - color: #333333; - } - - .el-checkbox__label { - line-height: 20px; - padding-left: 8px; - } - } - + .agm-friend-checkbox { margin-right: 20px; } diff --git a/im-ui/src/components/rtc/RtcPrivateAcceptor.vue b/im-ui/src/components/rtc/RtcPrivateAcceptor.vue index 193bc2f..95d5d52 100644 --- a/im-ui/src/components/rtc/RtcPrivateAcceptor.vue +++ b/im-ui/src/components/rtc/RtcPrivateAcceptor.vue @@ -15,7 +15,7 @@ import HeadImage from '../common/HeadImage.vue'; export default { - name: "videoAcceptor", + name: "rtcPrivateAcceptor", components: { HeadImage }, diff --git a/im-ui/src/main.js b/im-ui/src/main.js index 9ced174..25dfd46 100644 --- a/im-ui/src/main.js +++ b/im-ui/src/main.js @@ -21,6 +21,7 @@ Vue.prototype.$http = httpRequest // http请求方法 Vue.prototype.$emo = emotion; // emo表情 Vue.prototype.$elm = element; // 元素操作 Vue.prototype.$enums = enums; // 枚举 +Vue.prototype.$eventBus = new Vue(); // 全局事件 Vue.config.productionTip = false; new Vue({ diff --git a/im-ui/src/view/Home.vue b/im-ui/src/view/Home.vue index 0ac36cb..1bb97a4 100644 --- a/im-ui/src/view/Home.vue +++ b/im-ui/src/view/Home.vue @@ -42,6 +42,7 @@ @close="$store.commit('closeFullImageBox')"> + @@ -52,6 +53,7 @@ import FullImage from '../components/common/FullImage.vue'; import RtcPrivateVideo from '../components/rtc/RtcPrivateVideo.vue'; import RtcPrivateAcceptor from '../components/rtc/RtcPrivateAcceptor.vue'; + import RtcGroupVideo from '../components/rtc/RtcGroupVideo.vue'; export default { components: { @@ -60,7 +62,8 @@ UserInfo, FullImage, RtcPrivateVideo, - RtcPrivateAcceptor + RtcPrivateAcceptor, + RtcGroupVideo }, data() { return { @@ -70,6 +73,12 @@ }, methods: { init() { + this.$eventBus.$on('openGroupVideo', (rctInfo)=>{ + // 进入多人视频通话 + console.log(this.$refs.rtcGroupVideo) + this.$refs.rtcGroupVideo.open(rctInfo); + }); + this.$store.dispatch("load").then(() => { // ws初始化 this.$wsApi.connect(process.env.VUE_APP_WS_URL, sessionStorage.getItem("accessToken")); @@ -153,9 +162,8 @@ }) }, insertPrivateMessage(friend, msg) { - // webrtc 信令 - if (msg.type >= this.$enums.MESSAGE_TYPE.RTC_CALL_VOICE && - msg.type <= this.$enums.MESSAGE_TYPE.RTC_CANDIDATE) { + // 单人webrtc 信令 + if (msg.type >= 100 && msg.type <= 199) { let rtcInfo = this.$store.state.userStore.rtcInfo; // 呼叫 if (msg.type == this.$enums.MESSAGE_TYPE.RTC_CALL_VOICE || @@ -180,7 +188,8 @@ // 插入消息 this.$store.commit("insertMessage", msg); // 播放提示音 - if (!msg.selfSend && msg.status != this.$enums.MESSAGE_STATUS.READED) { + if (!msg.selfSend && msg.type < 10 + && msg.status != this.$enums.MESSAGE_STATUS.READED) { this.playAudioTip(); } }, @@ -214,12 +223,20 @@ } // 标记这条消息是不是自己发的 msg.selfSend = msg.sendId == this.$store.state.userStore.userInfo.id; + // 群视频信令 + if (msg.type >= 200 && msg.type <= 299) { + this.$nextTick(()=>{ + this.$refs.rtcGroupVideo.onRTCMessage(msg); + }) + return; + } this.loadGroupInfo(msg.groupId).then((group) => { // 插入群聊消息 this.insertGroupMessage(group, msg); }) }, insertGroupMessage(group, msg) { + let chatInfo = { type: 'GROUP', targetId: group.id, @@ -231,7 +248,8 @@ // 插入消息 this.$store.commit("insertMessage", msg); // 播放提示音 - if (!msg.selfSend && msg.status != this.$enums.MESSAGE_STATUS.READED) { + if (!msg.selfSend && msg.type < 10 + && msg.status != this.$enums.MESSAGE_STATUS.READED) { this.playAudioTip(); } }, diff --git a/im-uniapp/pages/chat/chat-box.vue b/im-uniapp/pages/chat/chat-box.vue index 146fafc..765b9b2 100644 --- a/im-uniapp/pages/chat/chat-box.vue +++ b/im-uniapp/pages/chat/chat-box.vue @@ -81,11 +81,11 @@ - + 视频通话 - + 语音通话 @@ -110,7 +110,7 @@ + @complete="onInviteOk"> @@ -175,18 +175,18 @@ }, onRtCall(msgInfo) { if (msgInfo.type == this.$enums.MESSAGE_TYPE.RT_VOICE) { - this.onVoiceCall(); + this.onPriviteVoice(); } else if (msgInfo.type == this.$enums.MESSAGE_TYPE.RT_VIDEO) { - this.onVideoCall(); + this.onPriviteVideo(); } }, - onVideoCall() { + onPriviteVideo() { const friendInfo = encodeURIComponent(JSON.stringify(this.friend)); uni.navigateTo({ url: `/pages/chat/chat-private-video?mode=video&friend=${friendInfo}&isHost=true` }) }, - onVoiceCall() { + onPriviteVoice() { const friendInfo = encodeURIComponent(JSON.stringify(this.friend)); uni.navigateTo({ url: `/pages/chat/chat-private-video?mode=voice&friend=${friendInfo}&isHost=true` @@ -208,7 +208,10 @@ } }) }, - onSelectMember(ids) { + onInviteOk(ids) { + if(ids.length < 2){ + return; + } let users = []; ids.forEach(id => { let m = this.groupMembers.find(m => m.userId == id); @@ -217,7 +220,8 @@ id: m.userId, nickName: m.aliasName, headImage: m.headImage, - isCamera: false + isCamera: false, + isMicroPhone: true }) }) const groupId = this.group.id;