Commit 3e3da3c4 by Kim Peace

Merge branch 'develop' into feature/add_user_in_collaboration

parents 3dd3f9c7 bc5339ae
...@@ -169,7 +169,7 @@ Common.startCollaboration = function (collaborationType) { ...@@ -169,7 +169,7 @@ Common.startCollaboration = function (collaborationType) {
return; return;
} }
const sendData = DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL; const sendData = DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL;
CHAT_SOCKET.emitCreateMessage(sendData, 0); CHAT_SOCKET.emitCreateMessage(SOCKET_KEY.CREATE_MESSAGE, sendData);
NativeBridgeDelegate.finishAllCollaboration(); NativeBridgeDelegate.finishAllCollaboration();
} }
NativeBridgeDelegate.startCollaboration(collaborationType); NativeBridgeDelegate.startCollaboration(collaborationType);
......
...@@ -131,6 +131,7 @@ const SOCKET_KEY = { ...@@ -131,6 +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_NOTIFICATION: "newNotification", NEW_NOTIFICATION: "newNotification",
REFRESH_GROUPLIST: "refreshGroupList", REFRESH_GROUPLIST: "refreshGroupList",
REFRESH_USERLIST_INGROUP: "refreshUserListInGroup", REFRESH_USERLIST_INGROUP: "refreshUserListInGroup",
...@@ -138,6 +139,10 @@ const SOCKET_KEY = { ...@@ -138,6 +139,10 @@ const SOCKET_KEY = {
RETRY_JOIN_PROCESS: "retryJoinProcess", RETRY_JOIN_PROCESS: "retryJoinProcess",
JOIN: "join", JOIN: "join",
CREATE_MESSAGE: "createMessage", CREATE_MESSAGE: "createMessage",
CREATE_TEXT: "createText",
CREATE_IMAGE: "createImage",
CREATE_VIDEO: "createVideo",
COMMUNICATION: "communication",
GET_GROUP_LIST: "getGroupList", GET_GROUP_LIST: "getGroupList",
LEAVE_ROOM: "leaveRoom", LEAVE_ROOM: "leaveRoom",
}; };
......
...@@ -2,49 +2,54 @@ CHAT_SOCKET.bindOnNewMessage = function () { ...@@ -2,49 +2,54 @@ 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) {
const systemMessageTemplate = getTemplate(TemplateURL.SYSTEM_MESSAGE); CHAT_SOCKET.handleMessage(message, roomName, SOCKET_KEY.NEW_MESSAGE)
});
const unwrappedMessageInfo = CHAT_SOCKET.decodeMessage(message.text);
if ( socket.on(SOCKET_KEY.NEW_COMMUNICATION, function (message, roomID, roomName) {
unwrappedMessageInfo == CHAT_SOCKET.handleMessage(message, roomName, SOCKET_KEY.NEW_COMMUNICATION)
DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL
) {
CHAT_SOCKET.cleanUpCollaborationMessage();
return;
}
if (unwrappedMessageInfo.includes(messageSeperator)) {
const messageInfo = unwrappedMessageInfo.split(messageSeperator);
const messageText = messageInfo[0];
const messageType = messageInfo[1];
if (
messageType == MessageType.COMMUNICATIONSTART ||
messageType == MessageType.COMMUNICATIONEND
) {
CHAT_SOCKET.addCollaborationMessage(
messageInfo,
message.userId,
roomName,
message.insertDate,
message.createdAt
);
} else {
CHAT_SOCKET.addTextMessage(messageText, message, socket.id);
}
}
if (typeof ChatRoom !== "undefined") {
// 画像、動画の描画を待ってからスクロール
setTimeout(function () {
ChatRoom.scrollToBottom();
}, 300);
} else {
Common.dismissLoadingIndicator();
}
}); });
}; };
CHAT_SOCKET.handleMessage = function (message, roomName, socketKey) {
const systemMessageTemplate = getTemplate(TemplateURL.SYSTEM_MESSAGE);
const unwrappedMessageInfo = CHAT_SOCKET.decodeMessage(message.text);
if (
unwrappedMessageInfo ==
DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL
) {
CHAT_SOCKET.cleanUpCollaborationMessage();
return;
}
const messageInfo = unwrappedMessageInfo;
const messageType = socketKey;
const messageText = unwrappedMessageInfo;
if (
messageType == SOCKET_KEY.NEW_COMMUNICATION
) {
CHAT_SOCKET.addCollaborationMessage(
messageInfo,
message.userId,
roomName,
message.insertDate,
message.createdAt
);
} else {
CHAT_SOCKET.addTextMessage(messageText, message, socket.id);
}
if (typeof ChatRoom !== "undefined") {
// 画像、動画の描画を待ってからスクロール
setTimeout(function () {
ChatRoom.scrollToBottom();
}, 300);
} else {
Common.dismissLoadingIndicator();
}
}
CHAT_SOCKET.decodeMessage = function (text) { CHAT_SOCKET.decodeMessage = function (text) {
try { try {
return decodeURIComponent(text); return decodeURIComponent(text);
......
...@@ -188,14 +188,60 @@ var bindOnRefreshUserListInGroup = function () { ...@@ -188,14 +188,60 @@ var bindOnRefreshUserListInGroup = function () {
); );
}; };
CHAT_SOCKET.emitCreateMessage = function (sendData, offset) { var nextFibonacci = function (num) {
socket.emit(SOCKET_KEY.CREATE_MESSAGE, { text: sendData }, offset); let nextNum = num * (1 + Math.sqrt(5)) / 2.0;
return Math.round(nextNum);
}
CHAT_SOCKET.emitCreateMessage = function (socketKey, sendData) {
if (socket.connected == false) {
CHAT_SOCKET.reconnectCreateMessage(socketKey, sendData);
} else {
socket.emit(socketKey, { text: sendData });
}
};
CHAT_SOCKET.emitCreateText = function (sendData) {
CHAT_SOCKET.emitCreateMessage(SOCKET_KEY.CREATE_TEXT, sendData);
};
CHAT_SOCKET.emitCreateImage = function (sendData) {
CHAT_SOCKET.emitCreateMessage(SOCKET_KEY.CREATE_IMAGE, sendData);
};
CHAT_SOCKET.emitCreateVideo = function (sendData) {
CHAT_SOCKET.emitCreateMessage(SOCKET_KEY.CREATE_VIDEO, sendData);
}; };
CHAT_SOCKET.emitCreateCommunicationStart = function (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;
CHAT_SOCKET.emitCreateMessage(sendData, 0); CHAT_SOCKET.emitCreateMessage(SOCKET_KEY.CREATE_MESSAGE, sendData);
} }
}; };
......
...@@ -169,8 +169,8 @@ ChatMediaHandler.videoEncodeEnd = function (encodedUri) { ...@@ -169,8 +169,8 @@ ChatMediaHandler.videoEncodeEnd = function (encodedUri) {
} catch (e) { } catch (e) {
encodedText = text; encodedText = text;
} }
const sendData = encodedText + messageSeperator + MessageType.VIDEO; const sendData = encodedText;
CHAT_SOCKET.emitCreateMessage(sendData, 1); CHAT_SOCKET.emitCreateVideo(sendData);
$(".overlay").removeClass("active undismissable"); $(".overlay").removeClass("active undismissable");
$(".loader").removeClass("active"); $(".loader").removeClass("active");
...@@ -320,8 +320,8 @@ ChatMediaHandler.uploadImage = function (formData) { ...@@ -320,8 +320,8 @@ ChatMediaHandler.uploadImage = function (formData) {
} catch (e) { } catch (e) {
encodedText = text; encodedText = text;
} }
const sendData = encodedText + messageSeperator + MessageType.IMAGE; const sendData = encodedText;
CHAT_SOCKET.emitCreateMessage(sendData, 1); CHAT_SOCKET.emitCreateImage(sendData);
} else { } else {
// 動画の処理 // 動画の処理
if (res.thumbnailPath && res.thumbnailPath.length > 0) { if (res.thumbnailPath && res.thumbnailPath.length > 0) {
...@@ -371,8 +371,8 @@ ChatMediaHandler.uploadImage = function (formData) { ...@@ -371,8 +371,8 @@ ChatMediaHandler.uploadImage = function (formData) {
} catch (e) { } catch (e) {
encodedText = text; encodedText = text;
} }
const sendData = encodedText + messageSeperator + MessageType.VIDEO; const sendData = encodedText;
CHAT_SOCKET.emitCreateMessage(sendData, 1); CHAT_SOCKET.emitCreateVideo(sendData);
} }
$(".overlay").removeClass("active undismissable"); $(".overlay").removeClass("active undismissable");
......
...@@ -65,8 +65,8 @@ ChatRoom.sendMessage = function (e) { ...@@ -65,8 +65,8 @@ ChatRoom.sendMessage = function (e) {
messageTextBox.val(""); messageTextBox.val("");
if (message.length > 0) { if (message.length > 0) {
const sendData = message + messageSeperator + MessageType.TEXT; const sendData = message;
CHAT_SOCKET.emitCreateMessage(sendData, 0); CHAT_SOCKET.emitCreateText(sendData);
} }
$(".message_input_form").focus(); $(".message_input_form").focus();
}; };
......
...@@ -210,18 +210,15 @@ CollaborationFeature.didReceiveLoginResponseMessage = async function () { ...@@ -210,18 +210,15 @@ CollaborationFeature.didReceiveLoginResponseMessage = async function () {
}; };
CollaborationFeature.didReceiveCreateRoomResponseMessage = function () { CollaborationFeature.didReceiveCreateRoomResponseMessage = function () {
let coviewInviteMessage = let coviewInviteMessage = "";
"" + let collaborationType = CHAT_UTIL.getCollaborationTypeNumber(globalUserInfo.collaborationType);
messageSeperator + let meetingID = null
MessageType.COMMUNICATIONSTART +
messageSeperator +
CHAT_UTIL.getCollaborationTypeNumber(globalUserInfo.collaborationType);
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.DOCUMENT) { if (globalUserInfo.collaborationType == COLLABORATION_TYPE.DOCUMENT) {
coviewInviteMessage += messageSeperator + globalUserInfo.meetingID; meetingID = globalUserInfo.meetingID;
} }
CHAT_SOCKET.emitCreateMessage(coviewInviteMessage, 0); CHAT_SOCKET.emitCreateCommunicationStart(coviewInviteMessage, collaborationType, meetingID);
}; };
CollaborationFeature.didReceivedJoinRoomInfoResponseMessage = function () { CollaborationFeature.didReceivedJoinRoomInfoResponseMessage = function () {
......
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