You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SocketController struct {
|
|
|
|
basePath string
|
|
|
|
sockets *socketio.Server
|
|
|
|
events *eventemitter.Emitter
|
|
|
|
context *context.ServerContext
|
|
|
|
storeModel *store.StoreModel
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetContext[T interface{}](socket socketio.Conn) *T {
|
|
|
|
ctx, ok := socket.Context().(*T)
|
|
|
|
if !ok {
|
|
|
|
ctx = new(T)
|
|
|
|
socket.SetContext(ctx)
|
|
|
|
}
|
|
|
|
return ctx
|
|
|
|
}
|