Documentation ¶
Index ¶
- Constants
- Variables
- type Action
- type AuthInput
- type AuthResultOutput
- type Client
- func (c *Client) LogValue() slog.Value
- func (c *Client) SetPingPongHandler()
- func (c *Client) WriteAuthResult(ok bool, message string) error
- func (c *Client) WriteConnectResult(ok bool, hubID string) error
- func (c *Client) WriteManageNextMark(nextMarkNo int) error
- func (c *Client) WriteManageRaceStatus(started bool, startedAt time.Time, finishedAt time.Time) error
- func (c *Client) WriteMarkGeolocations() error
- func (c *Client) WriteParticipantsInfo() error
- type ClientEvent
- type ConnectResultOutput
- type Handler
- type Hub
- func (h *Hub) LogValue() slog.Value
- func (h *Hub) PublishManageNextMarkTask(ctx context.Context, targetTaskManagerID string, targetDeviceID string, ...) error
- func (h *Hub) PublishManageRaceStatusTask(ctx context.Context, started bool, startedAt time.Time, finishedAt time.Time) error
- func (h *Hub) Register(conn *websocket.Conn) *Client
- func (h *Hub) Unregister(c *Client)
- type ManageNextMarkInput
- type ManageNextMarkOutput
- type ManageNextMarkTaskMessage
- type ManageRaceStatusInput
- type ManageRaceStatusOutput
- type ManageRaceStatusTaskMessage
- type MarkGeolocationsOutput
- type MarkGeolocationsOutputMark
- type ParticipantsInfoOutput
- type ParticipantsInfoOutputAthlete
- type PassedMarkInput
- type PostGeolocationInput
- type ServerEvent
- type UnimplementedAction
- type UnimplementedClientEvent
- type UnimplementedHandler
- type UnimplementedServerEvent
Constants ¶
View Source
const ( TaskTypeManageRaceStatus = "manage_race_start" TaskTypeManageNextMark = "manage_next_mark" )
View Source
const ( HandlerTypeAuth = "auth" HandlerTypePostGeolocation = "post_geolocation" HandlerTypePassedMark = "passed_mark" HandlerTypeManageRaceStatus = "manage_race_status" HandlerTypeManageNextMark = "manage_next_mark" )
View Source
const ( ActionTypeConnectResult = "connect_result" ActionTypeAuthResult = "auth_result" ActionTypeMarkGeolocations = "mark_geolocations" ActionTypeParticipantsInfo = "participants_info" ActionTypeManageRaceStatus = "manage_race_status" ActionTypeManageNextMark = "manage_next_mark" AuthResultOK = "OK" AuthResultFailedAuthToken = "failed_auth_token" AuthResultOutsideAssociation = "outside_association" AuthResultInvalidDeviceID = "invalid_device_id" AuthResultInvalidWantMarkCounts = "invalid_want_mark_counts" )
Variables ¶
View Source
var Upgrader = websocket.Upgrader{ ReadBufferSize: 4096, WriteBufferSize: 4096, EnableCompression: true, CheckOrigin: func(r *http.Request) bool { return true }, }
WebSocketアップグレーダー: HTTP接続をWebSocket接続にアップグレードする設定
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface { ConnectResult( c *Client, ok bool, hubID string, ) (*ConnectResultOutput, error) AuthResult( c *Client, ok bool, message string, ) (*AuthResultOutput, error) MarkGeolocations( c *Client, ) (*MarkGeolocationsOutput, error) ParticipantsInfo( c *Client, ) (*ParticipantsInfoOutput, error) ManageRaceStatus( c *Client, started bool, startedAt time.Time, finishedAt time.Time, ) (*ManageRaceStatusOutput, error) ManageNextMark( c *Client, nextMarkNo int, ) (*ManageNextMarkOutput, error) }
type AuthResultOutput ¶
type Client ¶
type Client struct { ID string Hub *Hub Conn *websocket.Conn SendCh chan any StoppingWritePumpCh chan bool DeviceID string Role string MarkNo int WantMarkCounts int Authed bool }
func (*Client) SetPingPongHandler ¶
func (c *Client) SetPingPongHandler()
func (*Client) WriteConnectResult ¶
func (*Client) WriteManageNextMark ¶
func (*Client) WriteManageRaceStatus ¶
func (*Client) WriteMarkGeolocations ¶
func (*Client) WriteParticipantsInfo ¶
type ClientEvent ¶
type ConnectResultOutput ¶
type Handler ¶
type Handler interface { Auth(*Client, *AuthInput) PostGeolocation(*Client, *PostGeolocationInput) PassedMark(*Client, *PassedMarkInput) ManageRaceStatus(*Client, *ManageRaceStatusInput) ManageNextMark(*Client, *ManageNextMarkInput) }
type Hub ¶
type Hub struct { ID string AssociationID string Clients map[string]*Client Mu sync.RWMutex // contains filtered or unexported fields }
func NewHub ¶
func NewHub( associationID string, tm *taskmanager.Manager, clientEvent ClientEvent, serverEvent ServerEvent, handler Handler, action Action, ) *Hub
func (*Hub) PublishManageNextMarkTask ¶
func (*Hub) PublishManageRaceStatusTask ¶
func (*Hub) Unregister ¶
type ManageNextMarkInput ¶
type ManageNextMarkOutput ¶
type ManageRaceStatusInput ¶
type ManageRaceStatusOutput ¶
type MarkGeolocationsOutput ¶
type MarkGeolocationsOutput struct { MessageType string `json:"type"` MarkCounts int `json:"mark_counts"` Marks []MarkGeolocationsOutputMark `json:"marks"` }
type ParticipantsInfoOutput ¶
type ParticipantsInfoOutput struct { MessageType string `json:"type"` MarkCounts int `json:"mark_counts"` Marks []MarkGeolocationsOutputMark `json:"marks"` Athletes []ParticipantsInfoOutputAthlete `json:"athletes"` }
type ParticipantsInfoOutputAthlete ¶
type ParticipantsInfoOutputAthlete struct { DeviceID string `json:"device_id"` NextMarkNo int `json:"next_mark_no"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` AccuracyMeter float64 `json:"accuracy_meter"` Heading float64 `json:"heading"` RecordedAt time.Time `json:"recorded_at"` }
type PassedMarkInput ¶
type PostGeolocationInput ¶
type PostGeolocationInput struct { MessageType string `json:"type"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` AltitudeMeter float64 `json:"altitude_meter"` AccuracyMeter float64 `json:"accuracy_meter"` AltitudeAccuracyMeter float64 `json:"altitude_accuracy_meter"` Heading float64 `json:"heading"` SpeedMeterPerSec float64 `json:"speed_meter_per_sec"` RecordedAt time.Time `json:"recorded_at"` }
type ServerEvent ¶
type ServerEvent interface { ManageRaceStatusTaskReceived(*Hub, *ManageRaceStatusTaskMessage) ManageNextMarkTaskReceived(*Hub, *ManageNextMarkTaskMessage) }
type UnimplementedAction ¶
type UnimplementedAction struct{}
type UnimplementedClientEvent ¶
type UnimplementedClientEvent struct{}
type UnimplementedHandler ¶
type UnimplementedHandler struct{}
type UnimplementedServerEvent ¶
type UnimplementedServerEvent struct{}
Click to show internal directories.
Click to hide internal directories.