state.go 742 B

1234567891011121314151617181920212223242526
  1. package server
  2. import (
  3. "github.com/gorilla/websocket"
  4. )
  5. type Client struct {
  6. name string
  7. conn *websocket.Conn
  8. closeChan 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. }