mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-22 09:37:09 +00:00
(experimental feature) Before a worker can start, it should have a configuration file. In case if such a file is not found it may request configuration from the coordinator to which it connected. Added example logic if a worker is needed to be blocked until a successful packet exchange with a coordinator is being made. * Add error return for config loader * Add config loaded flag to worker * Add zone flag * Add a custom mutex lock with timout * Refactor worker runtime * Refactor internal api * Extract monitoring server config * Extract worker HTTP(S) server * Add generic sub-server interface * Add internal coordinator API * Add internal routes and handlers to worker * Add internal worker API * Refactor worker run * Migrate serverId call to new API * Add packet handler to cws * Extract handlers for internal worker routes in coordinator * Pass worker to the worker internal heandlers * Cleanup worker handlers in coordinator * Add closeRoom packet handler to the API * Add GetRoom packet handler to the API * Add RegisterRoom packet handler to the API * Add IceCandidate packet handler to the API (internal and browser) * Add Heartbeat packet handler to the API (internal and browser) * Rename worker routes init function * Extract worker/coordinator internal ws handlers * Update timed locker * Allow sequential timed locks * Add config request from workers * Add nil check for the route registration functions
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
package coordinator
|
|
|
|
import "github.com/giongto35/cloud-game/v2/pkg/cws/api"
|
|
|
|
// workerRoutes adds all worker request routes.
|
|
func (o *Server) workerRoutes(wc *WorkerClient) {
|
|
if wc == nil {
|
|
return
|
|
}
|
|
wc.Receive(api.ConfigRequest, wc.handleConfigRequest())
|
|
wc.Receive(api.Heartbeat, wc.handleHeartbeat())
|
|
wc.Receive(api.RegisterRoom, wc.handleRegisterRoom(o))
|
|
wc.Receive(api.GetRoom, wc.handleGetRoom(o))
|
|
wc.Receive(api.CloseRoom, wc.handleCloseRoom(o))
|
|
wc.Receive(api.IceCandidate, wc.handleIceCandidate(o))
|
|
}
|
|
|
|
// useragentRoutes adds all useragent (browser) request routes.
|
|
func (o *Server) useragentRoutes(bc *BrowserClient) {
|
|
if bc == nil {
|
|
return
|
|
}
|
|
bc.Receive(api.Heartbeat, bc.handleHeartbeat())
|
|
bc.Receive(api.InitWebrtc, bc.handleInitWebrtc(o))
|
|
bc.Receive(api.Answer, bc.handleAnswer(o))
|
|
bc.Receive(api.IceCandidate, bc.handleIceCandidate(o))
|
|
bc.Receive(api.GameStart, bc.handleGameStart(o))
|
|
bc.Receive(api.GameQuit, bc.handleGameQuit(o))
|
|
bc.Receive(api.GameSave, bc.handleGameSave(o))
|
|
bc.Receive(api.GameLoad, bc.handleGameLoad(o))
|
|
bc.Receive(api.GamePlayerSelect, bc.handleGamePlayerSelect(o))
|
|
bc.Receive(api.GameMultitap, bc.handleGameMultitap(o))
|
|
}
|