@@ -127,10 +127,14 @@ func wsHandler(w http.ResponseWriter, r *http.Request) {
127127 return
128128 }
129129
130+ if data .Type == common .CdPing {
131+ continue
132+ }
133+
130134 var joinData common.JoinData
131135 err = json .Unmarshal ([]byte (data .Message ), & joinData )
132136 if err != nil {
133- common .LogInfof ("[handler] Could not unmarshal join data %#v: %v\n " , data .Message , err )
137+ common .LogInfof ("[handler] Could not unmarshal websocket %d data %#v: %v\n " , data . Type , data .Message , err )
134138 continue
135139 }
136140
@@ -315,14 +319,6 @@ func handleEmoteTemplate(w http.ResponseWriter, r *http.Request) {
315319}
316320
317321func handleIndexTemplate (w http.ResponseWriter , r * http.Request ) {
318- if settings .RoomAccess != AccessOpen {
319- if ! checkRoomAccess (w , r ) {
320- common .LogDebugln ("Denied access" )
321- return
322- }
323- common .LogDebugln ("Granted access" )
324- }
325-
326322 type Data struct {
327323 Video , Chat bool
328324 MessageHistoryCount int
@@ -473,3 +469,16 @@ func handleDefault(w http.ResponseWriter, r *http.Request) {
473469 handleIndexTemplate (w , r )
474470 }
475471}
472+
473+ func wrapAuth (next http.HandlerFunc ) http.HandlerFunc {
474+ return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
475+ if settings .RoomAccess != AccessOpen {
476+ if ! checkRoomAccess (w , r ) {
477+ common .LogDebugln ("Denied access" )
478+ return
479+ }
480+ common .LogDebugln ("Granted access" )
481+ }
482+ next .ServeHTTP (w , r )
483+ })
484+ }
0 commit comments