diff --git a/pkg/api/api.go b/pkg/api/api.go index 89d0628a..8b9a17c7 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -41,8 +41,8 @@ type ( type In[I Id] struct { Id I `json:"id,omitempty"` - T PT `json:"t"` Payload json.RawMessage `json:"p,omitempty"` // should be json.RawMessage for 2-pass unmarshal + T PT `json:"t"` } func (i In[I]) GetId() I { return i.Id } @@ -50,9 +50,9 @@ func (i In[I]) GetPayload() []byte { return i.Payload } func (i In[I]) GetType() PT { return i.T } type Out struct { + Payload any `json:"p,omitempty"` Id string `json:"id,omitempty"` // string because omitempty won't work as intended with arrays T uint8 `json:"t"` - Payload any `json:"p,omitempty"` } func (o *Out) SetId(s string) { o.Id = s } diff --git a/pkg/api/coordinator.go b/pkg/api/coordinator.go index 9cdf22b7..17f6737f 100644 --- a/pkg/api/coordinator.go +++ b/pkg/api/coordinator.go @@ -3,13 +3,13 @@ package api type ( CloseRoomRequest string ConnectionRequest[T Id] struct { - Addr string `json:"addr,omitempty"` Id T `json:"id,omitempty"` - IsHTTPS bool `json:"is_https,omitempty"` + Addr string `json:"addr,omitempty"` PingURL string `json:"ping_url,omitempty"` Port string `json:"port,omitempty"` Tag string `json:"tag,omitempty"` Zone string `json:"zone,omitempty"` + IsHTTPS bool `json:"is_https,omitempty"` } GetWorkerListResponse struct { Servers []Server `json:"servers"` @@ -28,15 +28,15 @@ const ( // Server is a separate machine that may contain // multiple sub-processes. type Server struct { - Addr string `json:"addr,omitempty"` Id Id `json:"id,omitempty"` - IsBusy bool `json:"is_busy,omitempty"` - InGroup bool `json:"in_group,omitempty"` + Addr string `json:"addr,omitempty"` Machine string `json:"machine,omitempty"` PingURL string `json:"ping_url"` Port string `json:"port,omitempty"` - Replicas uint32 `json:"replicas,omitempty"` Room string `json:"room,omitempty"` Tag string `json:"tag,omitempty"` Zone string `json:"zone,omitempty"` + Replicas uint32 `json:"replicas,omitempty"` + IsBusy bool `json:"is_busy,omitempty"` + InGroup bool `json:"in_group,omitempty"` } diff --git a/pkg/api/user.go b/pkg/api/user.go index e487b93c..2ce4fde4 100644 --- a/pkg/api/user.go +++ b/pkg/api/user.go @@ -7,13 +7,13 @@ type ( GameStartUserRequest struct { GameName string `json:"game_name"` RoomId string `json:"room_id"` - Record bool `json:"record,omitempty"` RecordUser string `json:"record_user,omitempty"` PlayerIndex int `json:"player_index"` + Record bool `json:"record,omitempty"` } GameStartUserResponse struct { - RoomId string `json:"roomId"` Av *AppVideoInfo `json:"av"` + RoomId string `json:"roomId"` KbMouse bool `json:"kb_mouse"` } IceServer struct { @@ -22,9 +22,9 @@ type ( Credential string `json:"credential,omitempty"` } InitSessionUserResponse struct { + Wid string `json:"wid"` Ice []IceServer `json:"ice"` Games []AppMeta `json:"games"` - Wid string `json:"wid"` } AppMeta struct { Alias string `json:"alias,omitempty"` @@ -36,7 +36,7 @@ type ( Sdp *string `json:"sdp,omitempty"` } InitUserWebrtcStreamRequest struct { - Initiator bool `json:"initiator"` Sdp string `json:"sdp,omitempty"` + Initiator bool `json:"initiator"` } )