mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 02:34:42 +00:00
Update latency
This commit is contained in:
parent
0bc8ce03f2
commit
1b39947541
3 changed files with 6 additions and 6 deletions
|
|
@ -72,7 +72,11 @@ func initializeWorker() {
|
|||
}
|
||||
|
||||
l.Close()
|
||||
http.Handle("/metrics", promhttp.Handler())
|
||||
if port == 9000 {
|
||||
// only turn on metric for the first worker to avoid overlap
|
||||
http.Handle("/metrics", promhttp.Handler())
|
||||
}
|
||||
|
||||
http.ListenAndServe(":"+strconv.Itoa(port), nil)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package cws
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
|
|
@ -158,10 +157,6 @@ func (c *Client) Listen() {
|
|||
}
|
||||
wspacket := WSPacket{}
|
||||
err = json.Unmarshal(rawMsg, &wspacket)
|
||||
fmt.Println(wspacket)
|
||||
if wspacket.ID == "checkLatency" {
|
||||
fmt.Println("!!!!!!")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -193,6 +193,7 @@ func (o *Server) findBestServerFromBrowser(client *BrowserClient) (string, error
|
|||
// TODO: Add timeout
|
||||
log.Println("Ping worker to get latency for ", client)
|
||||
latencies := o.getLatencyMapFromBrowser(client)
|
||||
log.Println("Latency map", latencies)
|
||||
|
||||
if len(latencies) == 0 {
|
||||
return "", errors.New("No server found")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue