googollee / go-socket.io

socket.io library for golang, a realtime application framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to receive binary message?

amos-lsl opened this issue · comments

how to receive binary message?

Simple add a []byte parameter to the event handler should be enough.

	type barType struct {
		Text string `json:"text"`
		Data []byte `json:"data"`
	}
	server.OnEvent("/", "bar", func(s socketio.Conn, payload *barType) string {
		text := payload.Text
		data := payload.Data
		fmt.Println(text, data)
		return fmt.Sprintf("Ack of bar %s %s", text, data)
	})
image