To connect to the WebSocket service, use the following URL:
ws://apiurl/ws8881
Here is an example of connecting to the WebSocket service using JavaScript:
const socket = new WebSocket('ws://apiurl/ws8881');
socket.onopen = function(event) {
console.log('Connected to WebSocket server.');
// Send message command 1 after successful connection
const apiKey = "yourApiKey";
const agent = "agentName";
const timestamp = Date.now();
const sign = md5(agent + apiKey + timestamp);
const message = {
cmd: "connect",
agent: agent,
sign: sign,
time: timestamp,
tableIds: [10101, 10102, 10103]
};
socket.send(JSON.stringify(message));
};
socket.onmessage = function(event) {
console.log('Message from server:', event.data);
};
socket.onclose = function(event) {
console.log('Disconnected from WebSocket server.');
};
socket.onerror = function(error) {
console.error('WebSocket error:', error);
};
// MD5 hash function
function md5(string) {
// Implementation of MD5 hash function
// You can use a library like CryptoJS for this
return CryptoJS.MD5(string).toString();
}
Sent by the client to establish a connection.
Signature rule: Use the MD5 algorithm to hash the concatenated string of `agent` name, `apiKey`, and `timestamp`.
{
"cmd": "connect",
"agent": "agentName",
"sign": "MD5(agentName + apiKey + timestamp)",
"time": "timestamp",
"tableIds": [10101, 10102, 10103]
}
The following is the data structure returned by the connect
command:
{
"codeId": 0, // Code ID
"cmd": "connect", // Command type
"agent": "DG01010100", // Agent name
"sign": "368c0add887c525cdf16cf9bdf897779", // Signature
"tableIds": [10101, 10102, 10103], // List of table IDs
"tableNameMap": { // Table ID to table name
"10101": "D01",
"10102": "D02",
"10103": "D03"
},
"tableGoodRoadType": { // Table ID to good road type and count (used for long dragon or single jump)
"10101": "1-6", // 6 long banker
"10102": "3-5", // 5 single hop banker road
"10103": "12-0" // rows and rows
},
"tableOnlineCount": { // Table ID to number of online users
"10101": 1023,
"10102": 249,
"10103": 441
},
"tablePicture": { // Table ID to table screenshot path
"10101": "241220/10101/i1oQ.jpg",
"10102": "241220/10102/Xkot.jpg",
"10103": "241220/10103/5YJu.jpg"
},
"tableRoads": { // Table ID to list of road data
"10101": ["#5#0#8", "#1#0#9", "#1#0#7", "#5#0#8", "#1#0#8", "#5#0#7", "#3#0#7", "#6#0#8", "#6#0#5", "#5#0#9", "#1#0#9", "#5#0#9", "#3#0#9", "#1#0#7", "#5#0#7", "#1#0#8", "#1#0#8", "#5#0#7", "#5#0#7", "#5#0#8", "#5#0#8", "#5#0#7", "#1#0#8", "#11#0#0", "#9#0#9", "#9#0#9", "#9#0#6", "#2#1#6", "#5#0#9", "#1#0#9", "#1#0#9", "#5#0#8", "#5#0#8", "#1#0#7", "#5#0#2", "#5#0#1", "#1#0#7", "#5#0#9", "#1#1#6", "#1#0#7", "#1#0#1", "#1#0#7", "#5#0#9"],
"10102": ["#1#0#8", "#1#0#8", "#3#0#8", "#5#0#7", "#5#0#7", "#1#0#5"],
"10103": ["#9#0#4", "#5#0#9", "#5#0#6", "#1#0#3", "#5#0#7", "#1#0#3", "#1#0#8", "#5#0#8", "#1#0#4", "#9#0#7", "#5#0#7", "#1#0#4", "#5#0#8", "#6#0#7", "#5#0#9", "#5#0#8", "#9#0#6", "#1#1#6"]
}
}
Sent by the client to keep the connection alive.
{
"cmd": "ping"
}
Sent by the server to push road data.
{
"cmd": "push_roads",
"tableId": 123,
"roads": ["road1", "road2"],
"online": 100,
"goodRoad": "type-count"
}
Sent by the server to push live dealer change picture data.
{
"cmd": "push_change_picture",
"tableId": 123,
"picture": "dealerPhotoUrl"
}
Game | Example | Definition |
---|---|---|
Classic, Speed, Live, Sexy Baccarat (GameId=1) |
road1="#6#0#3" |
Separated by #: |
Dragon Tiger (GameId=3) |
road1="#2#0101" |
Separated by #: |
Roulette (GameId=4) |
road1="#16" |
Separated by #: |
Sic Bo (GameId=5) |
road1="#123" |
Separated by #: |
Fan Tan (GameId=6) |
road1="#1" |
Separated by #: |
Niu Niu (GameId=7) |
road1="#0,1,0,5#1,1,1#27" |
Separated by #: |
Golden Flower (GameId=11) |
road1="#2#1,1,7,14,1#" |
Separated by #: |
Color Disc (GameId=14) |
road1="#2" |
Separated by #: |
San Gong (GameId=16) |
road1="#2P7,6,1P3,0,1,3,0,1#1,1,1#1" |
Separated by #: |
Andar Bahar (GameId=20) |
road1="#1#31#48#" |
Separated by #: |
Type | Description |
---|---|
1 | Long Banker |
2 | Long Player |
3 | Single Hop Banker Road |
4 | One Banker Two Player |
5 | One Player Two Banker |
8 | Meet Banker Jump |
9 | Meet Player Jump |
10 | Meet Banker Row |
11 | Meet Player Row |
12 | Rows and Rows |