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 { for {
// TODO: Make this a select between reading client data and getting updates from the event to push to clients" // 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) 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{} msg := GQLWSMsg{}
json.Unmarshal(msg_raw, &msg) json.Unmarshal(msg_raw, &msg)
if err != nil { if err != nil {
@ -329,7 +329,7 @@ func GQLWSHandler(schema graphql.Schema, ctx context.Context) func(http.Response
break break
} }
} else if msg.Type == "ping" { } 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\"}")) err = wsutil.WriteServerMessage(conn, 1, []byte("{\"type\": \"pong\"}"))
if err != nil { if err != nil {
log.Logf("gqlws", "WS_SERVER_ERROR: FAILED TO SEND PONG") 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 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 { func (logger * DefaultLogger) Init(components []string) error {
logger.init_lock.Lock() logger.init_lock.Lock()

@ -26,7 +26,7 @@ client.subscribe({
game_id = obj.Arenas[0].Owner.ID game_id = obj.Arenas[0].Owner.ID
client.subscribe({ 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: { variables: {
arena_id: arena_id arena_id: arena_id
}, },
@ -34,7 +34,9 @@ client.subscribe({
{ {
next: (data) => { next: (data) => {
console.log("ARENA_SUB") console.log("ARENA_SUB")
console.log(data) let obj = JSON.parse(data.data)
console.log(obj.Arena)
game_id = obj.Arena.Owner.ID
}, },
error: (err) => { error: (err) => {
console.log("ARENA_SUB") console.log("ARENA_SUB")