lipre

Stream text files for live (coding) representations
Log | Files | Refs

commit ae84c484e0a70ea5361093356e1b132663b9df60
parent 6f56ddcdf92a49b2f112d59713d1980aed7f86f6
Author: Vetle Haflan <vetle@haflan.dev>
Date:   Fri, 29 Jan 2021 01:05:15 +0100

Fix it - I think everything works as intended now

Diffstat:
Mlipre.go | 16++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lipre.go b/lipre.go @@ -45,13 +45,7 @@ func (room *Room) open() { } rooms[room.code] = room room.presenter.SetCloseHandler(func(code int, text string) error { - fmt.Printf("Closing room '%v'", room.code) - for _, viewer := range room.viewers { - if viewer != nil { - viewer.Close() - } - } - delete(rooms, room.code) + room.close() return nil }) go room.listen() @@ -61,7 +55,14 @@ func (room *Room) close() { room.mu.Lock() defer room.mu.Unlock() // The actual room close code is handled in the presenter connection close handler + fmt.Printf("Closing room '%v'\n", room.code) + for _, viewer := range room.viewers { + if viewer != nil { + viewer.Close() + } + } room.presenter.Close() + delete(rooms, room.code) } func (room *Room) addViewer(viewerConn *websocket.Conn) { @@ -82,7 +83,6 @@ func (room *Room) listen() { if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure, websocket.CloseAbnormalClosure) { log.Printf("Unexpected close error: %v", err) } - room.close() // TODO: Handle JSON errors (send info to presenter) return }