Skip to content

Commit

Permalink
make it explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
LdDl committed Sep 16, 2024
1 parent 66f265b commit 36c14e0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ws_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
// wshandler is a websocket handler for user connection
func wshandler(wsUpgrader *websocket.Upgrader, w http.ResponseWriter, r *http.Request, app *Application, verboseLevel VerboseLevel) {
var streamID, clientID uuid.UUID
var mseExists bool
var mseExists, clientAdded bool

streamIDSTR := r.FormValue("stream_id")
if verboseLevel > VERBOSE_SIMPLE {
Expand All @@ -39,7 +39,7 @@ func wshandler(wsUpgrader *websocket.Upgrader, w http.ResponseWriter, r *http.Re
if verboseLevel > VERBOSE_SIMPLE {
log.Info().Str("scope", SCOPE_WS_HANDLER).Str("event", EVENT_WS_UPGRADER).Str("remote_addr", r.RemoteAddr).Msg("Connection has been closed")
}
if mseExists {
if mseExists && clientAdded {
app.Streams.DeleteViewer(streamID, clientID)
if verboseLevel > VERBOSE_SIMPLE {
log.Info().Str("scope", SCOPE_WS_HANDLER).Str("event", EVENT_WS_UPGRADER).Str("remote_addr", r.RemoteAddr).Str("stream_id", streamIDSTR).Str("client_id", clientID.String()).Msg("Client has been removed")
Expand Down Expand Up @@ -80,6 +80,7 @@ func wshandler(wsUpgrader *websocket.Upgrader, w http.ResponseWriter, r *http.Re
closeWSwithError(conn, 1011, errReason)
return
}
clientAdded = true
if verboseLevel > VERBOSE_SIMPLE {
log.Info().Str("scope", SCOPE_WS_HANDLER).Str("event", EVENT_WS_UPGRADER).Str("remote_addr", r.RemoteAddr).Str("stream_id", streamIDSTR).Str("client_id", clientID.String()).Msg("Client has been added")
}
Expand Down

0 comments on commit 36c14e0

Please sign in to comment.