accesstoken2

package
v0.0.0-...-374cd21 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

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

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

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

	// Rtm
	// Fpa
	PrivilegeLogin = 1

	// Chat
	PrivilegeChatUser = 1
	PrivilegeChatApp  = 2

	// Apaas
	PrivilegeApaasRoomUser = 1
	PrivilegeApaasUser     = 2
	PrivilegeApaasApp      = 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

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 ServiceApaas

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

func NewServiceApaas

func NewServiceApaas(roomUuid string, userUuid string, role int16) (serviceApaas *ServiceApaas)

func (*ServiceApaas) Pack

func (serviceApaas *ServiceApaas) Pack(w io.Writer) (err error)

func (*ServiceApaas) UnPack

func (serviceApaas *ServiceApaas) UnPack(r io.Reader) (err error)

type ServiceChat

type ServiceChat struct {
	*Service
	UserId string
}

func NewServiceChat

func NewServiceChat(userId string) (serviceChat *ServiceChat)

func (*ServiceChat) Pack

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

func (*ServiceChat) UnPack

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

type ServiceFpa

type ServiceFpa struct {
	*Service
}

func NewServiceFpa

func NewServiceFpa() (serviceFpa *ServiceFpa)

func (*ServiceFpa) Pack

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

func (*ServiceFpa) UnPack

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