Commit bc5339ae by Kim Peace

Merge branch 'squash/socket_kim-ec' into 'develop'

Squash/socket kim ec

See merge request !217
parents 9868ee7e cc0c6e1f
...@@ -131,7 +131,7 @@ const SOCKET_KEY = { ...@@ -131,7 +131,7 @@ const SOCKET_KEY = {
DISCONNECT: "disconnect", DISCONNECT: "disconnect",
CONNECT_ERROR: "connect_error", CONNECT_ERROR: "connect_error",
NEW_MESSAGE: "newMessage", NEW_MESSAGE: "newMessage",
NEW_COMMUNICATION: "newCommunication", NEW_COMMUNICATION: "newCommunication",
NEW_NOTIFICATION: "newNotification", NEW_NOTIFICATION: "newNotification",
REFRESH_GROUPLIST: "refreshGroupList", REFRESH_GROUPLIST: "refreshGroupList",
REFRESH_USERLIST_INGROUP: "refreshUserListInGroup", REFRESH_USERLIST_INGROUP: "refreshUserListInGroup",
...@@ -142,7 +142,7 @@ const SOCKET_KEY = { ...@@ -142,7 +142,7 @@ const SOCKET_KEY = {
CREATE_TEXT: "createText", CREATE_TEXT: "createText",
CREATE_IMAGE: "createImage", CREATE_IMAGE: "createImage",
CREATE_VIDEO: "createVideo", CREATE_VIDEO: "createVideo",
CREATE_COMMUNICATIONSTART: "createCommunicationStart", COMMUNICATION: "communication",
GET_GROUP_LIST: "getGroupList", GET_GROUP_LIST: "getGroupList",
LEAVE_ROOM: "leaveRoom", LEAVE_ROOM: "leaveRoom",
}; };
......
...@@ -2,11 +2,11 @@ CHAT_SOCKET.bindOnNewMessage = function () { ...@@ -2,11 +2,11 @@ CHAT_SOCKET.bindOnNewMessage = function () {
// New Message // New Message
// #36170 // #36170
socket.on(SOCKET_KEY.NEW_MESSAGE, function (message, roomID, roomName) { socket.on(SOCKET_KEY.NEW_MESSAGE, function (message, roomID, roomName) {
handleMessage(message, roomName, SOCKET_KEY.NEW_MESSAGE) CHAT_SOCKET.handleMessage(message, roomName, SOCKET_KEY.NEW_MESSAGE)
}); });
socket.on(SOCKET_KEY.NEW_COMMUNICATION, function (message, roomID, roomName) { socket.on(SOCKET_KEY.NEW_COMMUNICATION, function (message, roomID, roomName) {
handleMessage(message, roomName, SOCKET_KEY.NEW_COMMUNICATION) CHAT_SOCKET.handleMessage(message, roomName, SOCKET_KEY.NEW_COMMUNICATION)
}); });
}; };
......
...@@ -188,8 +188,17 @@ var bindOnRefreshUserListInGroup = function () { ...@@ -188,8 +188,17 @@ var bindOnRefreshUserListInGroup = function () {
); );
}; };
var nextFibonacci = function (num) {
let nextNum = num * (1 + Math.sqrt(5)) / 2.0;
return Math.round(nextNum);
}
CHAT_SOCKET.emitCreateMessage = function (socketKey, sendData) { CHAT_SOCKET.emitCreateMessage = function (socketKey, sendData) {
socket.emit(socketKey, { text: sendData }); if (socket.connected == false) {
CHAT_SOCKET.reconnectCreateMessage(socketKey, sendData);
} else {
socket.emit(socketKey, { text: sendData });
}
}; };
CHAT_SOCKET.emitCreateText = function (sendData) { CHAT_SOCKET.emitCreateText = function (sendData) {
...@@ -205,9 +214,30 @@ CHAT_SOCKET.emitCreateVideo = function (sendData) { ...@@ -205,9 +214,30 @@ CHAT_SOCKET.emitCreateVideo = function (sendData) {
}; };
CHAT_SOCKET.emitCreateCommunicationStart = function (sendData, collaborationType, meetingID) { CHAT_SOCKET.emitCreateCommunicationStart = function (sendData, collaborationType, meetingID) {
socket.emit(SOCKET_KEY.CREATE_COMMUNICATIONSTART, { text: sendData }, collaborationType, meetingID); if (socket.connected == false) {
CHAT_SOCKET.reconnectCreateMessage(SOCKET_KEY.COMMUNICATION, sendData, collaborationType, meetingID);
} else {
socket.emit(SOCKET_KEY.COMMUNICATION, { text: sendData }, collaborationType, meetingID);
}
}; };
CHAT_SOCKET.reconnectCreateMessage = function (socketKey, sendData, timeout = 100, collaborationType = null, meetingID = null) {
if (socket.connected == false) {
console.log("socket disconnected, reconnect... " + timeout)
CHAT_SOCKET.initialJoin();
setTimeout(function() {
CHAT_SOCKET.reconnectCreateMessage(socketKey, sendData, nextFibonacci(timeout));
}, timeout);
} else {
console.log("reconnected")
if (collaborationType == null) {
socket.emit(socketKey, { text: sendData });
} else {
socket.emit(socketKey, { text: sendData }, collaborationType, meetingID);
}
}
}
CHAT_SOCKET.emitCollaborationFinishMessage = function () { CHAT_SOCKET.emitCollaborationFinishMessage = function () {
if (socket != null && socket.connected) { if (socket != null && socket.connected) {
const sendData = DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL; const sendData = DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment