mirror of https://github.com/Askill/r_place.git
clean up
This commit is contained in:
parent
fd7bd1c0e1
commit
ee6d416611
15
go/server.go
15
go/server.go
|
|
@ -8,7 +8,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -24,20 +23,6 @@ var upgrader = websocket.Upgrader{
|
||||||
WriteBufferSize: 2048,
|
WriteBufferSize: 2048,
|
||||||
}
|
}
|
||||||
|
|
||||||
type Pixel struct {
|
|
||||||
X uint16 `json:"x"`
|
|
||||||
Y uint16 `json:"y"`
|
|
||||||
Color uint8 `json:"color"`
|
|
||||||
Timestamp int64 `json:"timestamp"`
|
|
||||||
UserID uint64 `json:"userid"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func JsonToStruct(input []byte) Pixel {
|
|
||||||
pixel := Pixel{}
|
|
||||||
json.Unmarshal(input, &pixel)
|
|
||||||
return pixel
|
|
||||||
}
|
|
||||||
|
|
||||||
func serve(w http.ResponseWriter, r *http.Request) {
|
func serve(w http.ResponseWriter, r *http.Request) {
|
||||||
c, err := upgrader.Upgrade(w, r, nil)
|
c, err := upgrader.Upgrade(w, r, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ type Pixel struct {
|
||||||
X uint16 `json:"x"`
|
X uint16 `json:"x"`
|
||||||
Y uint16 `json:"y"`
|
Y uint16 `json:"y"`
|
||||||
Color uint8 `json:"color"`
|
Color uint8 `json:"color"`
|
||||||
Timestamp uint64 `json:"timestamp"`
|
Timestamp int64 `json:"timestamp"`
|
||||||
UserID uint64 `json:"userid"`
|
UserID uint64 `json:"userid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue