mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-21 09:08:57 +00:00
* Merge HTTP and HTTPS routes builder in coordinator * Extract HTTP/S routes * Rename config in coordinator * Generalize child services * Extract games library helper function * Use string address instead of port for HTTP/S * Use a dedicated port extractor function * Add missing GA tag templating * Rename shared server address and port params * Introduce TLS config parameters * Simplify HTTP/S server constructors * Update server auto port roll * Extract init function in worker * Reorder return params of address type port fn * Refactor config handler names * Update TLS default config params * Extract HTTP to HTTPS redirect function * Use httpx in monitoring * Don't log echo requests * Remove error return from the abstract server * Add WSS option to the worker-coordinator connection * Change default worker config * Make worker send its internal connection params * Decouple gamelib from the coordinator * Expose HTTP/S listener address * Keep original HTTP/S addresses * Remove no config handler in worker * Use HTTP-HTTPS redirection * Wrap net.Listener into a struct * Clean http server creation fn * Redirect to https with a generated address * Use URL in the redirector * Use zone address param in worker * Make use of actual addr and port in the monitoring servers * Use auto-justified monitoring addresses info * Add the non-HTTPS worker to HTTPS coordinator connection warning * Embed TLS struct * Move connection API struct into cws package
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
package api
|
|
|
|
import "github.com/giongto35/cloud-game/v2/pkg/cws"
|
|
|
|
const (
|
|
GetRoom = "get_room"
|
|
CloseRoom = "close_room"
|
|
RegisterRoom = "register_room"
|
|
Heartbeat = "heartbeat"
|
|
IceCandidate = "ice_candidate"
|
|
|
|
NoData = ""
|
|
|
|
InitWebrtc = "init_webrtc"
|
|
Answer = "answer"
|
|
|
|
GameStart = "start"
|
|
GameQuit = "quit"
|
|
GameSave = "save"
|
|
GameLoad = "load"
|
|
GamePlayerSelect = "player_index"
|
|
GameMultitap = "multitap"
|
|
)
|
|
|
|
type GameStartRequest struct {
|
|
GameName string `json:"game_name"`
|
|
}
|
|
|
|
func (packet *GameStartRequest) From(data string) error { return from(packet, data) }
|
|
|
|
type GameStartCall struct {
|
|
Name string `json:"name"`
|
|
Path string `json:"path"`
|
|
Type string `json:"type"`
|
|
}
|
|
|
|
func (packet *GameStartCall) From(data string) error { return from(packet, data) }
|
|
func (packet *GameStartCall) To() (string, error) { return to(packet) }
|
|
|
|
type ConnectionRequest struct {
|
|
Zone string `json:"zone,omitempty"`
|
|
PingAddr string `json:"ping_addr,omitempty"`
|
|
IsHTTPS bool `json:"is_https,omitempty"`
|
|
}
|
|
|
|
// packets
|
|
|
|
func RegisterRoomPacket(data string) cws.WSPacket { return cws.WSPacket{ID: RegisterRoom, Data: data} }
|
|
func GetRoomPacket(data string) cws.WSPacket { return cws.WSPacket{ID: GetRoom, Data: data} }
|
|
func CloseRoomPacket(data string) cws.WSPacket { return cws.WSPacket{ID: CloseRoom, Data: data} }
|
|
func IceCandidatePacket(data string, sessionId string) cws.WSPacket {
|
|
return cws.WSPacket{ID: IceCandidate, Data: data, SessionID: sessionId}
|
|
}
|