Example #1
0
func acceptSockets(listener net.Listener) {
	for {
		conn, err := listener.Accept()
		if err != nil {
			log.Fatalf("Accept error: %s\n", err.Error())
		}
		s := gameserver.NewSession(dispatcher.GetNextSessionId(), gameserver.HeaderPacketSerializer{}, conn, dispatcher.GetReceiver())
		lobby.AddSession(s)
		go s.Run()
	}
}
Example #2
0
func handleWebsocketConn(ws *websocket.Conn) {
	ws.PayloadType = websocket.BinaryFrame
	s := gameserver.NewSession(dispatcher.GetNextSessionId(), gameserver.RawPacketSerializer{}, ws, dispatcher.GetReceiver())
	lobby.AddSession(s)
	s.Run()
}