Draft: idk wtf was modified

This commit is contained in:
2025-10-16 05:04:26 +08:00
parent 85fa3dfe73
commit d55f333027
6 changed files with 19 additions and 11 deletions

View File

@@ -125,4 +125,4 @@ func (m *Game) Next(queue *[]*tea.Program) error {
tea.NewProgram(NewGame(m.Base, m.server, m.roomID)))
}
return nil
}
}

View File

@@ -37,7 +37,7 @@ func NewLobby(base *Base) *Lobby {
func (m *Lobby) fetchLobbyInfo() tea.Msg {
var users []models.UserStatus
resp, err := m.Base.client.R().
resp, err := m.Base.client.R().
SetResult(&users).
Get("/api/lobby/users")
if err != nil || resp.StatusCode() != http.StatusOK {

View File

@@ -87,4 +87,4 @@ func (m *RoomWaiting) Next(queue *[]*tea.Program) error {
*queue = append(*queue, tea.NewProgram(NewLobby(m.Base)))
}
return nil
}
}

View File

@@ -62,4 +62,4 @@ func (self *Handlers) GameFlow() {
}
}
}
}
}

View File

@@ -15,11 +15,11 @@ var (
)
type Room struct {
ID string `json:"id"`
Creater string `json:"creater"`
ID string `json:"id"`
Creater string `json:"creater"`
Status RoomStatus `json:"status"`
Players []string `json:"players"`
Addr string `json:"-"`
Players []string `json:"players"`
Addr string `json:"-"`
}
func (self Room) View() string {

View File

@@ -64,13 +64,21 @@ func ListenUDP(
func SendPayload(endpoint, data string) error {
conn, err := net.Dial("udp", endpoint)
if err != nil {
return fmt.Errorf("failed to dial endpoint")
return fmt.Errorf("failed to dial endpoint, %w", err)
}
defer conn.Close()
_, err = conn.Write([]byte(data))
b, err := msgpack.Marshal(UDPPayload{
MagicNumber: MAGIC_NUMBER,
Data: data,
})
if err != nil {
return fmt.Errorf("failed to send payload")
return fmt.Errorf("failed to marshal payload, %w", err)
}
_, err = conn.Write(b)
if err != nil {
return fmt.Errorf("failed to send payload, %w", err)
}
return nil