# 채팅방 전체 메시지

# 공지 메시지 이벤트

channel.onNotifyNotice = function(event) {
    // {"nickName":"홍길동","roomId":"e7works","clientKey":"user고유키","message":"전송될 메시지","mimeType":"text","messageType":"notice","messageDt":"20200826172223","messageCount":5260,"grade":"user"}
    console.log('onNotifyNotice', event)
};
1
2
3
4
  • 푸시 결과 값

    식별자 설명
    roomId String 채팅방 생성 후 발급받은 Channel Key
    nickName String 채팅방 입장 유저의 별명
    clientKey String 메시지를 전송한 접속 단말 설정 고유키
    message Date 전송한 메시지
    mimeType String 메시지 형태 (text: 일반텍스트, emoji: 이모지)
    messageType String 빈값이면 일반 메시지, 공지일경우 : "notice"
    messageDt String 전송 날짜
    messageCount String 채팅방 메시지 전송 수
    grade String 메시지를 전송한 유저의 등급 ( 사용자등급표 에서 확인 )

# 프로젝트에 적용할 코드

channel.onNotifyNotice = function(event) {
    write(msg, 'notice')
}
1
2
3

# 신규 유저접속 이벤트

channel.onNotifyJoinUser = function(event) {
    // {"roomId":"e7works","clientKey":"4bcdb713","nickName":"엣지","grade":"user","joinCount":3476}
    console.log('onNotifyJoinUser', event)
}
1
2
3
4
  • 푸시 결과 값

    식별자 설명
    roomId String 채팅방 생성 후 발급받은 Channel Key
    nickName String 채팅방 입장 유저의 별명
    clientKey String 메시지를 전송한 접속 단말 설정 고유키
    joinCount String 누적 유저수
    grade String 메시지를 전송한 유저의 등급 ( 사용자등급표 에서 확인 )

# 프로젝트에 적용할 코드

channel.onNotifyJoinUser = function(event) {
    write(event, 'join')
}
1
2
3

# 유저가 나간 경우 이벤트

channel.onNotifyLeaveUser = function(event) {
    // {"nickName":"엣지"}
    console.log('onNotifyLeaveUser', event)
}
1
2
3
4
  • 푸시 결과 값

    식별자 설명
    nickName String 채팅방 입장 유저의 별명

# 프로젝트에 적용할 코드

channel.onNotifyLeaveUser = function(event) {
    write(event, 'leave')
}
1
2
3

# 채팅방에서 추방 이벤트

channel.onNotifyKickUser = function(event) {
    // {"nickName":"tester_01"}
    console.log('onNotifyKickUser', event)
}
1
2
3
4
  • 푸시 결과 값

    식별자 설명
    nickName String 채팅방 입장 유저의 별명

# 프로젝트에 적용할 코드

channel.onNotifyKickUser = function(event) {
    write("'<font color='blue'><b>" + event.nickName + "</b></font>' 님이 채팅방에서 추방되었습니다.");
}
1
2
3

# 채팅방에서 추방해제 이벤트

channel.onNotifyUnkickUser = function(event) {
    // {"clientKey":"5000ec4b","messageDt":1598436375463}
    console.log('onNotifyUnkickUser', event)
}
1
2
3
4
  • 푸시 결과 값

    식별자 설명
    clientKey String 메시지를 전송한 접속 단말 설정 고유키
    messageDt String 전송 날짜

# 프로젝트에 적용할 코드

channel.onNotifyUnkickUser = function(event) {
    write("'<font color='blue'><b>" + event.nickName + "</b></font>' 님이 채팅방에서 추방 해제되었습니다.");
}
1
2
3

# 채팅방에서 글쓰기 제한 이벤트

channel.onNotifyMuteUser = function(event) {
    // {"clientKey":"user고유키","nickName":"홍길동","messageDt":1598426153634}
    console.log('onNotifyMuteUser', event)
}
1
2
3
4
  • 푸시 결과 값

    식별자 설명
    nickName String 채팅방 입장 유저의 별명
    clientKey String 메시지를 전송한 접속 단말 설정 고유키
    messageDt String 전송 날짜

# 프로젝트에 적용할 코드

channel.onNotifyMuteUser = function(event) {
    write("'<font color='blue'><b>" + event.nickName + "</b></font>' 님의 글쓰기가 제한되었습니다.");
}
1
2
3

# 채팅방에서 글쓰기 제한해제 이벤트

channel.onNotifyUnmuteUser = function(event) {
    // {"clientKey":"user고유키","nickName":"홍길동","messageDt":1598954317679}
    console.log('onNotifyUnmuteUser', event)
}
1
2
3
4
  • 푸시 결과 값

    식별자 설명
    nickName String 채팅방 입장 유저의 별명
    clientKey String 메시지를 전송한 접속 단말 설정 고유키
    messageDt String 전송 날짜

# 프로젝트에 적용할 코드

channel.onNotifyUnmuteUser = function(event) {
    write("'<font color='blue'><b>" + event.nickName + "</b></font>' 님의 글쓰기가 제한 해제되었습니다.");
}
1
2
3

# 채팅방에서 초대 이벤트

channel.onPersonalInvite = function(event) {
    // { roomId: "채널키" }
    console.log('onPersonalInvite', event)
}
1
2
3
4
  • 푸시 결과 값

    식별자 설명
    roomId String 채팅방 입장을 위한 키

# 프로젝트에 적용할 코드

channel.onPersonalInvite = function(event) {
    // 새로운 채널로 조인
    privateChannel = vChatCloud.joinChannel({
        roomId: event.roomId, // 전달받은 채널키로 진입
        clientKey: clientKey, // 접속 클라이언트키
        nickName: nickName, // 접속 닉네임
        },
        function (error, history) {
            // 채팅룸 조인 후 이벤트
        }
    );
}
1
2
3
4
5
6
7
8
9
10
11
12

# 전체 코드

메시지 이벤트 전체코드
// msgInit() 부분은 login.js에 joinRoom 이 성공한 이후에 실행하도록 한다
function msgInit() {
    // 공지사항 메시지
    channel.onNotifyNotice = function(event) {
        write(event, 'notice')
    }

    // 유저 입장
    channel.onNotifyJoinUser = function(event) {
        write(event, 'join')
    }

    // 유저 나감
    channel.onNotifyLeaveUser = function(event) {
        write(event, 'leave')
    }

    // 유저 추방
    channel.onNotifyKickUser = function(event) {
        write("'<font color='blue'><b>" + event.nickName + "</b></font>' 님이 채팅방에서 추방되었습니다.");
    }

    // 유저 추방 해제
    channel.onNotifyUnkickUser = function(event) {
        write("'<font color='blue'><b>" + event.nickName + "</b></font>' 님이 채팅방에서 추방 해제되었습니다.");
    }

    // 글쓰기 제한
    channel.onNotifyMuteUser = function(event) {
        write("'<font color='blue'><b>" + event.nickName + "</b></font>' 님의 글쓰기가 제한되었습니다.");
    }

    // 글쓰기 제한 해제
    channel.onNotifyUnmuteUser = function(event) {
        write("'<font color='blue'><b>" + event.nickName + "</b></font>' 님의 글쓰기가 제한 해제되었습니다.");
    }

    // 초대 이벤트
    channel.onPersonalInvite = function(event) {
        console.log('onPersonalInvite', event)
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Copyright 2022. E7Works Inc. & JOYTUNE Corp. All Rights Reserved.