Commit 0f021876 by Lee Munkyeong

チャットルーム開設API連動

parent de0375cf
......@@ -131,7 +131,11 @@ $('#room-search').on('input', function(event) {
// 検索結果が有る場合、結果を表示する
socket.emit('roomSearch', encodeURIComponent($('#room-search').val()));
} else {
socket.emit('getRoomList');
if (isOnline == 'true') {
android.updateRoomList();
CHAT_UI.refreshRoomList();
CHAT_UI.dismissLoadingIndicator();
}
}
});
......@@ -392,7 +396,11 @@ $('a[data-toggle="pill"]').on('show.bs.tab', function (e) {
CHAT_UI.showLoadingIndicator();
socket.emit('leaveRoom', function() {
CHAT.saveRoomInfo();
socket.emit('getRoomList');
if (isOnline == 'true') {
android.updateRoomList();
CHAT_UI.refreshRoomList();
CHAT_UI.dismissLoadingIndicator();
}
});
});
console.log("show #pills-chat")
......@@ -647,6 +655,10 @@ CHAT_UI.showConfirmView = function(isInvite) {
// ルーム名のURIencodingを行う
const encodedRoomName = encodeURIComponent(newRoomName);
//todo android create room api
socket.emit('createNewRoom', userIdList, encodedRoomName, function(newRoomId) {
socket.emit('joinRoom', newRoomId, newRoomName, function () {
CHAT.saveRoomInfo(newRoomId, newRoomName);
......@@ -657,6 +669,46 @@ CHAT_UI.showConfirmView = function(isInvite) {
});
});
socket.on('createNewRoom', (shopMemberIdList, newRoomName, callback) => {
const user = onlineUsers.getUser(socket.id)
if(user){
var loginIdListObj = new Object();
var newRoomNameObj = new Object();
loginIdListObj.type = 'loginIdList'
loginIdListObj.value = shopMemberIdList
newRoomNameObj.type = 'newRoomName'
newRoomNameObj.value = newRoomName
var path = httpRequest.makeChatRoomManageUrlPath(user.shopName, constant.ROOM_CREATENEWROOM, user.sid, loginIdListObj, newRoomNameObj)
winston.info('path' + path)
httpRequest.readResult(path, (res) =>{
const error = serverErrorHandler(res)
if(error.errorFlag) {
winston.error("Failed to [createNewRoom] process.")
socket.emit("showServerError", error.errorMessage);
return;
}
winston.info('create new room from server '+ util.inspect(res, false, null, false))
callback(res.roomId)
// ユーザーリストをアップデートする
socket.emit(res.roomId).emit('updateUserList', res.userList, [user.shop_member_id])
})
} else {
socket.emit("retryJoinProcess")
//join process
}
})
} else if(trimmedRoomName.includes(';') || trimmedRoomName.includes('/') || trimmedRoomName.includes('?') || trimmedRoomName.includes(':') || trimmedRoomName.includes("@")
|| trimmedRoomName.includes('&') || trimmedRoomName.includes('=') || trimmedRoomName.includes("+") || trimmedRoomName.includes('$') || trimmedRoomName.includes(",") || trimmedRoomName.includes('-')
|| trimmedRoomName.includes('_') || trimmedRoomName.includes('.') || trimmedRoomName.includes('!') || trimmedRoomName.includes('~') || trimmedRoomName.includes('*') || trimmedRoomName.includes("\'")
......
......@@ -383,7 +383,11 @@ function setSocketAction () {
if (isInvite) {
$('#pills-chat-tab').tab('show');
} else {
socket.emit('getRoomList');
if (isOnline == 'true') {
android.updateRoomList();
CHAT_UI.refreshRoomList();
CHAT_UI.dismissLoadingIndicator();
}
}
});
});
......
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