github.com/Azareal/Gosora@v0.0.0-20210729070923-553e66b59003/common/no_websockets.go (about)

     1  // +build no_ws
     2  
     3  package common
     4  
     5  import "errors"
     6  import "net/http"
     7  
     8  // TODO: Disable WebSockets on high load? Add a Control Panel interface for disabling it?
     9  var EnableWebsockets = false // Put this in caps for consistency with the other constants?
    10  
    11  var wsHub WSHub
    12  var errWsNouser = errors.New("This user isn't connected via WebSockets")
    13  
    14  type WSHub struct{}
    15  
    16  func (_ *WSHub) guestCount() int { return 0 }
    17  
    18  func (_ *WSHub) userCount() int { return 0 }
    19  
    20  func (hub *WSHub) broadcastMessage(_ string) error { return nil }
    21  
    22  func (hub *WSHub) pushMessage(_ int, _ string) error {
    23  	return errWsNouser
    24  }
    25  
    26  func (hub *WSHub) pushAlert(_ int, _ int, _ string, _ string, _ int, _ int, _ int) error {
    27  	return errWsNouser
    28  }
    29  
    30  func (hub *WSHub) pushAlerts(_ []int, _ int, _ string, _ string, _ int, _ int, _ int) error {
    31  	return errWsNouser
    32  }
    33  
    34  func RouteWebsockets(_ http.ResponseWriter, _ *http.Request, _ User) {}