func authenticateRoom(connClaims *claims, keyFunc jwt.Keyfunc, msg proto.Authenticatable) error {
	log.Debugf("authenticateRoom: checking claims on token %v", msg.Token())
	// connection token has valid claim on this room, succeed early
	if connClaims != nil && msg.Room() == proto.SID(connClaims.SID) {
		log.Debugf("authenticateRoom: valid sid in connection claims %v", msg.Room())
		return nil
	}

	// check for a message level proto.RoomToken
	var msgClaims *claims = nil
	if t := msg.Token(); t != "" {
		token, err := jwt.ParseWithClaims(t, &claims{}, keyFunc)
		if err != nil {
			log.Debugf("authenticateRoom: error parsing token: %v", err)
			return errors.New("invalid room token")
		}
		log.Debugf("authenticateRoom: Got Token %#v", token)
		msgClaims = token.Claims.(*claims)
	}

	// no tokens were passed in
	if connClaims == nil && msgClaims == nil {
		return errors.New("authorization token required for access")
	}

	// message token is valid, succeed
	if msgClaims != nil && msg.Room() == proto.SID(msgClaims.SID) {
		log.Debugf("authenticateRoom: valid sid in msg claims %v", msg.Room())
		return nil
	}

	// if this is reached, a token was passed but it did not have a valid SID claim
	return errors.New("permission not sufficient for room")
}
// authenticateRoom checks both the connection token AND an optional message token for SID claims
// returns nil for success and returns an error if there are no valid claims for the SID
authenticateRoom checks both the connection token AND an optional message token for SID claims
returns nil for success and returns an error if there are no valid claims for the SID
// authenticateRoom checks both the connection token AND an optional message token for SID claims // returns nil for success and returns an error if there are no valid claims for the SID
func authenticateRoom(connClaims *claims, keyFunc jwt.Keyfunc, msg proto.Authenticatable) error {
	log.Debugf("authenticateRoom: checking claims on token %v", msg.Token())
	if connClaims != nil && msg.Room() == proto.SID(connClaims.SID) {
		log.Debugf("authenticateRoom: valid sid in connection claims %v", msg.Room())
		return nil
	}
	var msgClaims *claims = nil
	if t := msg.Token(); t != "" {
		token, err := jwt.ParseWithClaims(t, &claims{}, keyFunc)
		if err != nil {
			log.Debugf("authenticateRoom: error parsing token: %v", err)
			return errors.New("invalid room token")
		}
		log.Debugf("authenticateRoom: Got Token %#v", token)
		msgClaims = token.Claims.(*claims)
	}
	if connClaims == nil && msgClaims == nil {
		return errors.New("authorization token required for access")
	}
	if msgClaims != nil && msg.Room() == proto.SID(msgClaims.SID) {
		log.Debugf("authenticateRoom: valid sid in msg claims %v", msg.Room())
		return nil
	}
	return errors.New("permission not sufficient for room")
}
func authenticateRoom ( connClaims * claims , keyFunc jwt . Keyfunc , msg proto . Authenticatable ) error { log . Debugf ( " " , msg . Token ( ) ) if connClaims != nil && msg . Room ( ) == proto . SID ( connClaims . SID ) { log . Debugf ( " " , msg . Room ( ) ) return nil } var msgClaims * claims = nil if t := msg . Token ( ) ; t != " " { token , err := jwt . ParseWithClaims ( t , & claims { } , keyFunc ) if err != nil { log . Debugf ( " " , err ) return errors . New ( " " ) } log . Debugf ( " " , token ) msgClaims = token . Claims . ( * claims ) } if connClaims == nil && msgClaims == nil { return errors . New ( " " ) } if msgClaims != nil && msg . Room ( ) == proto . SID ( msgClaims . SID ) { log . Debugf ( " " , msg . Room ( ) ) return nil } return errors . New ( " " ) }
authenticateRoom checks both the connection token AND an optional message token for SID claims
returns nil for success and returns an error if there are no valid claims for the SID
authenticateRoom checks both the connection token AND an optional message token for SID claims returns nil for success and returns an error if there are no valid claims for the SID
// connection token has valid claim on this room, succeed early // check for a message level proto.RoomToken // no tokens were passed in // message token is valid, succeed // if this is reached, a token was passed but it did not have a valid SID claim