use string for uid same to roomid

This commit is contained in:
Akiba
2023-07-09 11:02:51 +08:00
parent 31f039e912
commit e95ad7f9a5
4 changed files with 10 additions and 6 deletions

View File

@@ -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 {

View File

@@ -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
} }

View File

@@ -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"}

View File

@@ -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 {