You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
548 B
26 lines
548 B
package auth
|
|
|
|
import "encoding/json"
|
|
|
|
type WebSocketV1AuthenticationResponse struct {
|
|
Op string `json:"op"`
|
|
Timestamp int64 `json:"ts"`
|
|
ErrorCode int `json:"err-code"`
|
|
Data *struct {
|
|
UserId int `json:"user-id"`
|
|
}
|
|
}
|
|
|
|
func (p *WebSocketV1AuthenticationResponse) IsAuth() bool {
|
|
return p.Op == "auth"
|
|
}
|
|
|
|
func ParseWSV1AuthResp(message string) *WebSocketV1AuthenticationResponse {
|
|
result := &WebSocketV1AuthenticationResponse{}
|
|
err := json.Unmarshal([]byte(message), result)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
|
|
return result
|
|
}
|
|
|