agora

package module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2022 License: MIT Imports: 13 Imported by: 0

README

agora

Go client to Agora Rest api and token generation api

Documentation

Index

Constants

View Source
const AppIdLength = 32
View Source
const VersionLength = 3

Variables

This section is empty.

Functions

func BuildRTCTokenWithUID

func BuildRTCTokenWithUID(appID string, appCertificate string, channelName string, uid string, role RTCRole, privilegeExpiredTs time.Time) (string, error)

BuildRTCTokenWithUID method appID: The App ID issued to you by Agora. Apply for a new App ID from

Agora Dashboard if it is missing from your kit. See Get an App ID.

appCertificate: Certificate of the application that you registered in

the Agora Dashboard. See Get an App Certificate.

channelName:Unique channel name for the AgoraRTC session in the string format userAccount: The user account. role: Role_Publisher = 1: A broadcaster (host) in a live-broadcast profile.

Role_Subscriber = 2: (Default) A audience in a live-broadcast profile.

privilegeExpireTs: represented by the number of seconds elapsed since

1/1/1970. If, for example, you want to access the
Agora Service within 10 minutes after the token is
generated, set expireTimestamp as the current

func BuildRTCTokenWithUserAccount

func BuildRTCTokenWithUserAccount(appID string, appCertificate string, channelName string, userAccount string, role RTCRole, privilegeExpiredTs time.Time) (string, error)

BuildRTCTokenWithUserAccount method appID: The App ID issued to you by Agora. Apply for a new App ID from

Agora Dashboard if it is missing from your kit. See Get an App ID.

appCertificate: Certificate of the application that you registered in

the Agora Dashboard. See Get an App Certificate.

channelName:Unique channel name for the AgoraRTC session in the string format uid: User ID. A 32-bit unsigned integer with a value ranging from

1 to (232-1). optionalUid must be unique.

role: Role_Publisher = 1: A broadcaster (host) in a live-broadcast profile.

Role_Subscriber = 2: (Default) A audience in a live-broadcast profile.

privilegeExpireTs: represented by the number of seconds elapsed since

1/1/1970. If, for example, you want to access the
Agora Service within 10 minutes after the token is
generated, set expireTimestamp as the current
timestamp + 600 (seconds)./

func BuildRTMToken

func BuildRTMToken(appID string, appCertificate string, userAccount string, privilegeExpiredTs time.Time) (string, error)

BuildRTMToken method appID: The App ID issued to you by Agora. Apply for a new App ID from

Agora Dashboard if it is missing from your kit. See Get an App ID.

appCertificate: Certificate of the application that you registered in

the Agora Dashboard. See Get an App Certificate.

userAccount: The user account. privilegeExpireTs: represented by the number of seconds elapsed since

1/1/1970. If, for example, you want to access the
Agora Service within 10 minutes after the token is
generated, set expireTimestamp as the current
timestamp + 600 (seconds)./

Types

type AccessToken

type AccessToken struct {
	// contains filtered or unexported fields
}

func NewAccessToken

func NewAccessToken(appID, appCertificate, channelName string, uid uint32) *AccessToken

func NewAccessTokenFromString

func NewAccessTokenFromString(originToken string) (*AccessToken, error)

func NewAccessTokenStrUID

func NewAccessTokenStrUID(appID, appCertificate, channelName string, uid string) *AccessToken

func (*AccessToken) AddPrivilege

func (token *AccessToken) AddPrivilege(privilege Privileges, expireTimestamp time.Time)

func (*AccessToken) Build

func (token *AccessToken) Build() (string, error)

type Privileges

type Privileges uint16
const (
	PrivilegeJoinChannel        Privileges = 1
	PrivilegePublishAudioStream Privileges = 2
	PrivilegePublishVideoStream Privileges = 3
	PrivilegePublishDataStream  Privileges = 4

	PrivilegeAdministrateChannel Privileges = 101
	PrivilegeLoginRtm            Privileges = 1000
)

type RTCRole

type RTCRole uint16

RTCRole is role type

const (
	RolePublisher  RTCRole = 1
	RoleSubscriber RTCRole = 2
	RoleAdmin      RTCRole = 101
)

Role consts

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL