diff --git a/public/js/common.js b/public/js/common.js
index 33a41bc..d48e956 100644
--- a/public/js/common.js
+++ b/public/js/common.js
@@ -275,6 +275,19 @@ function addMemberView(id) {
memberElm.attr('id', id);
memberElm.find('div.member-id').html(id);
memberElm.css('display', 'flex');
+ memberElm.find("#video-btn").click((el)=>{
+ console.log(el)
+ console.log($(el.target).attr("src"))
+ console.log("video" + id);
+ })
+ memberElm.find("#mic-btn").click((el)=>{
+ console.log($(el.target).attr("src"))
+ console.log("mic" + id);
+ })
+ memberElm.find("#video-btn").removeAttr("id")
+ memberElm.find("#mic-btn").removeAttr("id")
+
+ console.log("移除")
memberElm.appendTo($('#member-list'));
}
diff --git a/public/js/iminit.js b/public/js/iminit.js
index e07711d..0074a6a 100644
--- a/public/js/iminit.js
+++ b/public/js/iminit.js
@@ -3,16 +3,39 @@ let options = {
};
let tim = TIM.create(options);
tim.setLogLevel(0);
-// 监听事件,例如:
-tim.on(TIM.EVENT.SDK_READY, function(event) {
- // 收到离线消息和会话列表同步完毕通知,接入侧可以调用 sendMessage 等需要鉴权的接口
- // event.name - TIM.EVENT.SDK_READY
- });
+function formatDateTime (inputTime) {
+ var date = new Date(inputTime);
+ var y = date.getFullYear();
+ var m = date.getMonth() + 1;
+ m = m < 10 ? ('0' + m) : m;
+ var d = date.getDate();
+ d = d < 10 ? ('0' + d) : d;
+ var h = date.getHours();
+ h = h < 10 ? ('0' + h) : h;
+ var minute = date.getMinutes();
+ var second = date.getSeconds();
+ minute = minute < 10 ? ('0' + minute) : minute;
+ second = second < 10 ? ('0' + second) : second;
+ return h + ':' + minute + ':' + second;
+}
tim.on(TIM.EVENT.MESSAGE_RECEIVED, function(event) {
// 收到推送的单聊、群聊、群提示、群系统通知的新消息,可通过遍历 event.data 获取消息列表数据并渲染到页面
// event.name - TIM.EVENT.MESSAGE_RECEIVED
// event.data - 存储 Message 对象的数组 - [Message]
+ console.log(event.data)
+ for(let i in event.data){
+ if(!event.data[i].payload.text){
+ break;
+ }
+ const list = $("#liaotianliebiao")
+ const html = `
+
${formatDateTime(event.data[i].time)}
+
${event.data[i].nick}:${event.data[i].payload.text}
+
`
+
+ list.append(html)
+ }
});
tim.on(TIM.EVENT.MESSAGE_REVOKED, function(event) {
@@ -81,8 +104,104 @@ tim.on(TIM.EVENT.SDK_READY, function(event) {
// \- TIM.TYPES.NET_STATE_DISCONNECTED - 未接入网络。接入侧可根据此状态提示“当前网络不可用”。SDK 仍会继续重试,若用户网络恢复,SDK 会自动同步消息
});
genTestUserSig(window.mid).then((res)=>{
- tim.login({userID: window.mid, userSig: res.data});
+ tim.login({userID: window.mid, userSig: res.data}).then(function(imResponse) {
+ console.log(imResponse.data); // 登录成功
+ if (imResponse.data.repeatLogin === true) {
+ // 标识账号已登录,本次登录操作为重复登录。v2.5.1 起支持
+ console.log(imResponse.data.errorInfo);
+ }
+ }).catch(function(imError) {
+ console.warn('login error:', imError); // 登录失败的相关信息
+ });
})
+ tim.on(TIM.EVENT.SDK_READY, function (){
+ tim.updateMyProfile({
+ nick: '我的昵称'
+ });
+ const promise = tim.createGroup({
+ type: TIM.TYPES.GRP_AVCHATROOM,
+ name: 'live',
+ groupID: window.roomid
+ });
+
+ promise.then(function(imResponse) { // 创建成功
+ console.log(imResponse.data.group); // 创建的群的资料
+ tim.joinGroup({
+ groupID: window.roomid,
+ type: TIM.TYPES.GRP_AVCHATROOM
+ }).then((res)=>{
+ switch (res.data.status) {
+ case TIM.TYPES.JOIN_STATUS_WAIT_APPROVAL: // 等待管理员同意
+ break;
+ case TIM.TYPES.JOIN_STATUS_SUCCESS: // 加群成功
+ console.log(res.data.group); // 加入的群组资料
+ break;
+ case TIM.TYPES.JOIN_STATUS_ALREADY_IN_GROUP: // 已经在群中
+ break;
+ default:
+ break;
+ }
+ }).catch((err)=>{
+ console.log(err)
+ })
+ }).catch(function(imError) {
+ console.warn('createGroup error:', imError); // 创建群组失败的相关信息
+ tim.joinGroup({
+ groupID: window.roomid,
+ type: TIM.TYPES.GRP_AVCHATROOM
+ }).then((res)=>{
+ switch (res.data.status) {
+ case TIM.TYPES.JOIN_STATUS_WAIT_APPROVAL: // 等待管理员同意
+ break;
+ case TIM.TYPES.JOIN_STATUS_SUCCESS: // 加群成功
+ console.log(res.data.group); // 加入的群组资料
+ break;
+ case TIM.TYPES.JOIN_STATUS_ALREADY_IN_GROUP: // 已经在群中
+ break;
+ default:
+ break;
+ }
+ }).catch((err)=>{
+ console.log(err)
+ })
+ });
+ function sendtext(text){
+ const m = tim.createTextMessage({
+ to: window.roomid,
+ conversationType: TIM.TYPES.CONV_GROUP,
+ payload: {
+ text: text
+ }
+ })
+ const promise = tim.sendMessage(m);
+ promise.then(function(imResponse) {
+ // 发送成功
+ console.log(imResponse);
+
+ const list = $("#liaotianliebiao")
+ const html = `
+
${formatDateTime(imResponse.data.message.time)}
+
${imResponse.data.message.nick}:${imResponse.data.message.payload.text}
+
`
+ console.log(html)
+ list.append(html)
+ }).catch(function(imError) {
+ // 发送失败
+ console.warn('sendMessage error:', imError);
+ });
+ }
+ $(()=>{
+ $("#fasongxiaoxi").click(()=>{
+ const text = $("#shurukuang").val()
+ console.log(text)
+ sendtext(text)
+ $("#shurukuang").val("")
+ })
+ })
+
+
+
+});
// 开始登录
\ No newline at end of file
diff --git a/public/zhibo.html b/public/zhibo.html
index dc9e266..0b760b2 100644
--- a/public/zhibo.html
+++ b/public/zhibo.html
@@ -376,47 +376,13 @@
-
-
-
00:00:00
-
andy:asdhjfhujaksdhfjkasdjhhjasjhfhjkas
-
-
-
00:00:00
-
andy:asdhjfhujaksdhfjkasdjhhjasjhfhjkas
-
-
-
00:00:00
-
andy:asdhjfhujaksdhfjkasdjhhjasjhfhjkas
-
-
-
00:00:00
-
andy:asdhjfhujaksdhfjkasdjhhjasjhfhjkas
-
-
-
00:00:00
-
andy:asdhjfhujaksdhfjkasdjhhjasjhfhjkas
-
-
-
00:00:00
-
andy:asdhjfhujaksdhfjkasdjhhjasjhfhjkas
-
-
-
00:00:00
-
andy:asdhjfhujaksdhfjkasdjhhjasjhfhjkas
-
-
-
00:00:00
-
andy:asdhjfhujaksdhfjkasdjhhjasjhfhjkas
-
-
-
00:00:00
-
andy:asdhjfhujaksdhfjkasdjhhjasjhfhjkas
-
+
+
+