rpc

package
v0.0.0-...-36085eb Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ModuleName = "jungletv:rpc"

ModuleName is the name by which this module can be require()d in a script

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientEventData

type ClientEventData struct {
	EventName string
	EventArgs []string
}

type InvocationResult

type InvocationResult struct {
	Synchronous bool
	Value       string // if synchronous
	AsyncResult <-chan PromiseResult
}

type PageUserTuple

type PageUserTuple struct {
	Page string
	User string
}

type PromiseResult

type PromiseResult struct {
	Rejected       bool
	Value          goja.Value
	JSONMarshaller goja.Callable
}

type RPCModule

type RPCModule interface {
	modules.NativeModule
	// HandleInvocation must be called inside the event loop
	// returns either a goja.Value (if the method handler is synchronous) or a channel where a goja.Value will later be sent (if the method handler returns a Promise)
	HandleInvocation(vm *goja.Runtime, user auth.User, pageID, method string, args []string) InvocationResult
	// HandleEvent must be called inside the event loop
	HandleEvent(vm *goja.Runtime, user auth.User, trusted bool, pageID, event string, args []string)

	GlobalEventEmitted() event.Event[ClientEventData]
	PageEventEmitted() event.Keyed[string, ClientEventData]
	UserEventEmitted() event.Keyed[string, ClientEventData]
	PageUserEventEmitted() event.Keyed[PageUserTuple, ClientEventData]
}

RPCModule manages client-initiated RPC for an application

func New

func New(userSerializer gojautil.UserSerializer) RPCModule

New returns a new RPC module

Jump to

Keyboard shortcuts

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