Documentation ¶
Index ¶
- Constants
- Variables
- type AccessToken
- type Privileges
- type Role
- type SimpleTokenBuilder
- func (builder *SimpleTokenBuilder) BuildToken() (string, error)
- func (builder *SimpleTokenBuilder) InitPrivileges(role Role, expireTimestamp uint32)
- func (builder *SimpleTokenBuilder) InitTokenBuilder(originToken string) bool
- func (builder *SimpleTokenBuilder) RemovePrivilege(privilege Privileges)
- func (builder *SimpleTokenBuilder) SetPrivilege(privilege Privileges, expireTimestamp uint32)
Constants ¶
View Source
const ( Role_Attendee = 1 Role_Publisher = 2 Role_Subscriber = 3 Role_Admin = 4 )
Roles
View Source
const ( KJoinChannel = 1 KPublishAudioStream = 2 KPublishVideoStream = 3 KPublishDataStream = 4 KPublishAudiocdn = 5 KPublishVideoCdn = 6 KRequestPublishAudioStream = 7 KRequestPublishVideoStream = 8 KRequestPublishDataStream = 9 KInvitePublishAudioStream = 10 KInvitePublishVideoStream = 11 KInvitePublishDataStream = 12 KAdministrateChannel = 101 )
View Source
const APP_ID_LENGTH = 32
View Source
const VERSION_LENGTH = 3
官方的 AccessToken文件
Variables ¶
View Source
var RolePrivileges = map[uint16](map[uint16]uint32){ Role_Attendee: attendeePrivileges, Role_Publisher: publisherPrivileges, Role_Subscriber: subscriberPrivileges, Role_Admin: adminPrivileges, }
RolePrivileges 角色权限
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken struct { AppID string AppCertificate string ChannelName string UidStr string Ts uint32 Salt uint32 Message map[uint16]uint32 Signature string CrcChannelName uint32 CrcUid uint32 MsgRawContent string }
func CreateAccessToken ¶
func CreateAccessToken(appID, appCertificate, channelName string, uid uint32) AccessToken
func (*AccessToken) AddPrivilege ¶
func (token *AccessToken) AddPrivilege(privilege Privileges, expireTimestamp uint32)
func (*AccessToken) Build ¶
func (token *AccessToken) Build() (string, error)
func (*AccessToken) FromString ¶
func (token *AccessToken) FromString(originToken string) bool
type Privileges ¶
type Privileges uint16
type SimpleTokenBuilder ¶
type SimpleTokenBuilder struct {
Token AccessToken
}
SimpleTokenBuilder
func CreateSimpleTokenBuilder ¶
func CreateSimpleTokenBuilder(appID, appCertificate, channelName string, uid uint32) SimpleTokenBuilder
func (*SimpleTokenBuilder) BuildToken ¶
func (builder *SimpleTokenBuilder) BuildToken() (string, error)
func (*SimpleTokenBuilder) InitPrivileges ¶
func (builder *SimpleTokenBuilder) InitPrivileges(role Role, expireTimestamp uint32)
InitPrivileges expireTimestamp 为0时长期有效
func (*SimpleTokenBuilder) InitTokenBuilder ¶
func (builder *SimpleTokenBuilder) InitTokenBuilder(originToken string) bool
func (*SimpleTokenBuilder) RemovePrivilege ¶
func (builder *SimpleTokenBuilder) RemovePrivilege(privilege Privileges)
func (*SimpleTokenBuilder) SetPrivilege ¶
func (builder *SimpleTokenBuilder) SetPrivilege(privilege Privileges, expireTimestamp uint32)
Click to show internal directories.
Click to hide internal directories.