1
0
mirror of https://github.com/fumiama/NanoBot.git synced 2026-06-05 18:50:24 +08:00
This commit is contained in:
源文雨
2023-10-15 01:46:49 +09:00
parent c5a11b858f
commit e2b0feebd4
5 changed files with 31 additions and 10 deletions

View File

@@ -19,7 +19,7 @@ type WebsocketPayload struct {
// GetHeartbeatInterval OpCodeHello 获得心跳周期 单位毫秒
func (wp *WebsocketPayload) GetHeartbeatInterval() (uint32, error) {
if wp.Op != OpCodeHello {
return 0, errors.New(getThisFuncName() + " unexpected OpCode " + strconv.Itoa(int(wp.Op)))
return 0, errors.New(getThisFuncName() + " unexpected OpCode " + strconv.Itoa(int(wp.Op)) + ", T: " + wp.T + ", D: " + BytesToString(wp.D))
}
data := &struct {
H uint32 `json:"heartbeat_interval"`
@@ -52,11 +52,11 @@ type EventReady struct {
// GetEventReady OpCodeDispatch READY
func (wp *WebsocketPayload) GetEventReady() (er EventReady, err error) {
if wp.Op != OpCodeDispatch {
err = errors.New(getThisFuncName() + " unexpected OpCode " + strconv.Itoa(int(wp.Op)))
err = errors.New(getThisFuncName() + " unexpected OpCode " + strconv.Itoa(int(wp.Op)) + ", T: " + wp.T + ", D: " + BytesToString(wp.D))
return
}
if wp.T != "READY" {
err = errors.New(getThisFuncName() + " unexpected event type " + wp.T)
err = errors.New(getThisFuncName() + " unexpected event type " + wp.T + ", T: " + wp.T + ", D: " + BytesToString(wp.D))
return
}
err = json.Unmarshal(wp.D, &er)