本文整理汇总了Golang中github.com/TF2Stadium/wsevent.Client.Token方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.Token方法的具体用法?Golang Client.Token怎么用?Golang Client.Token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/TF2Stadium/wsevent.Client
的用法示例。
在下文中一共展示了Client.Token方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SocketHandler
func SocketHandler(w http.ResponseWriter, r *http.Request) {
token, err := chelpers.GetToken(r)
if err != nil && err != http.ErrNoCookie { //invalid jwt token
logrus.Errorf("Error reading JWT: %v", err)
token = nil
}
//check if player is in the whitelist
if config.Constants.SteamIDWhitelist != "" {
if token == nil {
// player isn't logged in,
// and access is restricted to logged in people
http.Error(w, "Not logged in", http.StatusForbidden)
return
}
if !chelpers.IsSteamIDWhitelisted(token.Claims.(*chelpers.TF2StadiumClaims).SteamID) {
http.Error(w, "you're not in the beta", http.StatusForbidden)
return
}
}
var so *wsevent.Client
if token != nil { //received valid jwt
so, err = socket.AuthServer.NewClient(upgrader, w, r)
} else {
so, err = socket.UnauthServer.NewClient(upgrader, w, r)
}
if err != nil {
return
}
so.Token = token
//logrus.Debug("Connected to Socket")
err = SocketInit(so)
if err != nil {
logrus.Error(err)
so.Close()
return
}
}