|
@@ -4,6 +4,7 @@ import (
|
|
|
"context"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
+ "git.bvbej.com/bvbej/base-golang/pkg/mux"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"go.uber.org/zap"
|
|
|
"net/http"
|
|
@@ -26,6 +27,7 @@ type WsAcceptor interface {
|
|
|
Start(addr string) error
|
|
|
Stop()
|
|
|
GinHandle(ctx *gin.Context)
|
|
|
+ HandlerFunc() mux.HandlerFunc
|
|
|
}
|
|
|
|
|
|
type wsAcceptor struct {
|
|
@@ -88,3 +90,9 @@ func (ws *wsAcceptor) GinHandle(ctx *gin.Context) {
|
|
|
}
|
|
|
ws.sessMgr.Register <- peer.NewSession(NewConnection(c, ws.sessMgr))
|
|
|
}
|
|
|
+
|
|
|
+func (ws *wsAcceptor) HandlerFunc() mux.HandlerFunc {
|
|
|
+ return func(c mux.Context) {
|
|
|
+ ws.GinHandle(c.Context())
|
|
|
+ }
|
|
|
+}
|