graph-rework
noah metz 2023-06-16 19:19:05 -06:00
parent 8e0bb14f40
commit 23fbdc74a0
3 changed files with 18 additions and 16 deletions

@ -310,7 +310,7 @@ func GQLWSHandler(schema graphql.Schema, ctx context.Context) func(http.Response
for {
// TODO: Make this a select between reading client data and getting updates from the event to push to clients"
msg_raw, op, err := wsutil.ReadClientData(conn)
log.Logf("gqlws", "MSG: %s\nOP: 0x%02x\nERR: %+v\n", string(msg_raw), op, err)
log.Logf("gqlws_hb", "MSG: %s\nOP: 0x%02x\nERR: %+v\n", string(msg_raw), op, err)
msg := GQLWSMsg{}
json.Unmarshal(msg_raw, &msg)
if err != nil {
@ -329,7 +329,7 @@ func GQLWSHandler(schema graphql.Schema, ctx context.Context) func(http.Response
break
}
} else if msg.Type == "ping" {
log.Logf("gqlws", "PING FROM %s", r.RemoteAddr)
log.Logf("gqlws_hb", "PING FROM %s", r.RemoteAddr)
err = wsutil.WriteServerMessage(conn, 1, []byte("{\"type\": \"pong\"}"))
if err != nil {
log.Logf("gqlws", "WS_SERVER_ERROR: FAILED TO SEND PONG")

@ -23,7 +23,7 @@ type DefaultLogger struct {
}
var log DefaultLogger = DefaultLogger{loggers: map[string]zerolog.Logger{}}
var all_components = []string{"update", "graph", "event", "resource", "manager", "test", "gql", "vex", "gqlws", "gqlws_new", "listeners"}
var all_components = []string{"update", "graph", "event", "resource", "manager", "test", "gql", "vex", "gqlws", "gqlws_new", "gqlws_hb", "listeners"}
func (logger * DefaultLogger) Init(components []string) error {
logger.init_lock.Lock()

@ -26,23 +26,25 @@ client.subscribe({
game_id = obj.Arenas[0].Owner.ID
client.subscribe({
query: "subscription($arena_id:String) { Arena(arena_id:$arena_id) { Owner { Name ... on Match { State Control StateStart StateDuration } } }}",
query: "subscription($arena_id:String) { Arena(arena_id:$arena_id) { Owner { ID Name ... on Match { State Control StateStart StateDuration } } }}",
variables: {
arena_id: arena_id
},
},
{
next: (data) => {
console.log("ARENA_SUB")
console.log(data)
},
error: (err) => {
console.log("ARENA_SUB")
console.log(err)
},
complete: () => {
},
});
{
next: (data) => {
console.log("ARENA_SUB")
let obj = JSON.parse(data.data)
console.log(obj.Arena)
game_id = obj.Arena.Owner.ID
},
error: (err) => {
console.log("ARENA_SUB")
console.log(err)
},
complete: () => {
},
});
},
error: (err) => {
console.log(err)