Commit 000922d1 by Kim Eunchul

#43695 ウェブソケットの送信方式変更

parent a5080415
var bindOnNewMessage = function () {
CHAT_SOCKET.bindOnNewMessage = function () {
// New Message
// #36170
socket.on(SOCKET_KEY.NEW_MESSAGE, function (message, roomID, roomName) {
......@@ -10,15 +10,15 @@ var bindOnNewMessage = function () {
});
};
var handleMessage = function (message, roomName, socketKey) {
CHAT_SOCKET.handleMessage = function (message, roomName, socketKey) {
const systemMessageTemplate = getTemplate(TemplateURL.SYSTEM_MESSAGE);
const unwrappedMessageInfo = decodeMessage(message.text);
const unwrappedMessageInfo = CHAT_SOCKET.decodeMessage(message.text);
if (
unwrappedMessageInfo ==
DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL
) {
cleanUpCollaborationMessage();
CHAT_SOCKET.cleanUpCollaborationMessage();
return;
}
......@@ -29,7 +29,7 @@ var handleMessage = function (message, roomName, socketKey) {
if (
messageType == SOCKET_KEY.NEW_COMMUNICATION
) {
addCollaborationMessage(
CHAT_SOCKET.addCollaborationMessage(
messageInfo,
message.userId,
roomName,
......@@ -37,7 +37,7 @@ var handleMessage = function (message, roomName, socketKey) {
message.createdAt
);
} else {
addTextMessage(messageText, message, socket.id);
CHAT_SOCKET.addTextMessage(messageText, message, socket.id);
}
if (typeof ChatRoom !== "undefined") {
......@@ -45,10 +45,12 @@ var handleMessage = function (message, roomName, socketKey) {
setTimeout(function () {
ChatRoom.scrollToBottom();
}, 300);
} else {
Common.dismissLoadingIndicator();
}
}
var decodeMessage = function (text) {
CHAT_SOCKET.decodeMessage = function (text) {
try {
return decodeURIComponent(text);
} catch (e) {
......@@ -56,7 +58,7 @@ var decodeMessage = function (text) {
}
};
var addCollaborationMessage = function (
CHAT_SOCKET.addCollaborationMessage = function (
messageInfo,
userID,
roomName,
......@@ -64,7 +66,7 @@ var addCollaborationMessage = function (
createdAt
) {
const collaborationType = CHAT_UTIL.getCollaborationType(messageInfo[2]);
const meetingID = getMeetingID(collaborationType, messageInfo);
const meetingID = CHAT_SOCKET.getMeetingID(collaborationType, messageInfo);
const userInCollaboration = JSON.parse(
NativeBridgeDataSource.getUserInfoList(userID)
);
......@@ -77,7 +79,7 @@ var addCollaborationMessage = function (
TemplateURL.OPEN_COLLABORATION_MESSAGE
);
const html = renderCollaborationMessage(
const html = CHAT_SOCKET.renderCollaborationMessage(
openCollaborationMessageTemplate,
roomName,
userInCollaboration,
......@@ -87,10 +89,10 @@ var addCollaborationMessage = function (
createdAt
);
$("#messages").append(html);
$("#messages").prepend(html);
};
var getMeetingID = function (collaborationType, messageInfo) {
CHAT_SOCKET.getMeetingID = function (collaborationType, messageInfo) {
if (collaborationType == COLLABORATION_TYPE.DOCUMENT) {
return messageInfo[3];
} else {
......@@ -98,7 +100,7 @@ var getMeetingID = function (collaborationType, messageInfo) {
}
};
var renderCollaborationMessage = function (
CHAT_SOCKET.renderCollaborationMessage = function (
template,
roomName,
userList,
......@@ -123,15 +125,17 @@ var renderCollaborationMessage = function (
});
};
var addTextMessage = function (messageText, message, socketID) {
const messageTextWithSID = insertSID(messageText);
CHAT_SOCKET.addTextMessage = function (messageText, message, socketID) {
const messageTextWithSID = CHAT_SOCKET.insertSID(messageText);
const messageSender = JSON.parse(
NativeBridgeDataSource.getUserInfoList(message.userId)
);
const shopMemberName = messageSender[0].shopMemberName;
const textMessageTemplate = getTextMessageTemplate(message.id === socketID);
const textMessageTemplate = CHAT_SOCKET.getTextMessageTemplate(
message.id === socketID
);
const profileImagePath = Common.getProfileImgUrl(message.profileImagePath);
const html = renderTextMessage(
const html = CHAT_SOCKET.renderTextMessage(
textMessageTemplate,
messageTextWithSID,
shopMemberName,
......@@ -139,10 +143,10 @@ var addTextMessage = function (messageText, message, socketID) {
message.userId,
message.createdAt
);
$("#messages").append(html);
$("#messages").prepend(html);
};
var renderTextMessage = function (
CHAT_SOCKET.renderTextMessage = function (
template,
text,
from,
......@@ -170,11 +174,11 @@ var renderTextMessage = function (
}
};
var getUserInfoList = function (userID) {
CHAT_SOCKET.getUserInfoList = function (userID) {
return JSON.parse(NativeBridgeDataSource.getUserInfoList(userID));
};
var cleanUpCollaborationMessage = function () {
CHAT_SOCKET.cleanUpCollaborationMessage = function () {
$(".collabo_area.start").each(function (index, collaborationMessage) {
$(collaborationMessage).removeClass("start");
$(collaborationMessage).addClass("end");
......@@ -184,11 +188,11 @@ var cleanUpCollaborationMessage = function () {
.attr("disabled", "disabled");
$(collaborationMessage)
.find(".collaboration_join_message")
.text(getLocalizedString("message_ended"));
.text(getLocalizedString("flex-directionmessage_ended"));
});
};
var insertSID = function (text) {
CHAT_SOCKET.insertSID = function (text) {
let replacePath = text;
replacePath = replacePath.replaceAll(
"?fileName=",
......@@ -197,7 +201,7 @@ var insertSID = function (text) {
return replacePath;
};
var getTextMessageTemplate = function (isSenderMySelf) {
CHAT_SOCKET.getTextMessageTemplate = function (isSenderMySelf) {
return getTemplate(
isSenderMySelf
? TemplateURL.MY_MESSAGE // ユーザーが送信したメッセージの場合、自分のメッセージ様式を適用して表示する
......
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