# Channel
This article describes the APIs available in Channel
.
# Participation Method
Access the chat room.
If the set time (default: 5 seconds) has passed and the connection is not successful, a VChatCloudError.networkError
will occur.
You can get ChannelResultModel
from ChannelDelegate.onJoinUserInit
to retrieve your past chat history.
await channel.join(timeout: TimeInterval(5))
Parameter value
Value Identifier Description timeout TimeInterval Wait for connection attempts for the specified amount of time, default 5 seconds
# Exit method
Shut down the exit processing and the chat server's connection in the chat room.
ChannelDelegate.disconnect
is called together.
channel.disconnect()
# Access User List Query Method
Gets the list of users who have accessed the chat room.
await channel.getClientList();
Result value
Value Identifier Description ChannelResultModel List of connected users in ChannelResultModel.body
JSON
# Message sending method
Send a general message to the chat room.
let message = "Hello VChatCloud!"
channel.sendMessage(message)
2
Parameter value
Value Identifier Description message String Message to send
# Emoji Shipment Method
Send emojis to the chat room.
Data needs to be transferred like img/emoticon/emo01/emo01_001.png
to maintain the same shape as other clients (web, android, etc.).
let emoji = "img/emoticon/emo01/emo01_001.png"
channel.sendEmoji(emoji)
2
Parameter value
Value Identifier Description message String Emoji Information
# Whispering Method
Send a whisper to one user.
You must have the recipient's clientKey
and nickname
.
ChannelDelegate.onSendWhisper
is called together.
let message = "Hello"
let receivedClientKey = "mp9y8WCRAp" // Please change it to the actual user's clientKey.
let receivedUserNickname = "User" // Please change it to the nickname of the actual user.
channel.sendWhisper(message, receivedClientKey: receivedClientKey, receivedUserNickname: receivedUserNickname)
2
3
4
Parameter value
Value Identifier Description message String Message to send receivedClientKey String Whisper the other person's clientKey
receivedUserNickname String Whisper the other person's nickname
# File transfer method
After uploading the file to the server, share the file information to the chat server. There are two APIs for this function.
- To get a
URL
to access the file after upload, use VChatCloudAPI.loadFileUrl(_fileKey:String).- If the upload is successful, you can get the value
fileKey
from the return valueFileUploadResponseModel
.
- If the upload is successful, you can get the value
- You can use VChatCloudAPI.downloadFile(_model:FileItemModel, downloadURL:URL? = nil, sharePhotoApp: Bool = true) to save the file immediately.
- Uploads can be up to 100MB per file.
let url = URL(/* INPUT YOUR LOCAL FILE URL */)
let result = await channel.sendFile(url)
2
Parameter value
Value Identifier Description fileUrl String URL of the file to be sent
let data = Data() // INPUT YOUR DATA
let fileName = "image.png"
let result = await channel.sendFile(data: data, fileName: fileName)
2
3
Parameter value
Value Identifier Description data data data of the file to be transferred fileName String Name of the file to transfer (displayed in the file list)