|
@@ -51,8 +51,8 @@ func WsHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
// manage broadcasts and clients thru the broadcast package
|
|
// manage broadcasts and clients thru the broadcast package
|
|
|
- broadcast.RegisterClient(conn)
|
|
|
|
|
- defer broadcast.UnregisterClient(conn)
|
|
|
|
|
|
|
+ // broadcast.RegisterClient(conn)
|
|
|
|
|
+ // defer broadcast.UnregisterClient(conn)
|
|
|
// keepalive for ws
|
|
// keepalive for ws
|
|
|
conn.SetPongHandler(func(string) error {
|
|
conn.SetPongHandler(func(string) error {
|
|
|
conn.SetReadDeadline(time.Now().Add(60 * time.Second))
|
|
conn.SetReadDeadline(time.Now().Add(60 * time.Second))
|
|
@@ -185,17 +185,18 @@ func loginHandler(conn *websocket.Conn, msg []byte, payload structs.WsPayload) e
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// broadcast the unauth payload
|
|
// broadcast the unauth payload
|
|
|
func unauthHandler(conn *websocket.Conn, r *http.Request) {
|
|
func unauthHandler(conn *websocket.Conn, r *http.Request) {
|
|
|
blob := structs.UnauthBroadcast{
|
|
blob := structs.UnauthBroadcast{
|
|
|
- Type: "structure",
|
|
|
|
|
- AuthLevel: "unauthorized",
|
|
|
|
|
- Login: struct {
|
|
|
|
|
- Remainder int `json:"remainder"`
|
|
|
|
|
- }{
|
|
|
|
|
- Remainder: 0,
|
|
|
|
|
- },
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Type: "structure",
|
|
|
|
|
+ AuthLevel: "unauthorized",
|
|
|
|
|
+ Login: struct {
|
|
|
|
|
+ Remainder int `json:"remainder"`
|
|
|
|
|
+ }{
|
|
|
|
|
+ Remainder: 0,
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
resp, err := json.Marshal(blob)
|
|
resp, err := json.Marshal(blob)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
config.Logger.Error(fmt.Sprintf("Error unmarshalling message: %v", err))
|
|
config.Logger.Error(fmt.Sprintf("Error unmarshalling message: %v", err))
|