base

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultServiceScheme  = "https"
	DefaultServiceDomain  = "omega.kklab.com"
	DefaultConnectTimeout = 10 * time.Second
	DefaultTransitTimeout = 10 * time.Second
)

Variables

View Source
var ErrCantGetServiceResource = fmt.Errorf("can't get service resource")
View Source
var ErrConfigIsEmpty = errors.Errorf("config is empty")
View Source
var ErrConnectTimeout = fmt.Errorf("connect timeout")
View Source
var ErrConnectionClosed = errors.Errorf("connection closed")
View Source
var ErrSessionNotFound = errors.Errorf("session not found")
View Source
var ErrTransitTimeout = errors.Errorf("request transit timeout")
View Source
var ErrUnexpectError = errors.Errorf("unexcept error")

Functions

func SDKLanguage added in v1.0.1

func SDKLanguage() string

func SDKVersion added in v1.0.1

func SDKVersion() string

func SafeGetStructMap added in v1.1.0

func SafeGetStructMap(strpb *structpb.Struct) map[string]any

Types

type Agent

type Agent interface {
	Close() concurrent.Future
	IsClosed() bool
	Session() Session
	GetRemoteSession(sessionId string) concurrent.CastFuture[RemoteSession]
	OnClosed(f func())
	OnMessage(f func(tf *omega.TransitFrame))
	OnSessionMessage(f func(tf *omega.TransitFrame))
	OnRequest(f func(tf *omega.TransitFrame))
	OnResponse(f func(tf *omega.TransitFrame))
	OnRequestReplay(f func(tf *omega.TransitFrame))
	OnResponseReplay(f func(tf *omega.TransitFrame))
	OnNotification(f func(tf *omega.TransitFrame))
	OnNotificationReplay(f func(tf *omega.TransitFrame))
	OnError(f func(err error))
	Ping() SendFuture
	OnBroadcast(f func(tf *omega.TransitFrame))
	Broadcast(msg string) SendFuture
	Hello() SendFuture
	ServerTime() SendFuture
	PlaybackChannelMessage(channelId string, targetTimestamp int64, inverse bool, volume omega.Volume, nextId string) SendFuture
	GetChannelMetadata(channelId string) SendFuture
	SetChannelMetadata(channelId string, name string, metadata *Metadata, skill *omega.Skill) SendFuture
	JoinChannel(channelId string, key string) SendFuture
	LeaveChannel(channelId string) SendFuture
	CloseChannel(channelId, key string) SendFuture
	ChannelMessage(channelId string, message string, metadata *Metadata) SendFuture
	ChannelCount(channelId string) SendFuture
	ChannelOwnerMessage(channelId string, message string, metadata *Metadata) SendFuture
	ReplayChannelMessage(channelId string, targetTimestamp int64, inverse bool, volume omega.Volume, nextId string) SendFuture
	GetVoteMetadata(voteId string) SendFuture
	SetVoteMetadata(voteId string, name string, metadata *Metadata) SendFuture
	JoinVote(voteId string, key string) SendFuture
	LeaveVote(voteId string) SendFuture
	CloseVote(voteId, key string) SendFuture
	VoteMessage(voteId string, message string) SendFuture
	VoteSelect(voteId string, voteOptionId string) SendFuture
	VoteCount(voteId string) SendFuture
	VoteOwnerMessage(voteId string, message string) SendFuture
	VoteStatus(voteId string, statusType omega.Vote_Status) SendFuture
	GetSessionMeta(sessionId string) SendFuture
	SetSessionMeta(metadata *Metadata) SendFuture
	SessionMessage(sessionId string, message string) SendFuture
	SessionsMessage(sessionIds []string, message string) SendFuture
	CreateChannel(createChannel apirequest.CreateChannel) concurrent.CastFuture[*apiresponse.CreateChannel]
	CreateVote(createVote apirequest.CreateVote) concurrent.CastFuture[*apiresponse.CreateVote]
}

func NewAgent

func NewAgent(session Session) Agent

type AgentBuilder

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

func NewAgentBuilder

func NewAgentBuilder(conf *Config) *AgentBuilder

func (*AgentBuilder) Connect

func (b *AgentBuilder) Connect() concurrent.CastFuture[Agent]

func (*AgentBuilder) WithEngine added in v1.0.2

func (b *AgentBuilder) WithEngine(engine *Engine) *AgentBuilder

type Config

type Config struct {
	Scheme         string
	Domain         string
	ConnectTimeout time.Duration
	TransitTimeout time.Duration
	AppId          string
	Token          string
}

func NewConfig

func NewConfig(appId string, token string) *Config

type DefaultSendFuture

type DefaultSendFuture struct {
	concurrent.CastFuture[*omega.TransitFrame]
	// contains filtered or unexported fields
}

func (*DefaultSendFuture) SentTransitFrame

func (f *DefaultSendFuture) SentTransitFrame() *omega.TransitFrame

type Engine

type Engine struct {
	Config *Config
	APIUri string
	WSUri  string
}

func NewEngine

func NewEngine(conf *Config) *Engine

func (*Engine) Connect added in v1.0.2

func (e *Engine) Connect() concurrent.CastFuture[Session]

type Metadata

type Metadata = structpb.Struct

func NewMetadata

func NewMetadata(v map[string]interface{}) *Metadata

type RemoteSession

type RemoteSession interface {
	GetId() string
	GetSubject() string
	GetName() string
	GetMetadata() *Metadata
	OnMessage(f func(msg *omega.TransitFrame))
	SendMessage(message string) SendFuture
	Fetch() SendFuture
	Close() concurrent.Future
}

type SendFuture

type SendFuture interface {
	concurrent.CastFuture[*omega.TransitFrame]
	SentTransitFrame() *omega.TransitFrame
}

type Session

type Session interface {
	RemoteSession
	GetRemoteSession(sessionId string) concurrent.CastFuture[RemoteSession]
	Ch() channel.Channel
	GetEngine() *Engine
	SetName(name string) SendFuture
	SetMetadata(metadata *Metadata) SendFuture
	Send(tf *omega.TransitFrame) SendFuture
	SendRequest(data omega.TransitFrameData) SendFuture
	Ping() SendFuture
	Hello() SendFuture
	ServerTime() SendFuture
	OnClosed(f func())
	OnRead(f func(tf *omega.TransitFrame))
	OnError(f func(err error))
	IsClosed() bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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