From f4a4c7709e09bb7c31f802ea8187d1e117efda2b Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Thu, 12 Aug 2021 09:48:16 +0800
Subject: [PATCH] 视频
---
store/mutations.js | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/store/mutations.js b/store/mutations.js
index 497af5c..664665e 100644
--- a/store/mutations.js
+++ b/store/mutations.js
@@ -46,6 +46,43 @@
state.puserID = data.userID;
state.avatar = data.avatar;
}
+
+ uni.connectSocket({
+ url: 'ws://192.168.0.111:9034/websocket'
+ });
+ var socketOpen = false;
+ uni.onSocketOpen(function(res) {
+ socketOpen = true;
+ console.log('持续连接成功')
+ sendSocketMessage();
+ });
+
+ function sendSocketMessage() {
+ var data = {
+ // type: state.puserName,
+ id: state.puserID,
+ type: 'login'
+ }
+ if (socketOpen) {
+ uni.sendSocketMessage({
+ data: JSON.stringify(data)
+ });
+ }
+ }
+
+ uni.onSocketMessage(function(res) {
+ console.log(res.data);
+ var data = JSON.parse(res.data)
+ // if (data.type == 'video') {
+ // this.receiveVideo('Receiver', );
+ console.log('进入接受 跳转',data.type)
+ uni.navigateTo({
+ url: '../videoCall/videoCall?state=Receiver&type=' + data.type +'&room=' + data.roomId
+ });
+ // }
+ // console.log('收到服务器内容:' + res.data);
+ });
+
//储存用户
WxStorage.set("init", "true");
WxStorage.set("name", data.userName);
--
Gitblit v1.9.3