Barrage Server Documentation
wschat is a high-performance, high-concurrency barrage (danmu) server that we provide. It supports Windows/Linux systems, supports 100,000+ concurrent connections on a single machine, supports sending emojis, supports prohibited word settings, and can provide barrage forwarding services for zwplayer.
This is a paid module. If you need a trial, please add WeChat ID: zwplayerX to apply.
1. Installation
1.1 Linux Platform
Copy wschat.zip to the server directory, for example /home/
cd /home
unzip wschat.zip -d wschat
cd wschat
1.2 Windows Platform
Download and unzip wschat.zip to a specified directory, for example d:/
Open the command line as an administrator
cd d:/wschat
./wschat.exe -i # Install service
net start iAVCastLBLService # Start service
net stop iAVCastLBLService # Stop service
1.3 Modify Configuration
The file is located at conf/lblserver.conf in the installation directory
port=3000
ssl=0
ssl_cert=/sslcerts/fullchain.cer
ssl_key=/sslcerts/server.key
Configuration file description
- port: Port number
- ssl: Whether to enable SSL
- ssl_cert/ssl_key: SSL public/private key certificates, configured using nginx
2. Server Access Address
ws://serverhost.com:3000/
or
wss://serverhost.com:3000/
3. Message Instance Description
- c: Client
- s: Barrage Server
3.1 Connection Process
Server Assigns User ID
After the client successfully connects to the server via WebSocket, the server assigns a User ID:
s → c
{
"type": "setuserid",
"uid": 1412956275600,
"ip": "192.168.1.202"
}
uid: The unique ID assigned by the server to the clientip: The client’s IP address
Client Sends Hello Message Handshake
c → s
{
"type": "hello"
}
Server Reply
s → c
{
"type": "hello",
"server": "Huayi Live Chat Server Version 1.0",
"uid": 1412956275600,
"ip": "192.168.1.202"
}
3.2 Room Operations
Join Room
c → s
{
"type": "join",
"room": "videoroom_001"
}
Server Feedback on Join Room Result
s → c
{
"type": "event",
"event": "joinroom",
"uid": 1412956275600,
"userscount": 1,
"loginedcount": 0,
"ip": "192.168.1.202"
}
userscount: Total number of users in the current roomloginedcount: Total number of currently logged-in users
3.3 Barrage Functionality
Send Barrage
c → s
{
"type": "danmu",
"text": "测试发送弹幕"
}
Receive Barrage
s → c
{
"type": "danmu",
"text": "测试发送弹幕",
"uid": "1412956275600",
"avatar": "",
"username": ""
}
3.4 User Login/Logout
User Login
c → s
{
"type": "login",
"uname": "用户61396",
"avatar": "https://img1.baidu.com/it/u=2121025603,1672671484&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500",
"loginid": "uid61396",
"info": "这家伙很懒,什么也没说"
}
avatar: Avatar URL location, must be accessible by the current page
Login Result Feedback s → c
{
"type": "login",
"result": "success"
}
Server Broadcasts Login Information s → c
{
"type": "event",
"event": "login",
"uid": 1412956275248,
"username": "用户61396",
"avatar": "https://img1.baidu.com/it/u=2121025603,1672671484&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500",
"time": 1717737414,
"userid": "uid61396",
"userinfo": "这家伙很懒,什么也没说",
"userscount": 2,
"loginedcount": 1,
"ip": "192.168.1.202"
}
User Logout
c → s
{
"type": "logout"
}
Logout Result Feedback s → c
{
"type": "logout",
"result": "success"
}
Server Broadcasts Logout Information s → c
{
"type": "event",
"event": "logout",
"uid": 1412956275248,
"username": "用户61396",
"userscount": 1,
"loginedcount": 0,
"ip": "192.168.1.202"
}
Leave Room
c → s
{
"type": "leave"
}
Server Broadcasts Leave Information s → c
{
"type": "event",
"event": "leaveroom",
"uid": 1412956275248,
"userscount": 1,
"loginedcount": 0,
"ip": "192.168.1.202"
}
3.5 User List
Get User List
c → s
{
"type": "userlist"
}
Server Returns User List s → c
{
"type": "userlist",
"users": [
{
"uid": "1412956275248",
"ip": "192.168.1.202",
"time": "1717738078",
"avatar": "https://img1.baidu.com/it/u=2121025603,1672671484&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500",
"userid": "uid31935",
"userinfo": "这家伙很懒,什么也没说",
"username": "用户31935"
},
{
"uid": "1412956783616",
"ip": "192.168.1.202",
"time": "1717738554",
"avatar": "https://img1.baidu.com/it/u=2121025603,1672671484&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500",
"userid": "uid81779",
"userinfo": "这家伙很懒,什么也没说",
"username": "用户81779"
}
],
"count": 2
}
3.6 Text Chat
Send Chat Message
c → s
{
"type": "text",
"text": "我要聊天"
}
Message Broadcast for Non-logged-in User s → c
{
"type": "text",
"text": "我要聊天",
"uid": "1412956275584",
"avatar": "",
"username": ""
}
Message Broadcast for Logged-in User s → c
{
"type": "text",
"text": "我要聊天",
"uid": "1412956275584",
"userid": "uid84603",
"avatar": "https://img1.baidu.com/it/u=2121025603,1672671484&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500",
"username": "用户84603",
"userinfo": "这家伙很懒,什么也没说"
}
3.7 Private Messages
Send Private Message
Single User c → s
{
"type": "sendto",
"text": "私密消息发送",
"touids": "1412956275248"
}
Multiple Users c → s
{
"type": "sendto",
"text": "私密消息发送",
"touids": ["1412956275248", "1412956275228"]
}
Receive Private Message s → c
{
"type": "sendto",
"text": "私密消息发送",
"uid": "1412956275584",
"userid": "uid55710",
"avatar": "https://img1.baidu.com/it/u=2121025603,1672671484&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500",
"username": "用户55710",
"userinfo": "这家伙很懒,什么也没说"
}
3.8 Prohibited Word Filtering
The server side can configure prohibited word filtering via WebSocket. Prohibited word filtering should be set through the backend management system.
The prohibited word filtering command starts with the string setbadwords:\r\n, followed by the prohibited words. \r\n is the actual code for carriage return and line feed.
An equal sign = is used as a separator. The content before = is the prohibited word, and the content after = is the replacement word. The content after = can be omitted. There are no spaces on either side of =.
c → s Example:
setbadwords:\r\n
禁词1=好词1\r\n
禁词2=好词2\r\n
删除1=\r\n
删除2=\r\n