Description of Barrage Server

wschat is a high-performance, high-concurrency danmaku server we provide, supporting Win/Linux systems, supporting 100,000+ concurrent connections on a single machine, supporting emoticon sending, supporting forbidden word settings, and providing danmaku forwarding services for zwplayer.

This module is a paid module. If you need a trial, please add WeChat ID: zwplayerX to apply (please note "wschat")

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 extract wschat.zip to the specified directory, for example d:/

Open command line as 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, use nginx configuration

 

2. Server Access Address

ws://serverhost.com:3000/

Or

wss://serverhost.com:3000/

3. Message Instance Description

  • c: Client

  • s: Danmaku Server

3.1 Connection Flow

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: Unique ID assigned to the client by the server

  • ip: Client's IP address

Client Sends Hello Message (Handshake)

c → s

{
  "type": "hello"
}

Server Response

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 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 currently in the room

  • loginedcount: Total number of users currently logged in

3.3 Danmaku Function

Send Danmaku

c → s

{
  "type": "danmu",
  "text": "Test sending danmaku"
}

Receive Danmaku

s → c

{
  "type": "danmu",
  "text": "Test sending danmaku",
  "uid": "1412956275600",
  "avatar": "",
  "username": ""
}

3.4 User Login/Logout

User Login

c → s

{
  "type": "login",
  "uname": "User61396",
  "avatar": "https://img1.baidu.com/it/u=2121025603,1672671484&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500",
  "loginid": "uid61396",
  "info": "This user is lazy and left nothing"
}
  • 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": "User61396",
  "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": "This user is lazy and left nothing",
  "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": "User61396",
  "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": "This user is lazy and left nothing",
      "username": "User31935"
    },
    {
      "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": "This user is lazy and left nothing",
      "username": "User81779"
    }
  ],
  "count": 2
}

3.6 Text Chat

Send Chat Message

c → s

{
  "type": "text",
  "text": "I want to chat"
}

Broadcast to Non-logged-in Users s → c

{
  "type": "text",
  "text": "I want to chat",
  "uid": "1412956275584",
  "avatar": "",
  "username": ""
}

Broadcast to Logged-in Users s → c

{
  "type": "text",
  "text": "I want to chat",
  "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": "User84603",
  "userinfo": "This user is lazy and left nothing"
}

3.7 Private Messages

Send Private Message

Single User c → s

{
  "type": "sendto",
  "text": "Private message sent",
  "touids": "1412956275248"
}

Multiple Users c → s

{
  "type": "sendto",
  "text": "Private message sent",
  "touids": ["1412956275248", "1412956275228"]
}

Receive Private Message s → c

{
  "type": "sendto",
  "text": "Private message sent",
  "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": "User55710",
  "userinfo": "This user is lazy and left nothing"
}

3.8 Forbidden Word Filtering

The server side can set forbidden word filtering via WebSocket. Forbidden word filtering should be set through the backend management system.

Forbidden word filtering commands start with the string setbadwords:, followed by forbidden words, with actual carriage return and line feed codes.

Split by equals sign =, the forbidden word is before =, and the replacement good word is after =. The content after = can be empty. There are no spaces on either side of =.

c → s Example:

setbadwords:

ForbiddenWord1=GoodWord1

ForbiddenWord2=GoodWord2

Delete1=

Delete2=
Catalog Navigation