本文整理匯總了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
}
}