|
@@ -269,7 +269,7 @@ us.server = us.http.createServer(function (requset, response) {
|
|
|
case 'addUser':
|
|
|
us.addUser(response, _param[0], _param[1], _param[2], _param[3], _param[4]);
|
|
|
break;
|
|
|
- //其余执行
|
|
|
+ //其余执行
|
|
|
default:
|
|
|
response.end(0);
|
|
|
}
|
|
@@ -621,7 +621,7 @@ us.send = function (response, messageinfo) {
|
|
|
// console.log(_messagelist)
|
|
|
// console.log(_messagearr)
|
|
|
//调用群发函数
|
|
|
- _messagearr[0] && us.broadcast(_messagelist, _messagearr[0].messageInfo.pageId, 'cscl');
|
|
|
+ _messagearr[0] && us.broadcast(_messagelist, _messagearr[0].pageId, 'cscl');
|
|
|
break;
|
|
|
//同步课堂
|
|
|
case "us.realTimeClass":
|
|
@@ -742,42 +742,65 @@ us.updatemindNetwork = function (messageInfo) {
|
|
|
us.updatecscl = function (messageInfo, classId) {
|
|
|
messageInfo = messageInfo;
|
|
|
console.log("------------s------------");
|
|
|
- console.log(us.cscl[classId])
|
|
|
+ //console.log(us.cscl[classId]);
|
|
|
+ console.log(messageInfo.type);
|
|
|
+
|
|
|
if (us.cscl[classId]) {
|
|
|
var i, j, _is;
|
|
|
var _obj = us.cscl[classId].content;
|
|
|
_obj.backgroundUrl = messageInfo.backgroundUrl;
|
|
|
_obj.edges = _obj.edges || [];
|
|
|
_obj.nodes = _obj.nodes || [];
|
|
|
+
|
|
|
+ switch (messageInfo.type) { // 判断消息种类
|
|
|
+ case 'update':
|
|
|
+ us.updateEditorLine(messageInfo, $); //修改
|
|
|
+ break;
|
|
|
+
|
|
|
+
|
|
|
+ case 'delete':
|
|
|
+ us.deleteEditorLine(messageInfo, $); //删除
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
for (j = 0; j < messageInfo.edges.length; j++) {
|
|
|
_is = true;
|
|
|
for (i = 0; i < _obj.edges.length; i++) {
|
|
|
if (_obj.edges[i].id == messageInfo.edges[j].id) {
|
|
|
- _obj.edges[i] = messageInfo.edges[j];
|
|
|
+ if (messageInfo.type == "update") {
|
|
|
+ _obj.edges[i] = messageInfo.edges[j];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ _obj.edges.splice(i, 1);
|
|
|
+ }
|
|
|
_is = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (_is) {
|
|
|
+ if (_is && messageInfo.type == "update") {
|
|
|
_obj.edges.push(messageInfo.edges[j])
|
|
|
}
|
|
|
}
|
|
|
- console.log("------------a------------");
|
|
|
- console.log(messageInfo.nodes)
|
|
|
- console.log(_obj.nodes)
|
|
|
+
|
|
|
for (j = 0; j < messageInfo.nodes.length; j++) {
|
|
|
_is = true;
|
|
|
for (i = 0; i < _obj.nodes.length; i++) {
|
|
|
if (_obj.nodes[i].id == messageInfo.nodes[j].id) {
|
|
|
- _obj.nodes[i] = messageInfo.nodes[j];
|
|
|
+ if (messageInfo.type == "update") {
|
|
|
+ _obj.nodes[i] = messageInfo.nodes[j];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ _obj.nodes.splice(i, 1);
|
|
|
+ }
|
|
|
_is = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (_is) {
|
|
|
+ if (_is && messageInfo.type == "update") {
|
|
|
_obj.nodes.push(messageInfo.nodes[j])
|
|
|
}
|
|
|
}
|
|
|
+ console.log(_obj);
|
|
|
//如果不存在则去数据库查找
|
|
|
us.mysql.usselect(['172.16.12.5', 'pbl', 'updateRoomData', JSON.stringify(_obj), classId],
|
|
|
function (ret) {
|
|
@@ -1435,14 +1458,6 @@ us.broadcast = function (messageinfo, pageid, type) {
|
|
|
for (i in messageinfo) {
|
|
|
_messageinfo = messageinfo[i]; //记录消息消息
|
|
|
_users = us[type][i] ? us[type][i].user : {}; //记录用户集合
|
|
|
- // console.log("=================e=============");
|
|
|
- // console.log(type);
|
|
|
- // console.log("=================a=============");
|
|
|
- // console.log(_users);
|
|
|
- // console.log("=================c=============");
|
|
|
- // console.log(us.connect);
|
|
|
- // console.log("=================g=============");
|
|
|
- // console.log(_messageinfo);
|
|
|
for (j in _users) { //循环处理每个用户处理 给每个用户集合下的用户发送消息
|
|
|
_pageids = _users[j]; //记录当前用户在每个端登录的页面唯一识别ID
|
|
|
console.log(_pageids);
|