Fix: minor bugfix
This commit is contained in:
@@ -3,6 +3,7 @@ package stages
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -117,6 +118,9 @@ type clientScanMsg time.Time
|
|||||||
func (m *LobbyModel) clientScan() tea.Cmd {
|
func (m *LobbyModel) clientScan() tea.Cmd {
|
||||||
return tea.Tick(REFRESH_TIME, func(t time.Time) tea.Msg {
|
return tea.Tick(REFRESH_TIME, func(t time.Time) tea.Msg {
|
||||||
m.endpoints, m.err = utils.Ping(viper.GetStringSlice("udp-endpoints"))
|
m.endpoints, m.err = utils.Ping(viper.GetStringSlice("udp-endpoints"))
|
||||||
|
sort.Slice(m.endpoints, func(i, j int) bool {
|
||||||
|
return m.endpoints[i] < m.endpoints[j]
|
||||||
|
})
|
||||||
return clientScanMsg(t)
|
return clientScanMsg(t)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -199,6 +203,7 @@ func (m *LobbyModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
case "N", "n":
|
case "N", "n":
|
||||||
m.op = lobbyOperationServerWaiting
|
m.op = lobbyOperationServerWaiting
|
||||||
cmds = append(cmds, m.serverSendReply(false))
|
cmds = append(cmds, m.serverSendReply(false))
|
||||||
|
cmds = append(cmds, m.serverListen())
|
||||||
}
|
}
|
||||||
case serverSendReplyMsg:
|
case serverSendReplyMsg:
|
||||||
if m.err == nil {
|
if m.err == nil {
|
||||||
@@ -225,6 +230,7 @@ func (m *LobbyModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
} else {
|
} else {
|
||||||
m.op = lobbyOperationServerWaiting
|
m.op = lobbyOperationServerWaiting
|
||||||
|
cmds = append(cmds, m.serverListen())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case lobbyOperationClientScannning:
|
case lobbyOperationClientScannning:
|
||||||
|
|||||||
Reference in New Issue
Block a user