make it compile

This commit is contained in:
Iris Lightshard 2023-02-12 06:55:57 -07:00
parent cd14def1f8
commit 6fc78c333c
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398

View file

@ -1,14 +1,16 @@
package gametable package gametable
import ( import (
"bytes"
"context" "context"
"encoding/json"
"errors" "errors"
"fmt"
"golang.org/x/time/rate" "golang.org/x/time/rate"
"hacklab.nilfm.cc/felt/admin" "hacklab.nilfm.cc/felt/admin"
"hacklab.nilfm.cc/felt/models" "hacklab.nilfm.cc/felt/models"
"hacklab.nilfm.cc/felt/mongodb" "hacklab.nilfm.cc/felt/mongodb"
"hacklab.nilfm.cc/quartzgun/auth" "hacklab.nilfm.cc/quartzgun/auth"
"hacklab.nilfm.cc/quartzgun/cookie"
"hacklab.nilfm.cc/quartzgun/renderer" "hacklab.nilfm.cc/quartzgun/renderer"
"io/ioutil" "io/ioutil"
"log" "log"
@ -90,7 +92,7 @@ func (self *GameTableServer) subscribe(r *http.Request, c *websocket.Conn) error
err := json.NewDecoder(r.Body).Decode(&tableKey) err := json.NewDecoder(r.Body).Decode(&tableKey)
if err != nil { if err != nil {
fmt.Println(err.Error()) fmt.Println(err.Error())
return return err
} }
if !self.dbAdapter.CheckTable(tableKey) { if !self.dbAdapter.CheckTable(tableKey) {
@ -142,7 +144,7 @@ func (self *GameTableServer) publish(msg []byte) {
// decode message and store in DB // decode message and store in DB
tableMsg := models.TableMessage{} tableMsg := models.TableMessage{}
err := json.NewDecoder(msg).Decode(&tableMsg) err := json.NewDecoder(bytes.NewReader(msg)).Decode(&tableMsg)
if err != nil { if err != nil {
fmt.Println(err.Error()) fmt.Println(err.Error())
return return
@ -153,7 +155,7 @@ func (self *GameTableServer) publish(msg []byte) {
self.publishLimiter.Wait(context.Background()) self.publishLimiter.Wait(context.Background())
for s, k := range self.subscribers { for s, k := range self.subscribers {
if k == tableMsg.tableKey { if k == tableMsg.Key {
select { select {
case s.msgs <- msg: case s.msgs <- msg:
default: default:
@ -163,12 +165,12 @@ func (self *GameTableServer) publish(msg []byte) {
} }
} }
func (self *GameTableServer) getCurrentState(tableKey models.TableKey) ([]byte, error) { func (self *GameTableServer) getCurrentState(tableKey models.TableKey) ([]byte) {
// get diceroll log, map, and token state // get diceroll log, map, and token state
// build into a []byte message // build into a []byte message
return make([]byte, 1), nil return make([]byte, 1)
} }
func (self *GameTableServer) writeToDB(tableMsg models.TableMessage) error { func (self *GameTableServer) writeToDB(tableMsg models.TableMessage) error {