Thomas van Weert
9edcb83fc4
CHG: use concurrent map instead of regular map with lock DEL: global session control, moved to per server only DEL: unused command system
41 lines
772 B
Go
Executable file
41 lines
772 B
Go
Executable file
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)
|
|
return
|
|
} else {
|
|
_ = so.Close()
|
|
if debug {
|
|
log.Println("invalid client type:", clientType)
|
|
}
|
|
}
|
|
})
|
|
|
|
namespace.OnDisconnect(func(so socketio.Socket) {
|
|
clientType := so.GetQuery().Get("type")
|
|
if clientType == "server" {
|
|
serverQuit(so)
|
|
} else if clientType == "client" {
|
|
clientQuit(so)
|
|
}
|
|
})
|
|
|
|
namespace.OnError(func(so socketio.Socket, err ...interface{}) {
|
|
fmt.Println(err)
|
|
})
|
|
}
|