瀏覽代碼

Pass struct along with OnEvent event.

Bruce Marriner 8 年之前
父節點
當前提交
836e78d3d9
共有 2 個文件被更改,包括 3 次插入0 次删除
  1. 1 0
      structs.go
  2. 2 0
      wsapi.go

+ 1 - 0
structs.go

@@ -265,6 +265,7 @@ type Event struct {
 	Operation int             `json:"op"`
 	Direction int             `json:"dir"`
 	RawData   json.RawMessage `json:"d"`
+	Struct    interface{}     `json:"-"`
 }
 
 // A Ready stores all data for the websocket READY event.

+ 2 - 0
wsapi.go

@@ -301,6 +301,8 @@ func (s *Session) event(messageType int, message []byte) {
 	if i != nil {
 		s.handle(i)
 	}
+
+	e.Struct = i
 	s.handle(e)
 
 	return