开发者文档

支持tiktok、nimo、twitch、海外平台unity、javascrpit、


平台支持

进房
发言
礼物
关注
点赞
头像
tiktok
bigo 礼物事件有
nimo
twitch

字段说明

用户进房

{
  "type":"MemberMessage",//进房行为
  "name":"௸***",//用户名
  "uid":"111222333",//用户唯一标识【已脱敏】
  "head_img":"http://***obj.image",//头像地址
  "content":"进入直播间"
  "room_url":"https://www.nimo.tv/master***",//直播地址
}

用户发言

{
  "type":"ChatMessage",//发言行为
  "name":"玫***",//用户名
  "uid":"111222333",//用户唯一标识【已脱敏】
  "head_img":"http://p11-.image",//头像地址
  "content":"主播好漂亮",//用户发言
  "room_url":"https://www.nimo.tv/master***",//直播地址
}

用户送礼

{
  "type":"GiftMessage",//送礼行为
  "name":"car***",//用户名
  "uid":"a7600bce76cca53fbebe769039bf1b52",//用户唯一标识【已脱敏】
  "head_img":"https://st_avatar_st1.png",//用户图像
  "content":"送礼Finger Heart |  X 1",//内容
  "gift_id":"583",//礼物id
  "gift_name":"Finger Heart",//礼物昵称【未知:未收录】
  "gift_type":"diamond",//礼物类型【diamond:钻石、coin:金币、unKnow:未收录】
  "gift_count":"1",//礼物个数
  "gift_price":1,//礼物单价
  "room_url":"https://www.nimo.tv/master***",//直播地址
}

用户点赞

{
  "type":"LikeMessage",//点赞
  "name":"崔***",//用户名
  "uid":"111222333",//用户唯一标识【已脱敏】
  "head_img":"http://p3-webcast.**bj.image",
  "count":"1",//(用户一次性点赞多少)
  "content":"点赞了1次"
  "room_url":"https://www.nimo.tv/master***",//直播地址
}

开发者对接

工具的本质就是一个本地的websocket服务器,理论上各种语言都可以实现对接哦,软件启动之后,就可以进行对接测试了

web在线测试

python对接

#秋恋猫
import asyncio
import websockets
async def test():
    ws_url = 'ws://127.0.0.1:9999'
    async with websockets.connect(ws_url) as websocket:
        while True:
            recv_text = await websocket.recv()
            print(recv_text)
asyncio.get_event_loop().run_until_complete(test())

unity对接

using System;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
using BestHTTP.WebSocket;
using System.Collections.Generic;
using System.Collections;
public class websocket_01 : MonoBehaviour
{
private void Start()
{
   print("开启websocket");
   Init();
   Connect();}
public string url = "ws://127.0.0.1:9999";

private WebSocket webSocket;

private void Init()
{
   webSocket = new WebSocket(new Uri(url));
   webSocket.OnOpen += OnOpen;
   webSocket.OnMessage += OnMessageReceived;
   webSocket.OnError += OnError;
   webSocket.OnClosed += OnClosed;}
public void Connect()
{
   webSocket.Open();
   print("发送连接"); }
void OnOpen(WebSocket ws)
{
   print("连接成功"); }
void OnMessageReceived(WebSocket ws, string msg)
{
   Debug.Log(msg);}
void OnClosed(WebSocket ws, UInt16 code, string message)
{
   Debug.Log(message);
   webSocket.Close();}
private void OnDestroy()
{
   if (webSocket != null && webSocket.IsOpen)
   {
         Debug.Log("连接断开");
         webSocket.Close();     }}
void OnError(WebSocket ws, Exception ex)
{
   Debug.Log("WebSocket出错:"+ex.Message);
   webSocket.Close();
   }}

js对接

//秋恋猫
let socket1 = new WebSocket('ws://127.0.0.1:9999');
socket1.addEventListener('open', function (event) {
    socket1.send('Hello Server!');
});
socket1.addEventListener('message', function (event) {
    console.log('Message from server ', event.data);
});