```go
type ServerHandler struct {
Message chan *rtmp.Message
}
// Conn handler functions
func (handler *ServerHandler) OnReceived(conn rtmp.Conn, message *rtmp.Message) {
fmt.Printf("@@@@@@@@@@@@@OnReceived Success : %#v\n", message)
handler.Message <- message
}
// Stream callback handle functions
func (handler *ServerHandler) OnPlayStart(stream rtmp.InboundStream) {
fmt.Printf("@@@@@@@@@@@@@OnPlayStart: message %#v\n", handler.Message)
conn := stream.Conn()
go func() {
for {
select {
case message := <-handler.Message:
conn.Send(message)
}
}
}()
}
```
OnReceived()和OnPlayStart()都是回调函数,如何利用channel通信,还是说根本不能通信,按我上面的代码写的是错的,OnReceived()会阻塞,OnPlayStart的handler.Message也是nil,求解??希望大家帮忙
有疑问加站长微信联系(非本文作者)