mirror of
https://github.com/AynaLivePlayer/blivedm-go.git
synced 2025-12-07 20:02:50 +08:00
use string for uid same to roomid
This commit is contained in:
@@ -33,7 +33,7 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
c := client.NewClient("732", 194484313) // 732为房间号,194484313为UID
|
c := client.NewClient("732", "194484313") // 732为房间号,194484313为UID
|
||||||
//弹幕事件
|
//弹幕事件
|
||||||
c.OnDanmaku(func(danmaku *message.Danmaku) {
|
c.OnDanmaku(func(danmaku *message.Danmaku) {
|
||||||
if danmaku.Type == message.EmoticonDanmaku {
|
if danmaku.Type == message.EmoticonDanmaku {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
conn *websocket.Conn
|
conn *websocket.Conn
|
||||||
uid int
|
uid string
|
||||||
roomID string
|
roomID string
|
||||||
tempID string
|
tempID string
|
||||||
token string
|
token string
|
||||||
@@ -28,7 +28,7 @@ type Client struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewClient 创建一个新的弹幕 client
|
// NewClient 创建一个新的弹幕 client
|
||||||
func NewClient(roomID string, uid int) *Client {
|
func NewClient(roomID string, uid string) *Client {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
return &Client{
|
return &Client{
|
||||||
tempID: roomID,
|
tempID: roomID,
|
||||||
@@ -160,7 +160,11 @@ func (c *Client) sendEnterPacket() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("error roomID")
|
return errors.New("error roomID")
|
||||||
}
|
}
|
||||||
pkt := packet.NewEnterPacket(c.uid, rid, c.token)
|
uid, err := strconv.Atoi(c.uid)
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("error roomID")
|
||||||
|
}
|
||||||
|
pkt := packet.NewEnterPacket(uid, rid, c.token)
|
||||||
if err = c.conn.WriteMessage(websocket.BinaryMessage, pkt); err != nil {
|
if err = c.conn.WriteMessage(websocket.BinaryMessage, pkt); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const roomId = "8792912"
|
const roomId = "8792912"
|
||||||
const uid = 745493
|
const uid = "745493"
|
||||||
|
|
||||||
var dumps = []string{"GUARD_BUY", "USER_TOAST_MSG"}
|
var dumps = []string{"GUARD_BUY", "USER_TOAST_MSG"}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
c := client.NewClient("732", 194484313)
|
c := client.NewClient("732", "194484313")
|
||||||
//弹幕事件
|
//弹幕事件
|
||||||
c.OnDanmaku(func(danmaku *message.Danmaku) {
|
c.OnDanmaku(func(danmaku *message.Danmaku) {
|
||||||
if danmaku.Type == message.EmoticonDanmaku {
|
if danmaku.Type == message.EmoticonDanmaku {
|
||||||
|
|||||||
Reference in New Issue
Block a user