Closed jjhesk closed 6 years ago
e := &ev.Emitter{} e.Use("*", ev.Void)
e.On("main_event", func(evt *ev.Event) { message_like := evt.Args[0] jscontent, := json.Marshal(message_like) fmt.Printf("\nBC mess:", js_content) })
type Announcement struct { GameID int json:"gid" PlayerId int64 json:"pid" }
json:"gid"
json:"pid"
b1 := &Announcement{ GameID: 1, PlayerId: 4234, } go ev.Emit("main_event", b1)
how to cast the type into the receive listener?
b2, ok := e.Args[0].(*Announcement)
ok, thats really useful!
e := &ev.Emitter{} e.Use("*", ev.Void)
e.On("main_event", func(evt *ev.Event) { message_like := evt.Args[0] jscontent, := json.Marshal(message_like) fmt.Printf("\nBC mess:", js_content) })
type Announcement struct { GameID int
json:"gid"
PlayerId int64json:"pid"
}b1 := &Announcement{ GameID: 1, PlayerId: 4234, } go ev.Emit("main_event", b1)
how to cast the type into the receive listener?