state.go 844 B

12345678910111213141516171819202122232425262728293031
  1. package server
  2. import (
  3. "github.com/gorilla/websocket"
  4. )
  5. type Client struct {
  6. name string
  7. conn *websocket.Conn
  8. disconnected chan bool
  9. }
  10. // This state lives on the server and is common to all clients.
  11. // It describes the state of the music player, including who is currently
  12. // responsible for playing the sound.
  13. // Only one client is allowed to play the music at any one time (this could change later).
  14. // Each client should have a fairly up-to-date (~2s) copy of this state, in order to
  15. // accurately reflect the current state to the frontend.
  16. type MusicPlayer struct {
  17. SongId int `json:"songId"`
  18. Playing bool `json:"playing"`
  19. PlayTimeSeconds int `json:"playTimeSeconds"`
  20. CurrentClient string `json:"currentClient"`
  21. }
  22. type action struct {
  23. ActionType string `json:"type"`
  24. Payload interface{} `json:"payload"`
  25. }