From e356f992006d63df2d28a0a9ecdc7fcb10756c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20L=C3=B6fgren?= Date: Thu, 21 Dec 2023 21:47:24 +0100 Subject: [PATCH] server: respond with success if extension goes to start page --- wikiweaver-server/cmd/main/wikiweaver-server.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/wikiweaver-server/cmd/main/wikiweaver-server.go b/wikiweaver-server/cmd/main/wikiweaver-server.go index 7e53841..063dba3 100644 --- a/wikiweaver-server/cmd/main/wikiweaver-server.go +++ b/wikiweaver-server/cmd/main/wikiweaver-server.go @@ -867,6 +867,16 @@ func handleExtPage(w http.ResponseWriter, r *http.Request) { return } + if lobby.StartPage == pageFromExtMessage.Page && extClient.Page == pageFromExtMessage.Page { + log.Printf("extension %s went to start page, responding with success", r.RemoteAddr) + successResponse := PageToExtResponse{ + Success: true, + } + SendResponseToExt(w, successResponse) + extClient.mu.Unlock() + return + } + if extClient.Page != pageFromExtMessage.Previous { log.Printf("refusing to forward page from %s to lobby %s: previous page mismatch: server thinks %s while extension thinks %s", r.RemoteAddr, code, extClient.Page, pageFromExtMessage.Previous) SendResponseToExt(w, failResponse) @@ -912,6 +922,10 @@ func handleExtPage(w http.ResponseWriter, r *http.Request) { lobby.History = append(lobby.History, pageToWebMessage) lobby.mu.Unlock() + log.Printf("extension %s sent page: %+v", r.RemoteAddr, pageFromExtMessage) + + log.Printf("forwarding page to %d web clients: %+v", len(lobby.WebClients), pageToWebMessage) + lobby.Broadcast(pageToWebMessage) successResponse := PageToExtResponse{