From 2e34dcad414940e3b08ef19db1098656dcf4b630 Mon Sep 17 00:00:00 2001 From: Lex Lim Date: Fri, 16 Dec 2022 17:32:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E4=BA=8B=E4=BB=B6=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- context/ServerContext.go | 2 +- controller/ClientSocketController.go | 7 +------ controller/SocketController.go | 2 +- go.mod | 4 ++-- go.sum | 4 ++-- main.go | 2 +- 6 files changed, 8 insertions(+), 13 deletions(-) diff --git a/context/ServerContext.go b/context/ServerContext.go index 0e828ae..ce3049a 100644 --- a/context/ServerContext.go +++ b/context/ServerContext.go @@ -3,7 +3,7 @@ package context import ( "github.com/gin-gonic/gin" socketio "github.com/googollee/go-socket.io" - eventemitter "github.com/vansante/go-event-emitter" + eventemitter "github.com/hyperzlib/go-event-emitter" ) type ServerContext struct { diff --git a/controller/ClientSocketController.go b/controller/ClientSocketController.go index df0f1f3..a372986 100644 --- a/controller/ClientSocketController.go +++ b/controller/ClientSocketController.go @@ -263,12 +263,7 @@ func (c *ClientSocketController) BindPlayer(user string, code string) (string, e } } -func (c *ClientSocketController) OnBindUser(eventObj ...interface{}) { - event, err := utils.GetEvent[events.BindUserEvent](eventObj) - if err != nil { - log.Panicln("Cannot get event in OnBindUser:", err.Error()) - } - +func (c *ClientSocketController) OnBindUser(event events.BindUserEvent) { userName := event.User userInfo := c.storeModel.GetUserInfo(event.User) if userInfo == nil { diff --git a/controller/SocketController.go b/controller/SocketController.go index 167aa01..0ac7cd4 100644 --- a/controller/SocketController.go +++ b/controller/SocketController.go @@ -2,9 +2,9 @@ package controller import ( socketio "github.com/googollee/go-socket.io" + eventemitter "github.com/hyperzlib/go-event-emitter" "github.com/hyperzlib/isekai-remote-playback/context" "github.com/hyperzlib/isekai-remote-playback/store" - eventemitter "github.com/vansante/go-event-emitter" ) type SocketController struct { diff --git a/go.mod b/go.mod index ee1438b..93435e6 100644 --- a/go.mod +++ b/go.mod @@ -11,10 +11,11 @@ require ( github.com/gin-gonic/gin v1.8.1 github.com/go-redis/redis/v8 v8.11.5 github.com/googollee/go-socket.io v1.6.2 + github.com/hyperzlib/go-event-emitter v0.0.0-20221216091038-517774b059d3 + github.com/mileusna/useragent v1.2.1 github.com/mitchellh/mapstructure v1.5.0 github.com/pochard/commons v1.1.2 github.com/spf13/viper v1.14.0 - github.com/vansante/go-event-emitter v1.0.2 golang.org/x/exp v0.0.0-20221204150635-6dcec336b2bb ) @@ -39,7 +40,6 @@ require ( github.com/magiconair/properties v1.8.6 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mileusna/useragent v1.2.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml v1.9.5 // indirect diff --git a/go.sum b/go.sum index dd98008..1212ffe 100644 --- a/go.sum +++ b/go.sum @@ -191,6 +191,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hyperzlib/go-event-emitter v0.0.0-20221216091038-517774b059d3 h1:3F8JhZDgR6O85DMCnp6Rsjjm599jdmYEWQqjmnKn2cA= +github.com/hyperzlib/go-event-emitter v0.0.0-20221216091038-517774b059d3/go.mod h1:8HTsW17c5LMvrIUYn/ZKubdjLNMrsEArComp0nmfVy4= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= @@ -318,8 +320,6 @@ github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6 github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= -github.com/vansante/go-event-emitter v1.0.2 h1:Qh/B4aM2OKyWWqToiIgS9XCf5sR8/R6vAp/rOpSuwss= -github.com/vansante/go-event-emitter v1.0.2/go.mod h1:DC2i7ES4CtpdPHgm/BvbemeJKxKyAWSYpO24qdkqT/s= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/main.go b/main.go index 3d4465c..36e6511 100644 --- a/main.go +++ b/main.go @@ -6,12 +6,12 @@ import ( "github.com/gin-gonic/gin" socketio "github.com/googollee/go-socket.io" + eventemitter "github.com/hyperzlib/go-event-emitter" "github.com/hyperzlib/isekai-remote-playback/context" "github.com/hyperzlib/isekai-remote-playback/middleware" "github.com/hyperzlib/isekai-remote-playback/routes" "github.com/hyperzlib/isekai-remote-playback/store" "github.com/spf13/viper" - eventemitter "github.com/vansante/go-event-emitter" ) func initConfig() {