推送
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
950 B

package hasaki_push
import (
"git.ouxuan.net/hasaki-service/hasaki-sdk/hskgin"
"git.ouxuan.net/tommy/melody"
)
func Initialize(router *hskgin.GinHelper) {
mrouter := melody.New()
router.Any("/push/message", func(ctx *hskgin.GinContextHelper) {
err := mrouter.HandleRequest(ctx.GinContext.Writer, ctx.GinContext.Request)
ctx.CheckErrDisplayByError(err)
})
// 连接
mrouter.HandleConnect(func(session *melody.Session) {
})
// 断连
mrouter.HandleDisconnect(func(session *melody.Session) {
})
// 接收信息
mrouter.HandleMessage(func(session *melody.Session, message []byte) {
// 根据消息类型进行各种
})
// 发送消息
mrouter.HandleSentMessage(func(session *melody.Session, bytes []byte) {
// 设置发送状态
})
// 错误
mrouter.HandleError(func(session *melody.Session, err error) {
})
// 关闭
mrouter.HandleClose(func(session *melody.Session, i int, s string) error {
return nil
})
}