# new chat room

In order to create a new chat room, you must be connected to a random chat room.
Conversely, it is possible to delete the created chat room, and be careful as it must be deleted with the same ID for it to work.
If you are not ready, let's learn how to create it. Go to preparations

# Create a new chat room

let openRoomId = "Unique Room ID"
privateChannel = vChatCloud.openChannel({
        roomId: openRoomId,
        clientKey: channel.clientKey, // Channel connected to the main
    },
    function (err, res) {
        console.log(res)
    }
)
1
2
3
4
5
6
7
8
9
  • Parameter value

    Value Identifier Description
    err String Object returned in case of error
    res String Object returned on success

# code to apply to the project

privateChannel = vChatCloud.openChannel({
        roomId: openRoomId,
        clientKey: channel.clientKey,
    },
    function (err, res) {
        if (res) {
            console.log("success")
        } else if (err) {
            console.log("error", err)
        }
    }
)
1
2
3
4
5
6
7
8
9
10
11
12

# Chat room deletion event

let openRoomId = "Created room ID"
vChatCloud.closeChannel({
        roomId: openRoomId,
        clientKey: channel.clientKey, // Channel connected to the main
    },
    function (err, res) {
        console.log(res)
    }
);
1
2
3
4
5
6
7
8
9
  • Parameter value

    Value Identifier Description
    err String Object returned in case of error
    res String Object returned on success

# code to apply to the project

vChatCloud.closeChannel({
        roomId: openRoomId,
        clientKey: channel.clientKey,
    },
    function (err, res) {
        if (res) {
            console.log("success")
        } else if (err) {
            console.log("error", err)
        }
    }
);
1
2
3
4
5
6
7
8
9
10
11
12
Copyright 2022. E7Works Inc. & JOYTUNE Corp. All Rights Reserved.