Commit 9868ee7e by Kim Peace

Merge branch 'squash/socket' into 'develop'

Squash/socket

See merge request !206
parents 91ad8f0f 000922d1
......@@ -169,7 +169,7 @@ Common.startCollaboration = function (collaborationType) {
return;
}
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.startCollaboration(collaborationType);
......
......@@ -131,6 +131,7 @@ const SOCKET_KEY = {
DISCONNECT: "disconnect",
CONNECT_ERROR: "connect_error",
NEW_MESSAGE: "newMessage",
NEW_COMMUNICATION: "newCommunication",
NEW_NOTIFICATION: "newNotification",
REFRESH_GROUPLIST: "refreshGroupList",
REFRESH_USERLIST_INGROUP: "refreshUserListInGroup",
......@@ -138,6 +139,10 @@ const SOCKET_KEY = {
RETRY_JOIN_PROCESS: "retryJoinProcess",
JOIN: "join",
CREATE_MESSAGE: "createMessage",
CREATE_TEXT: "createText",
CREATE_IMAGE: "createImage",
CREATE_VIDEO: "createVideo",
CREATE_COMMUNICATIONSTART: "createCommunicationStart",
GET_GROUP_LIST: "getGroupList",
LEAVE_ROOM: "leaveRoom",
};
......
......@@ -2,6 +2,15 @@ CHAT_SOCKET.bindOnNewMessage = function () {
// New Message
// #36170
socket.on(SOCKET_KEY.NEW_MESSAGE, function (message, roomID, roomName) {
handleMessage(message, roomName, SOCKET_KEY.NEW_MESSAGE)
});
socket.on(SOCKET_KEY.NEW_COMMUNICATION, function (message, roomID, roomName) {
handleMessage(message, roomName, SOCKET_KEY.NEW_COMMUNICATION)
});
};
CHAT_SOCKET.handleMessage = function (message, roomName, socketKey) {
const systemMessageTemplate = getTemplate(TemplateURL.SYSTEM_MESSAGE);
const unwrappedMessageInfo = CHAT_SOCKET.decodeMessage(message.text);
......@@ -13,14 +22,12 @@ CHAT_SOCKET.bindOnNewMessage = function () {
return;
}
if (unwrappedMessageInfo.includes(messageSeperator)) {
const messageInfo = unwrappedMessageInfo.split(messageSeperator);
const messageText = messageInfo[0];
const messageType = messageInfo[1];
const messageInfo = unwrappedMessageInfo;
const messageType = socketKey;
const messageText = unwrappedMessageInfo;
if (
messageType == MessageType.COMMUNICATIONSTART ||
messageType == MessageType.COMMUNICATIONEND
messageType == SOCKET_KEY.NEW_COMMUNICATION
) {
CHAT_SOCKET.addCollaborationMessage(
messageInfo,
......@@ -32,7 +39,6 @@ CHAT_SOCKET.bindOnNewMessage = function () {
} else {
CHAT_SOCKET.addTextMessage(messageText, message, socket.id);
}
}
if (typeof ChatRoom !== "undefined") {
// 画像、動画の描画を待ってからスクロール
......@@ -42,8 +48,7 @@ CHAT_SOCKET.bindOnNewMessage = function () {
} else {
Common.dismissLoadingIndicator();
}
});
};
}
CHAT_SOCKET.decodeMessage = function (text) {
try {
......
......@@ -188,14 +188,30 @@ var bindOnRefreshUserListInGroup = function () {
);
};
CHAT_SOCKET.emitCreateMessage = function (sendData, offset) {
socket.emit(SOCKET_KEY.CREATE_MESSAGE, { text: sendData }, offset);
CHAT_SOCKET.emitCreateMessage = function (socketKey, sendData) {
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) {
socket.emit(SOCKET_KEY.CREATE_COMMUNICATIONSTART, { text: sendData }, collaborationType, meetingID);
};
CHAT_SOCKET.emitCollaborationFinishMessage = function () {
if (socket != null && socket.connected) {
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) {
} catch (e) {
encodedText = text;
}
const sendData = encodedText + messageSeperator + MessageType.VIDEO;
CHAT_SOCKET.emitCreateMessage(sendData, 1);
const sendData = encodedText;
CHAT_SOCKET.emitCreateVideo(sendData);
$(".overlay").removeClass("active undismissable");
$(".loader").removeClass("active");
......@@ -320,8 +320,8 @@ ChatMediaHandler.uploadImage = function (formData) {
} catch (e) {
encodedText = text;
}
const sendData = encodedText + messageSeperator + MessageType.IMAGE;
CHAT_SOCKET.emitCreateMessage(sendData, 1);
const sendData = encodedText;
CHAT_SOCKET.emitCreateImage(sendData);
} else {
// 動画の処理
if (res.thumbnailPath && res.thumbnailPath.length > 0) {
......@@ -371,8 +371,8 @@ ChatMediaHandler.uploadImage = function (formData) {
} catch (e) {
encodedText = text;
}
const sendData = encodedText + messageSeperator + MessageType.VIDEO;
CHAT_SOCKET.emitCreateMessage(sendData, 1);
const sendData = encodedText;
CHAT_SOCKET.emitCreateVideo(sendData);
}
$(".overlay").removeClass("active undismissable");
......
......@@ -65,8 +65,8 @@ ChatRoom.sendMessage = function (e) {
messageTextBox.val("");
if (message.length > 0) {
const sendData = message + messageSeperator + MessageType.TEXT;
CHAT_SOCKET.emitCreateMessage(sendData, 0);
const sendData = message;
CHAT_SOCKET.emitCreateText(sendData);
}
$(".message_input_form").focus();
};
......
......@@ -210,18 +210,15 @@ CollaborationFeature.didReceiveLoginResponseMessage = async function () {
};
CollaborationFeature.didReceiveCreateRoomResponseMessage = function () {
let coviewInviteMessage =
"" +
messageSeperator +
MessageType.COMMUNICATIONSTART +
messageSeperator +
CHAT_UTIL.getCollaborationTypeNumber(globalUserInfo.collaborationType);
let coviewInviteMessage = "";
let collaborationType = CHAT_UTIL.getCollaborationTypeNumber(globalUserInfo.collaborationType);
let meetingID = null
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 () {
......
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