im_sunclient_wev8.js
30.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
/*
* 向日葵被控端登录
* dll中内置有断网操作,长时间断网断网的话会走回调SLIsInit =false
* */
function SunClinetLogin(sunid, sunkey) {
this.m_sunid = sunid;
this.m_sunkey = sunkey;
this.isSupport = false;
//dll是否已经初始化成功
this.SLIsInit = false;
//正在初始化
this.isIniting = false;
//被控端id
this.m_client = -1
//创建的会话id
this.m_session = -1;
//远程连接的地址
this.m_address = "";
this.m_sessionname = "";
this.SLSESSION_CALLBACK_PROP;
this.OpenClientLog = true;
this.SLOpenClientLog = function () {
this.OpenClientLog = this.slsdk.SLOpenClientLog(this.m_client, require("path").join(window.Electron.ipcRenderer.sendSync('global-getAppPath'), '/extension/'));
this.log("日志开启成功!");
};
//初始化设备
this.Initialize = function (flag, callback) {
var _self = this;
if (_self.slsdk && (!_self.SLIsInit || flag) && !_self.isIniting && _self.isSupport) {
_self.isIniting = true;
_self.SLIsInit = _self.slsdk.SLInitialize();
_self.m_client = _self.slsdk.SLCreateClient();//创建一个被控制端
_self.m_clientCallback = _self.slsdk.ffi.Callback('void', ['int', 'int', 'int'], function (client, event, custom) {
_self.isIniting = false;
if (event != 2 && event != 0) {
_self.SLIsInit = false;
_self.m_address = "";
}
switch (event) {
case 0 :
_self.log("连接服务器成功");
break;
case 1:
_self.log("与服务器断开连接");
callback = null;
break;
case 2:
_self.log("登录服务器成功");
_self.m_address = _self.slsdk.SLGetClientAddress(client);//获取地址
callback && _self.getSession(callback);
break;
case 3:
_self.log("登录服务器失败");
break;
}
//监听服务状态改变
_self.clientListener && _self.clientListener.onChanged(event);
});
_self.slsdk.SLSetClientCallback(_self.m_client, _self.m_clientCallback, 0) && _self.log('SLSetClientCallback启动回调');
!_self.slsdk.SLClientLoginWithOpenID(_self.m_client, _self.m_sunid, _self.m_sunkey) && callback.onError && callback.onError("被控端登录服务失败!");// 被控制端登录服务器
}
}
//获取session
this.getSession = function (callback) {
var slsdk = this.slsdk;
if (slsdk) {
if (this.m_address == "") {
this.Initialize(false, callback);
} else {
if (this.m_session >= 0) {
slsdk.SLDestroyClientSession(this.m_client, this.m_session);
this.m_sessionname = "";
}
this.m_session = slsdk.SLCreateClientSession(this.m_client, 0);
this.m_sessionname = slsdk.SLGetClientSessionName(this.m_client, this.m_session);//获取session
//设置回调属性
var prop = new this.SLSESSION_CALLBACK_PROP();
prop.nCustom = this.m_session;
prop.SLSESSION_CALLBACK = slsdk.ffi.Callback('void', ['int', 'int', 'string', 'int'], function (session, event, var1) {
if (event == 1) {
console.log("会话连接成功!session" + session);
} else {
console.log("会话连接断开!session" + session);
}
callback && callback.onClientStatus(event);
});
this.currentProp = prop;
slsdk.SLSetClientSessionOpt(this.m_client, this.m_session, 2, this.currentProp.ref(), this.currentProp.ref().length);
if (this.m_address == "" || this.m_sessionname == "") {
callback && callback.onError(this.m_address, this.m_sessionname);
} else {
callback && callback.onSuccess(this.m_address, this.m_sessionname);
}
}
}else{
callback.onError && callback.onError();
}
};
this.log = function (log) {
if (this.OpenClientLog) {
console.log(log);
}
}
}
//装载 dll. 初始化 Sunclientlogin 基本信息
SunClinetLogin.init = function (sunid, sunkey, clientListener, callback) {
var instance = null;
SunClinetLogin.getInstance === undefined && (SunClinetLogin.getInstance = function () {
if (instance == null) {
instance = new SunClinetLogin(sunid, sunkey);
instance.clientListener = clientListener;
if (process.versions.electron == "1.6.10" && process.platform == "win32") {
instance.isSupport = true;
}
if (!instance.slsdk && instance.isSupport) {
try {
var ffi = require('ffi');
var path = require("path");
var Struct = require('ref-struct');
// SLSESSION_CALLBACK_PROP 结构体,设置被控制端某个会话某个属性值
instance.SLSESSION_CALLBACK_PROP = Struct({
"SLSESSION_CALLBACK": "pointer",
"nCustom": "int"
});
instance.slsdk = ffi.Library(path.join(window.Electron.ipcRenderer.sendSync('global-getAppPath'), '/extension/slsdk.dll'), {
// 被控端函数
// 初始化
'SLInitialize': ['bool', []],
//注销
'SLUninitialize': ['bool', []],
// 创建一个被控制端
'SLCreateClient': ['int', []],
// 被控制端登录服务器
'SLClientLoginWithOpenID': ['bool', ['int', 'string', 'string']],
// address
'SLGetClientAddress': ['string', ['int']],
//创建一个session
'SLCreateClientSession': ['int', ['int', 'int']],
//session
'SLGetClientSessionName': ['string', ['int', 'int']],
//日志打印
'SLOpenClientLog': ['bool', ['int', 'string']],
//销毁一个会话
'SLDestroyClientSession': ['bool', ['int', 'int']],
//销毁一个连接
'SLDestroyClient': ['bool', ['int']],
//SLSESSION_CALLBACK 连接回调
'SLSetClientCallback': ['bool', ['int', 'pointer', 'int']],
//SLSetClientSessionOpt 设置被控制端某个会话某个属性值
'SLSetClientSessionOpt': ['bool', ['int', 'int', 'int', 'string', 'int']]
});
instance.slsdk.ffi = ffi;
} catch (e) {
console.log(e);
instance.isSupport = false;
}
}
}
return instance;
})();
return SunClinetLogin.getInstance();
}
/*
* 向日葵工具类
**/
var SunClientUtil = {
host: window.location.origin,
sessionkey: "" || window.Electron && window.Electron.ipcRenderer.sendSync('global-getSessionKey'),
sunid: "",
sunkey: "",
address: {},
remoteRemindWin: {},
remoteWin:{},//目前已经打开的远程窗口
requestid: {},//对象id targetid 请求要邀请对象不能重复
inviteid: -1,//当前主控id 一个pc只能有一个主控.
status: {
0: "请求中",//请求控制
1: "取消",//请求取消
2: "拒绝",//拒绝请求
3: "接受",//接受请求
4: "邀请中",//邀请对方
5: "取消",//邀请取消
6: "拒绝",//拒绝邀请
7: "接受",//接受邀请
8: "断开", //主控断开
9: "断开",//被控断开
10: "连接中"
},
//监听向日葵的登录状态
clientListener: {
onChanged: function (event) {
if (event != 2 && event != 0) {
console.log("登录失败或者服务异常,请重新登录");
alert("远程服务器异常,请稍后再试试。");
} else {
console.log("登录向日葵正常");
}
}
},
sunClinetLogin: function () {
return SunClinetLogin.init(this.sunid, this.sunkey, this.clientListener);
},
//初始化环境
init: function () {
$.getJSON("/social/im/SocialIMOperation.jsp?operation=getSunkey", function (data) {
if (data) {
SunClientUtil.sunid = data.sunid;
SunClientUtil.sunkey = data.sunkey;
}
});
if(window.Electron){
//接受邀请或者请求
window.Electron.ipcRenderer.on("sun-accept-remote", function (event, args) {
SunClientUtil.acceptRemote(args.userid, args.remoteType);
});
//拒绝邀请或者请求
window.Electron.ipcRenderer.on("sun-refuse-remote", function (event, args) {
SunClientUtil.refuseRemote(args.userid, args.remoteType - 1);
});
}
},
/*
* 是否发起远程协助
* */
isSupport:function () {
return ChatUtil.isFromPc() && SunClientUtil.sunClinetLogin().isSupport;
},
//接受远程
acceptRemote: function (targetid, remoteType) {
if (remoteType == 3) {
//接受请求
this.sendSunAddr(targetid);
} else if (remoteType == 7) {
//接受邀请
this.remoteClient(targetid);
}
},
//拒绝取消远程
refuseRemote: function (targetid, remoteType) {
if (remoteType == 0) {
// 取消请求
remoteType = 1;
} else if (remoteType == 4) {
remoteType = 5;
//取消邀请
}
this.sendMsg(targetid, remoteType, "", "", function (data) {
if (data.issuccess) {
var extra = data.paramzip.msgobj.extra;
var extraObj = eval("(" + extra + ")");
SunClientUtil.refuseRemoteHandle(extraObj.receiverids, extraObj.remoteType);
}
})
},
refuseRemoteHandle: function (targetid, remoteType) {
var postFloatNotice = "";
if (remoteType == 1) {
// 取消请求
postFloatNotice = "您取消了远程协助的请求";
} else if (remoteType == 2) {
//拒绝请求
var invitewin = SunClientUtil.remoteRemindWin["request_" + targetid];
if (invitewin) invitewin.close();
var userinfo = getUserInfo(targetid);
postFloatNotice = "您拒绝了" + userinfo.userName + "的远程协助请求";
} else if (remoteType == 5) {
//取消邀请
postFloatNotice = "您取消了远程协助的邀请";
} else if (remoteType == 6) {
//拒绝邀请
var invitewin = SunClientUtil.remoteRemindWin["invite_" + targetid];
if (invitewin) invitewin.close();
var userinfo = getUserInfo(targetid);
postFloatNotice = "您拒绝了" + userinfo.userName + "的远程协助邀请";
}
SunClientUtil.changeRemoteStatusDiv(targetid, -1);
SunClientUtil.postFloatNotice(targetid,postFloatNotice);
},
//断开会话后操作
closeRemote:function (targetid,msg) {
SunClientUtil.changeRemoteStatusDiv(targetid, -1);
var msgcontent = msg||"远程已经断开!";
SunClientUtil.postFloatNotice(targetid,msgcontent);
},
postFloatNotice:function (targetid,msg,callback) {
var $chatWin = $("#chatWin_0_"+targetid);
if($chatWin.length >0){
var msgcontent = msg||"提醒";
var options ={};
options.timeout = 5*1000;
options.chatwin = $chatWin;
ChatUtil.postFloatNotice(msgcontent, "info",options);
}
},
//被控制端发送远程地址
sendSunAddr: function (targetid, callback) {
var self = this;
var sunClient = self.sunClinetLogin();
if (sunClient) {
var callback = {
onClientStatus: function (event) {
if (event == 1) {
SunClientUtil.changeRemoteStatusDiv(targetid, 9);
} else {
// 会话断开后操作
SunClientUtil.closeRemote(targetid);
}
},
onSuccess: function (addr, name) {
SunClientUtil.changeRemoteStatusDiv(targetid, 10);
SunClientUtil.sendMsg(targetid, 3, addr, name, function (data) {
if (!!data.issuccess) {
// 消息发送后操作
SunClientUtil.inviteid = targetid;
}
});
},
onError: function (addr, name) {
}
}
var invitewin = SunClientUtil.remoteRemindWin["request_" + targetid];
if (invitewin) invitewin.close();
sunClient.getSession(callback);
}
},
//主控端
remoteClient: function (targetid) {
var url = this.address["invite_" + targetid];
if (url) {
var finalUrl = this.host + url + "&sessionkey=" + this.sessionkey;
if (ChatUtil.isFromPc()) {
var invitewin = this.remoteRemindWin["invite_" + targetid];
if (invitewin) invitewin.close();
var BrowserWindow = require('electron').remote.BrowserWindow;
var userinfo = getUserInfo(targetid);
var options = {autoHideMenuBar: false, width: 1800, height: 1800}
options.title = "正在远程"+userinfo.userName +"/" +userinfo.deptName;
var win = new BrowserWindow(options);
win.on('close', function () {
win = null;
SunClientUtil.closeRemote(targetid);
delete SunClientUtil.address["invite_" + targetid];
});
win.loadURL(finalUrl);
win.show();
this.changeRemoteStatusDiv(targetid, 8);
} else {
delete SunClientUtil.address["invite_" + targetid];
SunClientUtil.changeRemoteStatusDiv(targetid, 8);
openUrlFromEmessge(finalUrl);
}
}
},
//远程弹框提醒
remoteRemind: function (data) {
this.requestid[data.userid] = true;
this.changeRemoteStatusDiv(data.userid, data.remoteType);
if (ChatUtil.isFromPc()) {
var winid = data.remoteType ==3?"request_"+data.userid : "invite_"+data.userid;
var url = this.host + "/social/im/sunlogin/SocialIMRemindSun.jsp";
var options = {
resizable: false,
frame: false,
show: false,
skipTaskbar: true,
alwaysOnTop: true
};
options.width = 320;
options.height = 195;
var primaryDisplay = require('electron').screen.getPrimaryDisplay();
var workAreaSize = primaryDisplay.workArea; //工作空间 h w x y
options.x = workAreaSize.width + workAreaSize.x - options.width - 20;
options.y = workAreaSize.height + workAreaSize.y - options.height;
var BrowserWindow = require('electron').remote.BrowserWindow;
var win = new BrowserWindow(options);
win.webContents.on('dom-ready', function (event) {
win.show();
if (!win.isFocused()) {
win.minimize();
win.showInactive();
}
win.webContents.send('sun-remind', data);
});
win.on('close', function () {
win = null;
delete SunClientUtil.remoteRemindWin[winid];
});
win.loadURL(url);
this.remoteRemindWin[winid] = win;
}
},
/*
*显示选择远程的类似 是邀请还是请求控制,web版本只有请求控制对方
* status 0 不在线 1 pc在线 2 web在线
* */
showRemoteType: function (obj) {
var targeid = $(obj).parents(".chatWin").attr('_targetid');
$('.remotesun').css('left', event.pageX - 160 + 'px');
$.getJSON('/social/im/SocialIMOperation.jsp', {
operation: 'checkOnLineStatus',
targetid: targeid
}, function (data) {
var $remotesun = $(obj).parents('.chatbottom').find(".remotesun");
var $remotesunItme = $remotesun.find("div[class^=remotesunItme]");
var status = data.status;
if("0"==status){
IM_Ext.showMsg("对方不在线");
}else{
for (var i = 0; i < $remotesunItme.length; i++) {
var temp = $remotesunItme[i];
if (temp.getAttribute("_index") == 0) {
if (SunClientUtil.requestid[targeid] || status ==2) {
temp.className = "remotesunItmeActive";
} else {
temp.className = "remotesunItme";
}
} else if (temp.getAttribute("_index") == 1) {
if (SunClientUtil.requestid[targeid] || SunClientUtil.inviteid != -1 || !ChatUtil.isFromPc()) {
temp.className = "remotesunItmeActive";
} else {
temp.className = "remotesunItme";
}
}
}
if ($remotesun.is(":hidden")) {
$remotesun.show();
} else {
$remotesun.hide();
}
}
});
stopEvent();
},
//请求控制对方电脑
remoteRequest: function (obj) {
if (obj.className == "remotesunItmeActive") return;
var $obj = $(obj);
var $chatWin = $obj.parents(".chatWin");
var targetid = $chatWin.attr("_targetid");
this.requestid[targetid] = true;
if ($chatWin.attr("_targettype") == 0) {
obj.className = "remotesunItmeActive";
obj.parentElement.parentElement.style.display = "none";
this.sendMsg(targetid, 0, "", "", function (data) {
if (data && data.issuccess) {
SunClientUtil.changeRemoteStatusDiv(targetid, 0);
} else {
obj.className = "remotesunItme";
SunClientUtil.changeRemoteStatusDiv(targetid, -1);
//请求失败
SunClientUtil.postFloatNotice(targetid,"请求远程失败,请重新尝试");
}
})
}
},
//邀请对方远程协助
remoteInvite: function (obj) {
if (obj.className == "remotesunItmeActive") return;
obj.className = "remotesunItmeActive";
obj.parentElement.parentElement.style.display = "none";
var self = this;
var sunClient = self.sunClinetLogin();
var $obj = $(obj);
var $chatWin = $obj.parents(".chatWin");
var targetid = $chatWin.attr("_targetid");
this.inviteid = targetid;
if ($chatWin.attr("_targettype") == 0) {
var callback = {
onClientStatus: function (event) {
if (event == 1) {
SunClientUtil.changeRemoteStatusDiv(targetid, 9);
} else {
SunClientUtil.closeRemote(targetid);
}
},
onSuccess: function (addr, name) {
SunClientUtil.sendMsg(targetid, 4, addr, name, function (data) {
if (data.issuccess) {
SunClientUtil.changeRemoteStatusDiv(targetid, 4);
}
});
},
onError: function (msg) {
alert(msg || "当前客户端不支持远程!");
SunClientUtil.changeRemoteStatusDiv(targetid, -1);
}
}
sunClient.getSession(callback);
}
},
/*
* targeid 会话id
* remoteType 远程类型
* 请求控制对方电脑 :0
* 请求取消 :1
* 拒绝请求:2
* 接受请求:3
*
* 邀请对方远程协助 :4
* 邀请取消 :5
* 拒绝邀请 : 6
* 接受邀请:7
* 主控断开: 8
* 被控断开:9
*
* 当前忙或者版本不支持:10
* */
sendMsg: function (targetid, remoteType, m_address, m_sessionname, callback) {
var sendTime = M_CURRENTTIME || new Date().getTime();
var msgid = IMUtil.guid();
var extraObj = {};
extraObj.msg_id = msgid;
extraObj.senderid = M_USERID;
extraObj.receiverids = targetid;
extraObj.sendTime = sendTime;
extraObj.remoteType = remoteType;
if (m_address && m_sessionname) {
extraObj.address = m_address;
extraObj.sessionName = m_sessionname;
}
var extra = JSON.stringify(extraObj);
var content = '{"content":{"pushType":"weaver_remote"}, "extra":' + extra + '}';
var msgObj = {
"content": content,
"objectName": "FW:SysMsg",
"msgType": 6,
"extra": extra,
"senderid": M_USERID,
"targetid": targetid,
"targetType": "FW:SysMsg"
};
client && client.sendMessageToUser(targetid, msgObj, 6, function (data) {
typeof callback === 'function' && callback(data);
});
},
mouseoverEvent:function (type,overandout,obj) {
/*if(type== 0){
if(overandout==0){
obj.offsetParent.childNodes[1].classList.add('request-active');
}else{
obj.offsetParent.childNodes[1].classList.remove('request-active');
}
}else if(type ==1){
if(overandout==0){
obj.offsetParent.childNodes[3].classList.add('invite-active');
}else{
obj.offsetParent.childNodes[3].classList.remove('invite-active');
}
}*/
},
getRemoteStatusMsg:function (targetid,status) {
var userName = getUserInfo(targetid).userName;
var msg ="";
switch (status){
case 0:
case 1:
msg = "您正在请求远程控制"+userName+"的电脑,请等待对方回应";
break;
case 2:
case 3:
msg = userName +"正在请求远程控制您的电脑";
case 4:
case 5:
msg = "您正在邀请"+userName+"远程控制您的电脑,请等待对方回应";
break;
case 6:
case 7:
msg = userName +"正在邀请您远程控制他/她的电脑";
break;
case 8:
msg = "您正在远程控制"+userName+"的电脑";
break;
case 9:
msg = userName+"正在远程控制您的电脑";
break;
}
return msg;
},
/*
* status :-1 恢复初始状态
* */
changeRemoteStatusDiv: function (targetid, status) {
var $remotemsgdiv = $("#remotemsg_" + targetid);
if (status > -1) {
var $conversationstatus = $("#conversationstatus_" + targetid);
if ($conversationstatus.length == 0) {
$("#conversation_" + targetid).append($("<div id ='conversationstatus_" + targetid + "' class='chatItemRemoteActive'> </div>"));
}
var $remoteStatusDiv = $remotemsgdiv.find(".status");
if ($remoteStatusDiv.length > 0) {
$remoteStatusDiv.empty();
}
if (status % 4 == 3) {
$remoteStatusDiv.prepend("<div class='remotebtn acceptbtn' _remoteType ='" + status + "' _targetId ='" + targetid + "' onclick='SunClientUtil.remoteStatusHandle(this)'></div>" +
"<div class='remotebtn refusebtn' _remoteType ='" + (status - 1) + "' _targetId ='" + targetid + "' onclick='SunClientUtil.remoteStatusHandle(this)'></div>")
} else if(status < 8){
$remoteStatusDiv.prepend("<div class='remotebtn cancelbtn' _remoteType ='" + status + "' _targetId ='" + targetid + "' onclick='SunClientUtil.remoteStatusHandle(this)'></div>")
}else{
$remoteStatusDiv.prepend("<div class='remotebtn hangupbtn' _remoteType ='" + status + "' _targetId ='" + targetid + "' onclick='SunClientUtil.remoteStatusHandle(this)'></div>")
}
$remotemsgdiv.find(".msg").html(this.getRemoteStatusMsg(targetid,status));
$remotemsgdiv.show();
} else {
if (this.requestid[targetid]) {
this.requestid[targetid] =false;
}
if (this.inviteid = targetid) {
this.inviteid = -1;
}
$("#conversationstatus_" + targetid).remove();
$remotemsgdiv.hide();
}
},
remoteStatusHandle: function (obj) {
$('.remotesun').hide();
var _remoteType = Number(obj.getAttribute("_remoteType"));
var _targetid = obj.getAttribute("_targetId");
if (_remoteType == 3 || _remoteType == 7) {
this.acceptRemote(_targetid, _remoteType);
} else if (_remoteType == 8 ||_remoteType ==9||_remoteType ==10) {
if(_remoteType ==10 ) _remoteType =9;
if(_remoteType ==9){
SunClientUtil.sunClinetLogin().getSession();
}
this.sendMsg(_targetid,_remoteType,"","",function (data) {
SunClientUtil.closeRemote(_targetid);
})
} else {
this.refuseRemote(_targetid, _remoteType);
}
event.stopPropagation();
},
HandleSysMsgUitl: function (allContent) {
var extra = allContent.extra;
var targetid = extra.senderid;
switch (extra.remoteType) {
case 0:
if(this.isSupport()){
var args = getUserInfo(targetid);
args.remoteType = 3;
$('#conversation_' + targetid).click();
showConverChatpanel("",{targetId:targetid,
targetName:args.userName,
targetHead:args.userHead,
targetType:0});
setTimeout(function () {
SunClientUtil.remoteRemind(args);
},1000);
}else{
this.sendMsg(targetid,10);
}
break;
case 1:
var userinfo = getUserInfo(targetid);
var invitewin = SunClientUtil.remoteRemindWin["request_" + targetid];
if (invitewin) invitewin.close();
SunClientUtil.changeRemoteStatusDiv(targetid, -1);
SunClientUtil.postFloatNotice(targetid,userinfo.userName + "取消了远程邀请");
break;
case 2:
var userinfo = getUserInfo(targetid);
SunClientUtil.changeRemoteStatusDiv(targetid, -1);
SunClientUtil.postFloatNotice(targetid,userinfo.userName + "拒绝了您的远程请求");
break;
case 3:
var url = "/social/im/sunlogin/SocialIMSunlogin.html?address=" + extra.address + "&cid=" + extra.sessionName;
//记录远程地址
this.address["invite_" + extra.senderid] = url;
this.remoteClient(targetid);
break;
case 4:
var args = getUserInfo(targetid);
args.address = extra.address;
args.sessionName = extra.sessionName;
//接收邀请,己方展示的是接受、拒绝
args.remoteType = 7;
var url = "/social/im/sunlogin/SocialIMSunlogin.html?address=" + args.address + "&cid=" + args.sessionName;
//记录远程地址
this.address["invite_" + args.userid] = url;
$('#conversation_' + targetid).click();
showConverChatpanel("",{targetId:targetid,
targetName:args.userName,
targetHead:args.userHead,
targetType:0});
setTimeout(function () {
SunClientUtil.remoteRemind(args);
},1000);
break;
case 5:
var userinfo = getUserInfo(targetid);
var invitewin = SunClientUtil.remoteRemindWin["invite_" + targetid];
if (invitewin) invitewin.close();
SunClientUtil.changeRemoteStatusDiv(targetid, -1);
SunClientUtil.postFloatNotice( targetid ,userinfo.userName + "取消了远程邀请");
break;
case 6:
var userinfo = getUserInfo(targetid);
SunClientUtil.changeRemoteStatusDiv(targetid, -1);
SunClientUtil.postFloatNotice(targetid,userinfo.userName + "拒绝了您的远程邀请");
break;
case 8:
SunClientUtil.sunClinetLogin().getSession();
case 9:
SunClientUtil.closeRemote(targetid);
break;
case 10:
var userinfo = getUserInfo(targetid);
SunClientUtil.changeRemoteStatusDiv(targetid, -1);
SunClientUtil.postFloatNotice(targetid,userinfo.userName + " 对方暂时无法接受远程请求");
break;
}
}
};
SunClientUtil.init();