|
@@ -243,12 +243,10 @@ us.server = us.http.createServer(function (requset, response) {
|
|
break;
|
|
break;
|
|
//新建导航文件保存
|
|
//新建导航文件保存
|
|
case 'newNavSave':
|
|
case 'newNavSave':
|
|
- //, _param[5], _param[6], _param[7]
|
|
|
|
us.newNavSave(response, _param[0], _param[1], _param[2], _param[3], _param[4], _param[5], _param[6]);
|
|
us.newNavSave(response, _param[0], _param[1], _param[2], _param[3], _param[4], _param[5], _param[6]);
|
|
break;
|
|
break;
|
|
//加入文档编辑
|
|
//加入文档编辑
|
|
case 'addWord':
|
|
case 'addWord':
|
|
- //us.addWord(response, _param[0]);
|
|
|
|
break;
|
|
break;
|
|
//加入Excel表格编辑
|
|
//加入Excel表格编辑
|
|
case 'addExcel':
|
|
case 'addExcel':
|
|
@@ -388,6 +386,40 @@ us.addUser = function (response, type, fileid, userids, userid, pageid) {
|
|
response.end('addUserSuccess'); //返回文档内容
|
|
response.end('addUserSuccess'); //返回文档内容
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+* 根据用户集合,获取详细的用户信息
|
|
|
|
+*
|
|
|
|
+* @param {object} userids 用户id集合
|
|
|
|
+**/
|
|
|
|
+us.getuserbytype = function (userids) {
|
|
|
|
+ var _userinfo = [];
|
|
|
|
+ for (var i in userids) {
|
|
|
|
+ _userinfo.push(us.user[i])
|
|
|
|
+ }
|
|
|
|
+ return _userinfo;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+* 用户加入某个项目后通知所有已经在项目的用户
|
|
|
|
+*
|
|
|
|
+* @param {object} userinfo 用户信息
|
|
|
|
+* @param {string} type 项目类型
|
|
|
|
+* @param {string} fileid 项目的id
|
|
|
|
+**/
|
|
|
|
+us.sendUser = function (userinfo, type, pageid, fileid) {
|
|
|
|
+ var _message = {};
|
|
|
|
+ var _messageinfo = us.message(userinfo.userid, 'us.' + type, {
|
|
|
|
+ id: us.createGuid(),
|
|
|
|
+ type: "addUser",
|
|
|
|
+ userinfo: userinfo,
|
|
|
|
+ docId: fileid
|
|
|
|
+ });
|
|
|
|
+ _message[fileid] = [_messageinfo];
|
|
|
|
+ us.broadcast(_message, pageid, type);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取用户传参异步
|
|
* 获取用户传参异步
|
|
*
|
|
*
|
|
@@ -474,15 +506,12 @@ us.unifyDispose = function (req, res, cb) {
|
|
* @param {type} username 用户登录类型
|
|
* @param {type} username 用户登录类型
|
|
**/
|
|
**/
|
|
us.login = function (response, userid, pageid, username, type) {
|
|
us.login = function (response, userid, pageid, username, type) {
|
|
- //console.log(userid);
|
|
|
|
-
|
|
|
|
//用户登录信息表,以后移入redis
|
|
//用户登录信息表,以后移入redis
|
|
//如果用户信息不存在则新建一个用户信息存入
|
|
//如果用户信息不存在则新建一个用户信息存入
|
|
if (!us.user[userid]) {
|
|
if (!us.user[userid]) {
|
|
var _userinfo = us.userInfo(userid, username); //初始化用户信息
|
|
var _userinfo = us.userInfo(userid, username); //初始化用户信息
|
|
us.user[userid] = _userinfo;
|
|
us.user[userid] = _userinfo;
|
|
}
|
|
}
|
|
- //console.log(us.user);
|
|
|
|
//添加用户轮询列表
|
|
//添加用户轮询列表
|
|
us.polling(response, userid, pageid, type);
|
|
us.polling(response, userid, pageid, type);
|
|
}
|
|
}
|
|
@@ -534,10 +563,6 @@ us.offLine = function (response, userid, pageid) {
|
|
* @param {string} pageid 页面ID(用户登录唯一识别ID)
|
|
* @param {string} pageid 页面ID(用户登录唯一识别ID)
|
|
**/
|
|
**/
|
|
us.polling = function (response, userid, pageid, type) {
|
|
us.polling = function (response, userid, pageid, type) {
|
|
- console.log("aaaaaaaaaaaaaaaaaaaa")
|
|
|
|
- console.log(userid)
|
|
|
|
- console.log(pageid)
|
|
|
|
- console.log(type)
|
|
|
|
//判断轮询的用户是否在连接池中
|
|
//判断轮询的用户是否在连接池中
|
|
if (us.connect[userid]) {
|
|
if (us.connect[userid]) {
|
|
var _userarray = us.connect[userid], //用户连接池,获取制定用户连接的数量,
|
|
var _userarray = us.connect[userid], //用户连接池,获取制定用户连接的数量,
|
|
@@ -546,7 +571,6 @@ us.polling = function (response, userid, pageid, type) {
|
|
//获取当前连接的用户,如果获取成功那么直接修改用户的连接
|
|
//获取当前连接的用户,如果获取成功那么直接修改用户的连接
|
|
if (_userarray[pageid]) {
|
|
if (_userarray[pageid]) {
|
|
_userarray[pageid].response = response;
|
|
_userarray[pageid].response = response;
|
|
- // console.log(pageid);
|
|
|
|
if (_messagearray && _messagearray.message.length > 0) {
|
|
if (_messagearray && _messagearray.message.length > 0) {
|
|
response.write(JSON.stringify(_messagearray.message));
|
|
response.write(JSON.stringify(_messagearray.message));
|
|
_messagearray.message = [];
|
|
_messagearray.message = [];
|
|
@@ -566,7 +590,6 @@ us.polling = function (response, userid, pageid, type) {
|
|
us.connect[userid][pageid] = _userconect;
|
|
us.connect[userid][pageid] = _userconect;
|
|
us.offLineMessage[pageid] = us.userOffLineMessage(type); //初始化用户离线消息记录
|
|
us.offLineMessage[pageid] = us.userOffLineMessage(type); //初始化用户离线消息记录
|
|
}
|
|
}
|
|
- //console.log(us.connect);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -586,7 +609,7 @@ us.send = function (response, messageinfo) {
|
|
for (i in _messageobj) {
|
|
for (i in _messageobj) {
|
|
//console.log(i);
|
|
//console.log(i);
|
|
switch (i) {
|
|
switch (i) {
|
|
- //思维网格交互
|
|
|
|
|
|
+ //思维网格交互
|
|
case "us.mindNetwork":
|
|
case "us.mindNetwork":
|
|
_messagearr = _messageobj[i]; //获取word消息
|
|
_messagearr = _messageobj[i]; //获取word消息
|
|
//得到word所有的用户
|
|
//得到word所有的用户
|
|
@@ -649,7 +672,7 @@ us.send = function (response, messageinfo) {
|
|
//调用群发函数
|
|
//调用群发函数
|
|
_messagearr[0] && us.broadcast(_messagelist, _messagearr[0].messageInfo.pageId, 'realTimeClass');
|
|
_messagearr[0] && us.broadcast(_messagelist, _messagearr[0].messageInfo.pageId, 'realTimeClass');
|
|
break;
|
|
break;
|
|
- //word信息交互
|
|
|
|
|
|
+ //word信息交互
|
|
case "us.word":
|
|
case "us.word":
|
|
try {
|
|
try {
|
|
_messagearr = _messageobj[i]; //获取word消息
|
|
_messagearr = _messageobj[i]; //获取word消息
|
|
@@ -675,7 +698,7 @@ us.send = function (response, messageinfo) {
|
|
console.log(e)
|
|
console.log(e)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
- //用户信息的交互
|
|
|
|
|
|
+ //用户信息的交互
|
|
case "us.excel":
|
|
case "us.excel":
|
|
_messagearr = _messageobj[i]; //获取excel消息
|
|
_messagearr = _messageobj[i]; //获取excel消息
|
|
//得到excel所有的用户
|
|
//得到excel所有的用户
|
|
@@ -751,10 +774,10 @@ us.updatecscl = function (messageInfo, classId, ty) {
|
|
_obj.backgroundUrl = messageInfo.backgroundUrl;
|
|
_obj.backgroundUrl = messageInfo.backgroundUrl;
|
|
_obj.edges = _obj.edges || [];
|
|
_obj.edges = _obj.edges || [];
|
|
_obj.nodes = _obj.nodes || [];
|
|
_obj.nodes = _obj.nodes || [];
|
|
- console.log("------------s------------");
|
|
|
|
- console.log(messageInfo);
|
|
|
|
- console.log(_obj);
|
|
|
|
- console.log(ty);
|
|
|
|
|
|
+ // console.log("------------s------------");
|
|
|
|
+ // console.log(messageInfo);
|
|
|
|
+ // console.log(_obj);
|
|
|
|
+ // console.log(ty);
|
|
for (j = 0; j < messageInfo.edges.length; j++) {
|
|
for (j = 0; j < messageInfo.edges.length; j++) {
|
|
_is = true;
|
|
_is = true;
|
|
for (i = 0; i < _obj.edges.length; i++) {
|
|
for (i = 0; i < _obj.edges.length; i++) {
|
|
@@ -1446,8 +1469,8 @@ us.broadcast = function (messageinfo, pageid, type) {
|
|
_recievedpageid, //接收用户的页面唯一识别ID
|
|
_recievedpageid, //接收用户的页面唯一识别ID
|
|
_issend, // 是否发送
|
|
_issend, // 是否发送
|
|
_userconnect = us.connect; //用户连接池
|
|
_userconnect = us.connect; //用户连接池
|
|
- console.log("=================a=============");
|
|
|
|
- console.log(messageinfo);
|
|
|
|
|
|
+ // console.log("=================a=============");
|
|
|
|
+ // console.log(messageinfo);
|
|
for (i in messageinfo) {
|
|
for (i in messageinfo) {
|
|
_messageinfo = messageinfo[i]; //记录消息消息
|
|
_messageinfo = messageinfo[i]; //记录消息消息
|
|
_users = us[type][i] ? us[type][i].user : {}; //记录用户集合
|
|
_users = us[type][i] ? us[type][i].user : {}; //记录用户集合
|
|
@@ -2007,9 +2030,6 @@ us.addExcel = function (response, excelinfo) {
|
|
us.getcscl = function (response, calssid, pageid, userid) {
|
|
us.getcscl = function (response, calssid, pageid, userid) {
|
|
//判断文档是否已在内层中存在
|
|
//判断文档是否已在内层中存在
|
|
if (us.cscl[calssid]) {
|
|
if (us.cscl[calssid]) {
|
|
- // console.log("------------------------ssss----------")
|
|
|
|
- // console.log(userid)
|
|
|
|
- // console.log(us.cscl[calssid].user[userid])
|
|
|
|
//如果存在则直接返回内层的文档
|
|
//如果存在则直接返回内层的文档
|
|
if (!us.cscl[calssid].user[userid]) {
|
|
if (!us.cscl[calssid].user[userid]) {
|
|
us.cscl[calssid].user[userid] = [pageid];
|
|
us.cscl[calssid].user[userid] = [pageid];
|
|
@@ -2023,13 +2043,15 @@ us.getcscl = function (response, calssid, pageid, userid) {
|
|
catch (e) {
|
|
catch (e) {
|
|
|
|
|
|
}
|
|
}
|
|
- console.log(us.cscl[calssid])
|
|
|
|
//如果不存在则去数据库查找
|
|
//如果不存在则去数据库查找
|
|
us.mysql.usselect(['172.16.12.5', 'pbl', 'select_room', calssid],
|
|
us.mysql.usselect(['172.16.12.5', 'pbl', 'select_room', calssid],
|
|
function (ret) {
|
|
function (ret) {
|
|
|
|
+ var _user = us.getuserbytype(us.cscl[calssid].user); //获取当前项目下所有的用户信息
|
|
|
|
+ var _data = us.cscl[calssid].content; //保存在内存的知识建构数据
|
|
if (ret) {
|
|
if (ret) {
|
|
- console.log(ret[0][0].data)
|
|
|
|
- ret[0][0].data = us.cscl[calssid].content; //把思维网格的内容转化成数组
|
|
|
|
|
|
+ ret[0][0].user = _user; //这里是项目当前所有用户
|
|
|
|
+ ret[0][0].data = _data; //把思维网格的内容转化成数组
|
|
|
|
+ us.sendUser(us.user[userid], "cscl", pageid, calssid); //加入知识建构项目后通知所有的用户
|
|
response.end(JSON.stringify(ret)); //返回文档内容
|
|
response.end(JSON.stringify(ret)); //返回文档内容
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -2046,22 +2068,23 @@ us.getcscl = function (response, calssid, pageid, userid) {
|
|
if (us.offLineMessage[pageid]) {
|
|
if (us.offLineMessage[pageid]) {
|
|
us.offLineMessage[pageid].cscl.indexOf(calssid) == -1 && us.offLineMessage[pageid].cscl.push(calssid); //添加到用户离线消息的连接wrod记录中
|
|
us.offLineMessage[pageid].cscl.indexOf(calssid) == -1 && us.offLineMessage[pageid].cscl.push(calssid); //添加到用户离线消息的连接wrod记录中
|
|
}
|
|
}
|
|
- // console.log("------------------------ggggg----------");
|
|
|
|
- // console.log(us.cscl[calssid])
|
|
|
|
//如果不存在则去数据库查找
|
|
//如果不存在则去数据库查找
|
|
us.mysql.usselect(['172.16.12.5', 'pbl', 'select_room', calssid],
|
|
us.mysql.usselect(['172.16.12.5', 'pbl', 'select_room', calssid],
|
|
function (ret) {
|
|
function (ret) {
|
|
|
|
+ var _user = us.getuserbytype(us.cscl[calssid].user);
|
|
if (ret) {
|
|
if (ret) {
|
|
- console.log(ret[0][0].data)
|
|
|
|
|
|
+ ret[0][0].user = _user; //这里是项目当前所有用户
|
|
us.cscl[calssid].content = JSON.parse(ret[0][0].data); //把思维网格的内容转化成数组
|
|
us.cscl[calssid].content = JSON.parse(ret[0][0].data); //把思维网格的内容转化成数组
|
|
|
|
+ us.sendUser(us.user[userid], "cscl", pageid, calssid); //加入知识建构项目后通知所有的用户
|
|
response.end(JSON.stringify(ret)); //返回文档内容
|
|
response.end(JSON.stringify(ret)); //返回文档内容
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
us.cscl[calssid].content = {}; //创建一个空数组
|
|
us.cscl[calssid].content = {}; //创建一个空数组
|
|
- response.end(''); //返回文档内容
|
|
|
|
|
|
+ response.end(''); //返回文档内容
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|