diff --git a/README.md b/README.md index 3718fb8..fc3f0a7 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ import ( func main() { 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) { if danmaku.Type == message.EmoticonDanmaku { diff --git a/client/client.go b/client/client.go index 6816f21..6e40d75 100644 --- a/client/client.go +++ b/client/client.go @@ -15,7 +15,7 @@ import ( type Client struct { conn *websocket.Conn - uid int + uid string roomID string tempID string token string @@ -28,7 +28,7 @@ type Client struct { } // NewClient 创建一个新的弹幕 client -func NewClient(roomID string, uid int) *Client { +func NewClient(roomID string, uid string) *Client { ctx, cancel := context.WithCancel(context.Background()) return &Client{ tempID: roomID, @@ -160,7 +160,11 @@ func (c *Client) sendEnterPacket() error { if err != nil { 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 { return err } diff --git a/example/dump/main.go b/example/dump/main.go index dde9702..48b3f98 100644 --- a/example/dump/main.go +++ b/example/dump/main.go @@ -10,7 +10,7 @@ import ( ) const roomId = "8792912" -const uid = 745493 +const uid = "745493" var dumps = []string{"GUARD_BUY", "USER_TOAST_MSG"} diff --git a/example/main.go b/example/main.go index 92663f8..a675b75 100644 --- a/example/main.go +++ b/example/main.go @@ -13,7 +13,7 @@ import ( func main() { log.SetLevel(log.DebugLevel) - c := client.NewClient("732", 194484313) + c := client.NewClient("732", "194484313") //弹幕事件 c.OnDanmaku(func(danmaku *message.Danmaku) { if danmaku.Type == message.EmoticonDanmaku {