package user
import (
"fmt"
"github.com/Mindgamesnl/socketio"
"log"
)
var debug bool
func Load(namespace socketio.Namespace, b bool) {
debug = b
namespace.OnConnect(func(so socketio.Socket) {
clientType := so.GetQuery().Get("type")
if clientType == "server" {
serverLogin(so)
return
} else if clientType == "client" {
clientLogin(so)
} else {
_ = so.Close()
if debug {
log.Println("invalid client type:", clientType)
}
})
namespace.OnDisconnect(func(so socketio.Socket) {
serverQuit(so)
clientQuit(so)
namespace.OnError(func(so socketio.Socket, err ...interface{}) {
fmt.Println(err)