dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 8a85857f8d4c0c794853ec0737664a5b197b838c
parent 07088ac5b1f944cd5ebae87e407c8fa45856c31e
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue,  5 Dec 2023 18:18:15 -0500

cleanup

Diffstat:
Mpkg/web/handlers/poker.go | 52+++++++++++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/pkg/web/handlers/poker.go b/pkg/web/handlers/poker.go @@ -760,30 +760,7 @@ func buildSeatsHtml(g *PokerGame) string { return seats } -func PokerHandler(c echo.Context) error { - roomID := c.Param("roomID") - g := PokerInstance.GetOrCreateGame(roomID) - - authUser := c.Get("authUser").(*database.User) - - send := func(s string) { - _, _ = c.Response().Write([]byte(s)) - } - - quit := hutils.CloseSignalChan(c) - roomTopic := "room_" + roomID - roomUserTopic := "room_" + roomID + "_" + authUser.Username.String() - - sub := PokerPubSub.Subscribe([]string{roomTopic, roomUserTopic}) - defer sub.Close() - - c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTMLCharsetUTF8) - c.Response().WriteHeader(http.StatusOK) - c.Response().Header().Set("Transfer-Encoding", "chunked") - c.Response().Header().Set("Connection", "keep-alive") - - send(cssReset) - send(`<style> +const pokerCss = `<style> html, body { height: 100%; width: 100%; } body { background:linear-gradient(135deg, #449144 33%,#008a00 95%); @@ -918,7 +895,32 @@ body { } } -</style>`) +</style>` + +func PokerHandler(c echo.Context) error { + roomID := c.Param("roomID") + g := PokerInstance.GetOrCreateGame(roomID) + + authUser := c.Get("authUser").(*database.User) + + send := func(s string) { + _, _ = c.Response().Write([]byte(s)) + } + + quit := hutils.CloseSignalChan(c) + roomTopic := "room_" + roomID + roomUserTopic := "room_" + roomID + "_" + authUser.Username.String() + + sub := PokerPubSub.Subscribe([]string{roomTopic, roomUserTopic}) + defer sub.Close() + + c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTMLCharsetUTF8) + c.Response().WriteHeader(http.StatusOK) + c.Response().Header().Set("Transfer-Encoding", "chunked") + c.Response().Header().Set("Connection", "keep-alive") + + send(cssReset) + send(pokerCss) drawCountDownStyle := func(evt PokerWaitTurnEvent) { send(`<style>#countdown1, #countdown2, #countdown3, #countdown4, #countdown5, #countdown6 { display: none; }</style>`)