accesstoken

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version       = "007"
	VersionLength = 3

	// Service type
	ServiceTypeRtc       = 1
	ServiceTypeRtm       = 2
	ServiceTypeFpa       = 4
	ServiceTypeChat      = 5
	ServiceTypeEducation = 7

	// Rtc
	PrivilegeJoinChannel        = 1
	PrivilegePublishAudioStream = 2
	PrivilegePublishVideoStream = 3
	PrivilegePublishDataStream  = 4

	// Rtm
	// Fpa
	PrivilegeLogin = 1

	// Chat
	PrivilegeChatUser = 1
	PrivilegeChatApp  = 2

	// Education
	PrivilegeEducationRoomUser = 1
	PrivilegeEducationUser     = 2
	PrivilegeEducationApp      = 3
)

Variables

This section is empty.

Functions

func AssertEqual

func AssertEqual(t *testing.T, expected, actual interface{})

func AssertNil

func AssertNil(t *testing.T, err error)

func GetUidStr

func GetUidStr(uid uint32) string

func Md5 added in v1.2.0

func Md5(str string) string

Types

type AccessToken

type AccessToken struct {
	AppCert  string
	AppId    string
	Expire   uint32
	IssueTs  uint32
	Salt     uint32
	Services map[uint16]IService
}

func CreateAccessToken

func CreateAccessToken() (accessToken *AccessToken)

func NewAccessToken

func NewAccessToken(appId string, appCert string, expire uint32) (accessToken *AccessToken)

func (*AccessToken) AddService

func (accessToken *AccessToken) AddService(service IService)

func (*AccessToken) Build

func (accessToken *AccessToken) Build() (res string, err error)

func (*AccessToken) Parse

func (accessToken *AccessToken) Parse(token string) (res bool, err error)

type IService

type IService interface {
	Pack(io.Writer) error
	UnPack(io.Reader) error
	// contains filtered or unexported methods
}

type Service

type Service struct {
	Privileges map[uint16]uint32
	Type       uint16
}

func NewService

func NewService(serviceType uint16) (service *Service)

func (*Service) AddPrivilege

func (service *Service) AddPrivilege(privilege uint16, expire uint32)

func (*Service) Pack

func (service *Service) Pack(w io.Writer) (err error)

func (*Service) UnPack

func (service *Service) UnPack(r io.Reader) (err error)

type ServiceChat added in v1.2.0

type ServiceChat struct {
	*Service
	UserId string
}

func NewServiceChat added in v1.2.0

func NewServiceChat(userId string) (serviceChat *ServiceChat)

func (*ServiceChat) Pack added in v1.2.0

func (serviceChat *ServiceChat) Pack(w io.Writer) (err error)

func (*ServiceChat) UnPack added in v1.2.0

func (serviceChat *ServiceChat) UnPack(r io.Reader) (err error)

type ServiceEducation added in v1.2.0

type ServiceEducation struct {
	*Service
	RoomUuid string
	UserUuid string
	Role     int16
}

func NewServiceEducation added in v1.2.0

func NewServiceEducation(roomUuid string, userUuid string, role int16) (serviceEducation *ServiceEducation)

func (*ServiceEducation) Pack added in v1.2.0

func (serviceEducation *ServiceEducation) Pack(w io.Writer) (err error)

func (*ServiceEducation) UnPack added in v1.2.0

func (serviceEducation *ServiceEducation) UnPack(r io.Reader) (err error)

type ServiceFpa added in v1.2.0

type ServiceFpa struct {
	*Service
}

func NewServiceFpa added in v1.2.0

func NewServiceFpa() (serviceFpa *ServiceFpa)

func (*ServiceFpa) Pack added in v1.2.0

func (serviceFpa *ServiceFpa) Pack(w io.Writer) (err error)

func (*ServiceFpa) UnPack added in v1.2.0

func (serviceFpa *ServiceFpa) UnPack(r io.Reader) (err error)

type ServiceRtc

type ServiceRtc struct {
	*Service
	ChannelName string
	Uid         string
}

func NewServiceRtc

func NewServiceRtc(channelName string, uid string) (serviceRtc *ServiceRtc)

func (*ServiceRtc) Pack

func (serviceRtc *ServiceRtc) Pack(w io.Writer) (err error)

func (*ServiceRtc) UnPack

func (serviceRtc *ServiceRtc) UnPack(r io.Reader) (err error)

type ServiceRtm

type ServiceRtm struct {
	*Service
	UserId string
}

func NewServiceRtm

func NewServiceRtm(userId string) (serviceRtm *ServiceRtm)

func (*ServiceRtm) Pack

func (serviceRtm *ServiceRtm) Pack(w io.Writer) (err error)

func (*ServiceRtm) UnPack

func (serviceRtm *ServiceRtm) UnPack(r io.Reader) (err error)

Jump to

Keyboard shortcuts

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