From f5c63cde56eb35c0125a0545f084441cdd4340ab Mon Sep 17 00:00:00 2001 From: Keuin Date: Tue, 11 Jul 2023 22:56:07 +0800 Subject: Refactor: move data structures to a separate package to avoid circular dependency. --- danmaku/client.go | 4 ++-- danmaku/dmpkg/auth.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'danmaku') diff --git a/danmaku/client.go b/danmaku/client.go index c74a449..3862154 100644 --- a/danmaku/client.go +++ b/danmaku/client.go @@ -9,8 +9,8 @@ package danmaku import ( "context" "fmt" - "github.com/keuin/slbr/bilibili" "github.com/keuin/slbr/danmaku/dmpkg" + "github.com/keuin/slbr/types" "nhooyr.io/websocket" ) @@ -87,7 +87,7 @@ func (d *DanmakuClient) Disconnect() error { return ws.Close(websocket.StatusInternalError, "disconnected") } -func (d *DanmakuClient) Authenticate(roomId bilibili.RoomId, authKey string) error { +func (d *DanmakuClient) Authenticate(roomId types.RoomId, authKey string) error { pkg := dmpkg.NewAuth(dmpkg.ProtoPlainJson, roomId, authKey) data, err := pkg.Marshal() if err != nil { diff --git a/danmaku/dmpkg/auth.go b/danmaku/dmpkg/auth.go index bb66f1d..b6a90d3 100644 --- a/danmaku/dmpkg/auth.go +++ b/danmaku/dmpkg/auth.go @@ -8,20 +8,20 @@ package dmpkg import ( "encoding/json" "fmt" - "github.com/keuin/slbr/bilibili" + "github.com/keuin/slbr/types" ) type authInfo struct { - UID uint64 `json:"uid"` - RoomId bilibili.RoomId `json:"roomid"` - ProtoVer int `json:"protover"` - Platform string `json:"platform"` - Type int `json:"type"` - Key string `json:"key"` + UID uint64 `json:"uid"` + RoomId types.RoomId `json:"roomid"` + ProtoVer int `json:"protover"` + Platform string `json:"platform"` + Type int `json:"type"` + Key string `json:"key"` } // NewAuth creates a new authentication exchange. -func NewAuth(protocol ProtocolVer, roomId bilibili.RoomId, authKey string) (exc DanmakuExchange) { +func NewAuth(protocol ProtocolVer, roomId types.RoomId, authKey string) (exc DanmakuExchange) { exc, _ = NewPlainExchange(OpConnect, authInfo{ UID: UidGuest, RoomId: roomId, -- cgit v1.2.3