Commit 958a5649 by Kim Eunchul

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

parent cc0c6e1f
CHAT_SOCKET.bindOnNewMessage = function () { 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, onlineUsers) {
CHAT_SOCKET.handleMessage(message, roomName, SOCKET_KEY.NEW_MESSAGE) CHAT_SOCKET.handleMessage(message, roomName, SOCKET_KEY.NEW_MESSAGE, roomID, onlineUsers)
}); });
socket.on(SOCKET_KEY.NEW_COMMUNICATION, function (message, roomID, roomName) { socket.on(SOCKET_KEY.NEW_COMMUNICATION, function (message, roomID, roomName, collaborationType, meetingID) {
CHAT_SOCKET.handleMessage(message, roomName, SOCKET_KEY.NEW_COMMUNICATION) CHAT_SOCKET.handleMessage(message, roomName, SOCKET_KEY.NEW_COMMUNICATION, null, null, collaborationType, meetingID)
}); });
}; };
CHAT_SOCKET.handleMessage = function (message, roomName, socketKey) { CHAT_SOCKET.handleMessage = function (message, roomName, socketKey, roomID = null, onlineUsers = null, collaborationType = null, meetingID = null) {
const systemMessageTemplate = getTemplate(TemplateURL.SYSTEM_MESSAGE); const systemMessageTemplate = getTemplate(TemplateURL.SYSTEM_MESSAGE);
const unwrappedMessageInfo = CHAT_SOCKET.decodeMessage(message.text); const unwrappedMessageInfo = CHAT_SOCKET.decodeMessage(message.text);
...@@ -34,10 +34,12 @@ CHAT_SOCKET.handleMessage = function (message, roomName, socketKey) { ...@@ -34,10 +34,12 @@ CHAT_SOCKET.handleMessage = function (message, roomName, socketKey) {
message.userId, message.userId,
roomName, roomName,
message.insertDate, message.insertDate,
message.createdAt message.createdAt,
collaborationType,
meetingID
); );
} else { } else {
CHAT_SOCKET.addTextMessage(messageText, message, socket.id); CHAT_SOCKET.addTextMessage(messageText, message, socket.id, roomID, onlineUsers);
} }
if (typeof ChatRoom !== "undefined") { if (typeof ChatRoom !== "undefined") {
...@@ -63,10 +65,12 @@ CHAT_SOCKET.addCollaborationMessage = function ( ...@@ -63,10 +65,12 @@ CHAT_SOCKET.addCollaborationMessage = function (
userID, userID,
roomName, roomName,
insertDate, insertDate,
createdAt createdAt,
collaborationType,
meetingID
) { ) {
const collaborationType = CHAT_UTIL.getCollaborationType(messageInfo[2]); const collaborationType = collaborationType;
const meetingID = CHAT_SOCKET.getMeetingID(collaborationType, messageInfo); const meetingID = meetingID;
const userInCollaboration = JSON.parse( const userInCollaboration = JSON.parse(
NativeBridgeDataSource.getUserInfoList(userID) NativeBridgeDataSource.getUserInfoList(userID)
); );
...@@ -125,7 +129,7 @@ CHAT_SOCKET.renderCollaborationMessage = function ( ...@@ -125,7 +129,7 @@ CHAT_SOCKET.renderCollaborationMessage = function (
}); });
}; };
CHAT_SOCKET.addTextMessage = function (messageText, message, socketID) { CHAT_SOCKET.addTextMessage = function (messageText, message, socketID, roomID, onlineUsers) {
const messageTextWithSID = CHAT_SOCKET.insertSID(messageText); const messageTextWithSID = CHAT_SOCKET.insertSID(messageText);
const messageSender = JSON.parse( const messageSender = JSON.parse(
NativeBridgeDataSource.getUserInfoList(message.userId) NativeBridgeDataSource.getUserInfoList(message.userId)
...@@ -135,13 +139,16 @@ CHAT_SOCKET.addTextMessage = function (messageText, message, socketID) { ...@@ -135,13 +139,16 @@ CHAT_SOCKET.addTextMessage = function (messageText, message, socketID) {
message.id === socketID message.id === socketID
); );
const profileImagePath = Common.getProfileImgUrl(message.profileImagePath); const profileImagePath = Common.getProfileImgUrl(message.profileImagePath);
const users = NativeBridgeDataSource.getUsersInRoom(roomID);
const unreadCount = users.length - (onlineUsers.users.length - 1);
const html = CHAT_SOCKET.renderTextMessage( const html = CHAT_SOCKET.renderTextMessage(
textMessageTemplate, textMessageTemplate,
messageTextWithSID, messageTextWithSID,
shopMemberName, shopMemberName,
profileImagePath, profileImagePath,
message.userId, message.userId,
message.createdAt message.createdAt,
unreadCount
); );
$("#messages").prepend(html); $("#messages").prepend(html);
}; };
...@@ -152,7 +159,8 @@ CHAT_SOCKET.renderTextMessage = function ( ...@@ -152,7 +159,8 @@ CHAT_SOCKET.renderTextMessage = function (
from, from,
profileImagePath, profileImagePath,
userID, userID,
createdAt createdAt,
unreadCount
) { ) {
let messageTime = CHAT_UTIL.formatDate(createdAt); let messageTime = CHAT_UTIL.formatDate(createdAt);
let dataInsertedTemplate = Mustache.render(template, { let dataInsertedTemplate = Mustache.render(template, {
...@@ -164,6 +172,7 @@ CHAT_SOCKET.renderTextMessage = function ( ...@@ -164,6 +172,7 @@ CHAT_SOCKET.renderTextMessage = function (
createdAtDay: messageTime.createdAtDay, createdAtDay: messageTime.createdAtDay,
createdAtTime: messageTime.createdAtTime, createdAtTime: messageTime.createdAtTime,
isToday: true, isToday: true,
unreadCount: unreadCount,
}); });
// イメージの場合、img tagを追加する // イメージの場合、img tagを追加する
......
...@@ -96,7 +96,7 @@ ChatRoom.loadMessages = function (joinRoomID, joinRoomName) { ...@@ -96,7 +96,7 @@ ChatRoom.loadMessages = function (joinRoomID, joinRoomName) {
// メッセージ表示 // メッセージ表示
let messages = NativeBridgeDataSource.getMessagesByRoomID(roomID); let messages = NativeBridgeDataSource.getMessagesByRoomID(roomID);
ChatRoom.prependMessage(messages); ChatRoom.prependMessage(messages, roomID);
window.addEventListener( window.addEventListener(
......
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