์ด๋ฒ ํ๋ก์ ํธ์์ ๊ตฌํํ ๋ฐฉ๋ฒ์
๋๋ค.
DB์ ์ฐ๋ํ ์์ผ์ผ๋ก ๊ตฌํํ ์ฑํ
๋ฐฉ์์ ๋ฉ์์ง๋ง๋ค ์ฝ์ง์์ ์ฌ๋ ์๋ฅผ ์ค์๊ฐ์ผ๋ก ๋ณด์ฌ์ฃผ๋ ๊ธฐ๋ฅ์
๋๋ค.
readMember() ํธ์ถ ์์
readMember()
function readMember() {
$.ajax({
url: _contextPath + '/talk/readMember',
data: { 'roomNumber' : $("#roomNumber").val(),
'm_id' : $("#m_id").val()
},
type: 'get',
success: function (res) {
send('readMember');
},
error : function(err){
console.log('error');
}
});
}
function send(type) {
if (!type) {
type = 'message';
}
var option ={
type: type,
roomNumber : $("#roomNumber").val(),
sessionId : $("#sessionId").val(),
userName : $("#m_name").val(),
msg : $("#chatting").val(),
m_id : $("#m_id").val()
}
ws.send(JSON.stringify(option))
if (type == 'message') {
$('#chatting').val("");
}
}
sendMessageOfUpdateOfSession(rN) ๋ฉ์๋ ํธ์ถ
private void sendMessageOfUpdateOfSession(String roomNumber) {
JSONObject objOfNumOfSession = new JSONObject();
objOfNumOfSession.put("type", "updateOfSession");
int numOfAllMember = talkService.selectJoinGroupMemberList(Integer.parseInt(roomNumber)).size();
int numOfSessionMember = findNumOfSessionMember(roomNumber);
objOfNumOfSession.put("numOfAllMember", numOfAllMember);
objOfNumOfSession.put("numOfSessionMember", numOfSessionMember);
sendMessage(roomNumber, objOfNumOfSession); // ํด๋น ๋ฐฉ์ ์ฐ๊ฒฐ๋์ด ์๋ ์์ผ ์ธ์
๋ค์๊ฒ ๋ฉ์์ง ์ ๋ฌํ๋ ๋ฉ์๋
}
countUnread(tkrm_num)
function countUnread(tkrm_num) {
$.ajax({
url : _contextPath + '/talk/countUnread',
data: {'roomNumber' : $("#roomNumber").val()},
type : 'get',
success: function(res) {
let numOfUnreadList = res.numOfUnreadList;
for(var i = 0; i<numOfUnreadList.length; i++) {
let tk_num = numOfUnreadList[i].tk_num;
let unread_num = numOfUnreadList[i].unread_num;
$('#unReadNum' + tk_num).text(unread_num);
if (unread_num == 0) {
$('#unReadNum' + tk_num).text('');
}
}
},
error : function(err){
console.log('error');
}
});
}