MyWebSocket.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. /*eslint-disable*/
  2. /**
  3. * 用于处理websocket实时通讯使用
  4. */
  5. export class MyWebSocket {
  6. // 每次 new 出对象则会调用这个构造函数
  7. constructor() {
  8. // 端口号
  9. this.prot = 3000;
  10. // new出webSocket通讯对象
  11. this.objWebSocket = null;
  12. // webSocket 服务端ip
  13. this.ip = "127.0.0.1";
  14. // 如果是平时开发后,发布到服务器,域名访问,那么就用这个
  15. // this.ip = document.domain;
  16. // 用于触发重连的计时器
  17. this.webSocketRestConnectTime = null;
  18. // 记录当前进入的房间号
  19. this.room = null;
  20. // 记录当前自己的socketId值
  21. this.socketId = null;
  22. /**
  23. * 记录当前的userId,用户登陆后
  24. * 就会固定唯一的 userId, 之后就不会在改变
  25. * 这里的userId 可以是数据库的,没有数据库的
  26. * 可以用第一次登陆的 socketId 作为记录
  27. *
  28. * 用于后续统一通讯告诉大家例如角色,还是别的数据使用
  29. * 不会因为后续每次断开重连,导致 socketId 的变化
  30. * 而要重置已经存在在别的地方的渲染数据使用
  31. */
  32. this.userId = null;
  33. /**
  34. * 记录当前用户自己本身的参数
  35. */
  36. this.myConfig = null;
  37. // 昵称
  38. this.nickname = null;
  39. // 记录最后一次进入的房间号,用于后续触发重连的逻辑
  40. this.roomId = null;
  41. // 当断开连接,重置false,后面触发重连进入房间逻辑
  42. this.joinRoomBool = false;
  43. /**
  44. * 记录当前房间号的用户列表 json 结构
  45. * 每当用户进入,或者退出,该参数优先更新逻辑
  46. */
  47. this.roomListJson = {
  48. // "唯一cid" : "对应json数据",
  49. };
  50. /**
  51. * 记录当前房间号的用户列表
  52. * 对应 cid 的数据记录在 this.roomListJson
  53. */
  54. this.roomList = [];
  55. /**
  56. * 每当房间里发送变化的时候触发回调
  57. *
  58. * type 类型
  59. * roomUserExit 有用户退出
  60. * roomUserJoin 有用户加入
  61. * roomUserDbUpdate 用户数据发送了变化
  62. *
  63. * cidJson 加入或者退出的用户的 json数据
  64. * dbUpdate 当 type 是 roomUserDbUpdate 的时候,才有的参数回调,具体变化的字段数据
  65. *
  66. */
  67. this.roomUpdateCallback = null;
  68. /**
  69. * 每次房间里有群发消息的时候回调
  70. * cidJson 用户的 json数据
  71. * message 消息的内容
  72. */
  73. this.roomChatAllCallback = null;
  74. /**
  75. * 每次有其他用户单独发送消息给你回调
  76. * sendCidJson 发起消息用户的json数据
  77. * getCidJson 接收消息用户的json数据
  78. * message 消息内容
  79. */
  80. this.cidSendCallback = null;
  81. }
  82. // 实现单例模式
  83. static find() {
  84. if (!MyWebSocket.instance) {
  85. MyWebSocket.instance = new MyWebSocket();
  86. }
  87. return MyWebSocket.instance;
  88. }
  89. /**
  90. * webSocket 初始化连接
  91. * */
  92. webSocketInit = function() {
  93. let thisClass = this;
  94. // 只有是空的时候
  95. if (thisClass.objWebSocket == null || thisClass.objWebSocket == 'undefined') {
  96. var webSocketUrl = "ws://" + this.ip + ":" + this.prot;
  97. // 连接 webSocket
  98. thisClass.objWebSocket = new WebSocket(webSocketUrl);
  99. thisClass.webSocketEvent();
  100. }
  101. }
  102. /**
  103. * 断开后,自动触发重新连接通讯逻辑
  104. */
  105. webSocketRestConnect = function() {
  106. let thisClass = this;
  107. if (thisClass.webSocketRestConnectTime != null && thisClass.webSocketRestConnectTime != 'undefined') {
  108. return this;
  109. }
  110. if (thisClass.objWebSocket != null && thisClass.objWebSocket != 'undefined') {
  111. return this;
  112. }
  113. thisClass.joinRoomBool = false;
  114. thisClass.webSocketRestConnectTime = setInterval(function() {
  115. clearInterval(thisClass.webSocketRestConnectTime);
  116. thisClass.webSocketRestConnectTime = null;
  117. thisClass.webSocketInit();
  118. }, 1000);
  119. }
  120. /**
  121. * 连接成功后,调用该方法,设置 objWebSocket 的事件
  122. * */
  123. webSocketEvent = function() {
  124. let thisClass = this;
  125. /**
  126. * 实例对象的 onopen 属性
  127. * 当WebSocket客户端与服务器建立连接并完成握手后会回调此函数。
  128. * 参数 evt 就是 数据的返回
  129. * */
  130. thisClass.objWebSocket.onopen = function(evt) {
  131. console.log([ "连接成功", evt ]);
  132. }
  133. /**
  134. * 实例对象的 onmessage 属性
  135. * 当服务器收到来自客户端的数据帧时会回调此函数。
  136. * 参数 evt 就是 数据的返回
  137. * */
  138. thisClass.objWebSocket.onmessage = function(evt) {
  139. // console.log("onmessage 回调数据");
  140. // console.log(evt);
  141. // console.log(evt.data);
  142. thisClass.commonMessage(evt.data);
  143. }
  144. /**
  145. * 实例对象的 onclose 属性
  146. * 目标客户端id 退出关闭的时候,会触发该事件
  147. * 服务端关闭也会触发该事件
  148. * 参数 evt 就是 数据的返回
  149. * */
  150. thisClass.objWebSocket.onclose = function(evt) {
  151. // console.log("onclose 回调数据");
  152. // console.log(evt);
  153. // 此时将目标对象重置为null,方便后续重新连接
  154. thisClass.objWebSocket = null;
  155. thisClass.webSocketRestConnect();
  156. }
  157. /**
  158. * 报错的时候执行这里,例如连接失败
  159. * */
  160. thisClass.objWebSocket.onerror = function(evt, e) {
  161. // console.log("onerror 回调数据");
  162. // console.log(evt);
  163. // // console.log(evt.data);
  164. // 此时将目标对象重置为null,方便后续重新连接
  165. thisClass.objWebSocket = null;
  166. thisClass.webSocketRestConnect();
  167. }
  168. }
  169. /**
  170. * 统一处理接收到的消息
  171. * serverData 接收服务端的消息
  172. */
  173. commonMessage = function(serverData) {
  174. let thisClass = this;
  175. let json = {};
  176. try {
  177. json = JSON.parse(serverData);
  178. } catch(e) {
  179. return thisClass;
  180. }
  181. // console.log("commonMessage", json);
  182. // 当前是哪个cid发来的消息
  183. let cid = json["cid"];
  184. let data = json["data"];
  185. let dataType = data["type"];
  186. console.log("commonMessage", json, dataType, data);
  187. if (typeof dataType == "string") {
  188. switch (dataType) {
  189. // 心跳包的ping,用于验证用户是否还在正常连接,没有回复pong,则服务端强制退出
  190. case "ping":
  191. thisClass.commonSend("pong", "");
  192. break;
  193. // 第一次连接通讯后,服务端发来的消息
  194. case "login":
  195. thisClass.loginEvent(json);
  196. break;
  197. // 每次用户自己在服务器成功更新了哪些字段数据,则得到对应更新的字段数据
  198. case "myDbUpdate":
  199. thisClass.myDbUpdateEvent(json);
  200. // 如果自己已经加入过房间号,则自动再触发进入房间逻辑,实现重连后进入房间的逻辑
  201. if (
  202. thisClass.roomId != null && thisClass.roomId != undefined
  203. && thisClass.joinRoomBool == false
  204. ) {
  205. thisClass.joinRoom(room);
  206. }
  207. break;
  208. // 当房间里有新用户进入的时候,给当前房间号的所有用户发送消息
  209. case "roomUserJoin":
  210. thisClass.roomUserJoinEvent(json);
  211. break;
  212. // 当房间里有用户退出离开的时候的时候,给当前房间号的所有用户发送消息
  213. case "roomUserExit":
  214. thisClass.roomUserExitEvent(json);
  215. break;
  216. // 当房间里某个用户更新了数据字段的时候
  217. case "roomUserDbUpdate":
  218. thisClass.roomUserDbUpdateEvent(json);
  219. break;
  220. // 当前房间接收到聊天群发的消息
  221. case "roomChatAll":
  222. thisClass.roomChatAllEvent(json);
  223. break;
  224. // 给指定用户私聊
  225. case "cidSend":
  226. thisClass.cidSendEvent(json);
  227. break;
  228. }
  229. }
  230. return thisClass;
  231. }
  232. /**
  233. * 统一发送消息给服务端格式
  234. * 服务端会根据接收不同的类型,执行操作,例如更新用户数据,或者是群发消息,或者是进入房间,或者是给指定的用户单独发送消息等逻辑触发
  235. *
  236. * type 类型,不同的类型,会触发的逻辑不一样
  237. * upUser 更新当前用户的参数,例如昵称,或者坐标点
  238. * joinRoom 用户进入房间或者切换到另外一个房间
  239. * roomSendAll 房间里群发消息,房间里所有用户可以接收到消息,是一个通用的传输数据
  240. * 这里只做实时通讯消息发送,具体最后前端进行逻辑处理
  241. * cidSend 给指定用户私聊
  242. *
  243. * message 给服务端发送的消息,可以是字符串,也可以是json结构
  244. *
  245. * * */
  246. commonSend = function(type, message) {
  247. let thisClass = this;
  248. if (thisClass.objWebSocket == null || thisClass.objWebSocket == undefined) {
  249. return thisClass;
  250. }
  251. // 设置发送消息的时间戳,精确到毫秒
  252. let thisTime = new Date().getTime();
  253. // 消息传输统一格式,格式不正确则无法正常通讯
  254. var submitJson = {
  255. "type" : type,
  256. "message" : message,
  257. // // 客户端发送时间
  258. // "sendTime" : new Date().Format("yyyy-MM-dd hh:mm:ss"),
  259. "thisTime" : thisTime,
  260. };
  261. thisClass.objWebSocket.send(JSON.stringify(submitJson));
  262. return thisClass;
  263. }
  264. /**
  265. * 处理当前用户第一次登陆的时候的逻辑
  266. * json 接收服务端的参数
  267. */
  268. loginEvent = function(json) {
  269. let thisClass = this;
  270. // 当前是哪个cid发来的消息
  271. let cid = json["cid"];
  272. let data = json["data"];
  273. let dataMessage = data["message"];
  274. let dataMessageUserDb = dataMessage["userDb"];
  275. let dataMessageUserDbCid = dataMessageUserDb["cid"];
  276. thisClass.socketId = dataMessageUserDbCid;
  277. if (thisClass.userId == null || thisClass.userId == undefined) {
  278. thisClass.userId = dataMessageUserDbCid;
  279. }
  280. thisClass.myConfig = dataMessageUserDb;
  281. // console.log(
  282. // thisClass.socketId,
  283. // thisClass.myConfig,
  284. // thisClass.userId
  285. // );
  286. thisClass.loginUserUpdate();
  287. return thisClass;
  288. }
  289. /**
  290. * 登陆后,先更新初始的用户数据
  291. */
  292. loginUserUpdate = function() {
  293. let thisClass = this;
  294. thisClass.commonSend(
  295. "upUser",
  296. {
  297. "name" : thisClass.nickname,
  298. "userId" : thisClass.userId,
  299. }
  300. );
  301. return thisClass;
  302. }
  303. /**
  304. * 每次用户自己在服务器成功更新了哪些字段数据,则得到对应更新的字段数据
  305. * json
  306. */
  307. myDbUpdateEvent = function(json) {
  308. let thisClass = this;
  309. // 当前是哪个cid发来的消息
  310. let cid = json["cid"];
  311. let data = json["data"];
  312. let dataMessage = data["message"];
  313. let updateJson = dataMessage["updateJson"];
  314. // 更新的字段数据
  315. for (let key in updateJson) {
  316. let val = updateJson[key];
  317. thisClass.myConfig[key] = val;
  318. }
  319. return thisClass;
  320. }
  321. /**
  322. * 进入房间
  323. * room 房间号
  324. */
  325. joinRoom = function(room) {
  326. let thisClass = this;
  327. if (thisClass.userId == null && thisClass.userId == undefined) {
  328. console.log("连接通讯后请先更新 userId 字段才可进入房间");
  329. return;
  330. }
  331. var submitJson = {
  332. "roomId" : room,
  333. };
  334. thisClass.roomId = room;
  335. thisClass.commonSend(
  336. "joinRoom",
  337. submitJson
  338. );
  339. thisClass.joinRoomBool = true;
  340. return thisClass;
  341. }
  342. /**
  343. * 当房间里有新用户进入的时候,给当前房间号的所有用户发送消息
  344. * json
  345. */
  346. roomUserJoinEvent = function(json) {
  347. let thisClass = this;
  348. // 当前是哪个cid发来的消息
  349. let cid = json["cid"];
  350. let data = json["data"];
  351. let dataMessage = data["message"];
  352. // 此时是该cid进入房间
  353. let sendCid = dataMessage["sendCid"];
  354. // 得到当前房间列表的所有用户信息
  355. let roomList = dataMessage["message"];
  356. // 加入用户的数据
  357. let joinUser = null;
  358. // 循环更新对应房间数据
  359. for (let i = 0; i < roomList.length; i++) {
  360. let objRoomList = roomList[i];
  361. let objRoomListCid = objRoomList["cid"];
  362. // 此时说明是该用户加入的房间
  363. if (objRoomListCid == sendCid) {
  364. // console.log("用户加入房间", objRoomList);
  365. joinUser = objRoomList;
  366. }
  367. thisClass.roomListJson[objRoomListCid] = objRoomList;
  368. }
  369. // 更新房间列表用户数据
  370. thisClass.roomList = roomList;
  371. if (thisClass.roomUpdateCallback != null && thisClass.roomUpdateCallback != undefined) {
  372. thisClass.roomUpdateCallback("roomUserJoin", joinUser, null);
  373. }
  374. return thisClass;
  375. }
  376. /**
  377. * 当房间里有用户退出离开的时候的时候,给当前房间号的所有用户发送消息
  378. * json
  379. */
  380. roomUserExitEvent = function(json) {
  381. let thisClass = this;
  382. // 当前是哪个cid发来的消息
  383. let cid = json["cid"];
  384. let data = json["data"];
  385. let dataMessage = data["message"];
  386. // 此时是该cid退出房间
  387. let sendCid = dataMessage["sendCid"];
  388. // 得到当前房间列表的所有用户信息
  389. let roomList = dataMessage["message"];
  390. // 循环更新对应房间数据
  391. for (let i = 0; i < roomList.length; i++) {
  392. let objRoomList = roomList[i];
  393. let objRoomListCid = objRoomList["cid"];
  394. thisClass.roomListJson[objRoomListCid] = objRoomList;
  395. }
  396. // 更新房间列表用户数据
  397. thisClass.roomList = roomList;
  398. // 退出的用户数据
  399. let userExit = null;
  400. // 找到哪个用户退出
  401. if (thisClass.roomListJson[sendCid] != null && thisClass.roomListJson[sendCid] != undefined) {
  402. // 这里进行一个转换,让它变成独立的对象
  403. userExit = JSON.parse(JSON.stringify(thisClass.roomListJson[sendCid]));
  404. // console.log("用户退出房间", userExit);
  405. // 退出用户的数据清除
  406. thisClass.roomListJson[sendCid] = null;
  407. delete thisClass.roomListJson[sendCid];
  408. }
  409. if (thisClass.roomUpdateCallback != null && thisClass.roomUpdateCallback != undefined) {
  410. thisClass.roomUpdateCallback("roomUserExit", userExit, null);
  411. }
  412. return thisClass;
  413. }
  414. /**
  415. * 当房间里某个用户更新了数据字段的时候
  416. * json
  417. */
  418. roomUserDbUpdateEvent = function(json) {
  419. let thisClass = this;
  420. // 当前是哪个cid发来的消息
  421. let cid = json["cid"];
  422. let data = json["data"];
  423. let dataMessage = data["message"];
  424. // 此时是该cid更新的字段数据
  425. let sendCid = dataMessage["sendCid"];
  426. // 更新了哪些字段数据
  427. let dbUpdate = dataMessage["message"];
  428. console.log(
  429. "当房间里某个用户更新了数据字段的时候 roomUserDbUpdateEvent ",
  430. // json,
  431. sendCid,
  432. dbUpdate,
  433. // this.roomListJson,
  434. // this.roomList
  435. );
  436. let dbUpdateUserId = null;
  437. // 如果更新的字段带有 userId
  438. if (dbUpdate["userId"] != null && dbUpdate["userId"] != null) {
  439. dbUpdateUserId = dbUpdate["userId"];
  440. }
  441. // 找到被更新的用户数据
  442. let updateUser = null;
  443. // 循环房间的所有数据
  444. for (let i = 0; i < this.roomList.length; i++) {
  445. let objRoomList = this.roomList[i];
  446. let objRoomListCid = objRoomList["cid"];
  447. let objRoomListUserId = objRoomList["userId"];
  448. // console.log(
  449. // "roomUserDbUpdateEvent objRoomList ===》", objRoomList
  450. // );
  451. // 是否找到
  452. let objBool = false;
  453. // 优先以 userId 进行寻找对象
  454. if (
  455. dbUpdateUserId != null && dbUpdateUserId != undefined
  456. && dbUpdateUserId == objRoomListUserId
  457. ) {
  458. objBool = true;
  459. } else if (objRoomListCid == sendCid) {
  460. objBool = true;
  461. }
  462. if (objBool == true) {
  463. // console.log(
  464. // "roomUserDbUpdateEvent objBool ===》", objRoomList
  465. // );
  466. // 开始更新对应的字段数据
  467. for (var key in dbUpdate) {
  468. objRoomList[key] = dbUpdate[key];
  469. }
  470. // 更新指定目标cid的用户相关数据
  471. if (this.roomListJson[objRoomListCid] != null && this.roomListJson[objRoomListCid] != undefined) {
  472. // 开始更新对应的字段数据
  473. for (var key in dbUpdate) {
  474. this.roomListJson[objRoomListCid][key] = dbUpdate[key];
  475. }
  476. }
  477. updateUser = objRoomList;
  478. }
  479. }
  480. // console.log(
  481. // "roomUserDbUpdateEvent ===》", this.roomListJson, this.roomList
  482. // );
  483. if (thisClass.roomUpdateCallback != null && thisClass.roomUpdateCallback != undefined) {
  484. thisClass.roomUpdateCallback("roomUserDbUpdate", updateUser, dbUpdate);
  485. }
  486. return thisClass;
  487. }
  488. /**
  489. * 给当前自己所在房间号发送消息
  490. * type 自定义类型,该类型你定义的是什么,在返回的房间里,就会返回什么类型
  491. * 如果你是通知所有房间群发聊天填写 chatAll
  492. * 否则你填写别的类型,然后再根据这个类型,单独处理逻辑
  493. *
  494. * message 给服务端发送的消息,可以是字符串,也可以是json结构
  495. * 该参数后续根据 type 参数,来配合开发新的逻辑
  496. * 例如我填写 type = chatAll , 该参数就传字符串聊天的内容
  497. * 如果传别的类型,可以传json结构,然后通过该接收的消息,进行特殊处理别的逻辑
  498. */
  499. roomSend = function(type, message) {
  500. let thisClass = this;
  501. if (this.myConfig == null || this.myConfig == undefined) {
  502. return thisClass;
  503. }
  504. if (this.myConfig["roomId"] == null || this.myConfig["roomId"] == undefined) {
  505. return thisClass;
  506. }
  507. let roomId = this.myConfig["roomId"];
  508. // console.log("roomSend myConfig", this.myConfig, type, message, roomId);
  509. let submit = {
  510. "roomId" : roomId,
  511. "type" : type,
  512. "content" : message,
  513. };
  514. thisClass.commonSend("roomSendAll", submit);
  515. return thisClass;
  516. }
  517. /**
  518. * 给指定cid私聊发送消息
  519. * type 自定义类型,该类型你定义的是什么,就会返回什么类型
  520. * 如果你是单独处理聊天则填写 chat
  521. * 否则你填写别的类型,然后再根据这个类型,单独处理逻辑
  522. *
  523. * cid 跟对方私聊的cid值
  524. *
  525. * message 给服务端发送的消息,可以是字符串,也可以是json结构
  526. * 该参数后续根据 type 参数,来配合开发新的逻辑
  527. * 例如我填写 type = chat , 该参数就传字符串聊天的内容
  528. * 如果传别的类型,可以传json结构,然后通过该接收的消息,进行特殊处理别的逻辑
  529. */
  530. cidSend = function(type, cid, message) {
  531. let thisClass = this;
  532. let submit = {
  533. "cid" : cid,
  534. "type" : type,
  535. "content" : message,
  536. };
  537. thisClass.commonSend("cidSend", submit);
  538. return thisClass;
  539. }
  540. /**
  541. * 当前房间接收到聊天群发的消息
  542. * json
  543. */
  544. roomChatAllEvent = function(json) {
  545. let thisClass = this;
  546. // console.log("roomChatAllEvent", json);
  547. let cid = json["cid"];
  548. let data = json["data"];
  549. let dataMessage = data["message"];
  550. let dataMessageSendCid = dataMessage["sendCid"];
  551. let dataMessageMessage = dataMessage["message"];
  552. // console.log("roomChatAllEvent", dataMessageSendCid, dataMessageMessage);
  553. if (thisClass.roomListJson[dataMessageSendCid] == null || thisClass.roomListJson[dataMessageSendCid] == undefined) {
  554. return thisClass;
  555. }
  556. let cidJson = thisClass.roomListJson[dataMessageSendCid];
  557. if (typeof thisClass.roomChatAllCallback == 'function') {
  558. thisClass.roomChatAllCallback(cidJson, dataMessageMessage);
  559. }
  560. return thisClass;
  561. }
  562. /**
  563. * 给指定用户发送消息
  564. * json
  565. */
  566. cidSendEvent = function(json) {
  567. let thisClass = this;
  568. // console.log( "cidSendEvent", json );
  569. let cid = json["cid"];
  570. let data = json["data"];
  571. let dataMessage = data["message"];
  572. // 哪个cid发起的
  573. let dataMessageSendCid = dataMessage["sendCid"];
  574. // 接收消息的cid
  575. let dataMessageGetCid = dataMessage["getCid"];
  576. let dataMessageSubmitJson = dataMessage["submitJson"];
  577. let dataMessageSubmitJsonMessage = dataMessageSubmitJson["message"];
  578. if (thisClass.roomListJson[dataMessageSendCid] == null || thisClass.roomListJson[dataMessageSendCid] == undefined) {
  579. return thisClass;
  580. }
  581. if (thisClass.roomListJson[dataMessageGetCid] == null || thisClass.roomListJson[dataMessageGetCid] == undefined) {
  582. return thisClass;
  583. }
  584. let sendCidJson = thisClass.roomListJson[dataMessageSendCid];
  585. let getCidJson = thisClass.roomListJson[dataMessageGetCid];
  586. // console.log(
  587. // "cidSendEvent",
  588. // dataMessageSendCid,
  589. // dataMessageSubmitJson,
  590. // dataMessageSubmitJsonMessage,
  591. // dataMessageGetCid,
  592. // sendCidJson,
  593. // getCidJson
  594. // );
  595. if (typeof thisClass.cidSendCallback == 'function') {
  596. thisClass.cidSendCallback(sendCidJson, getCidJson, dataMessageSubmitJsonMessage);
  597. }
  598. return thisClass;
  599. }
  600. }