pm

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileTs

func CompileTs(tsCfg config.TsConfig, outDir string) error

func EncodeMessage

func EncodeMessage(msg ControlMessage) []byte

func GetSocketPath

func GetSocketPath() (sockFile string, sockPath string)

func IsHostOnline

func IsHostOnline() bool

func ResolveTsEntry

func ResolveTsEntry(entry string, tsCfg config.TsConfig) (outDir string, outFile string)

func SendCommand

func SendCommand(cmd string, appName string)

func SpawnApp

func SpawnApp(app config.App, tsCfg config.TsConfig) (int, error)

Types

type ControlMessage

type ControlMessage struct {
	Cmd    string         `json:"cmd"`
	App    string         `json:"app"`
	MsgId  string         `json:"msgId"`
	Text   string         `json:"text"`
	Guests []clientRecord `json:"guests"`
	Error  string         `json:"error"`

	// `Pid` shall be provided when `Cmd` is `handshake`.
	Pid int `json:"pid"`

	// `conn.Close()` will destroy the connection before the final message is flushed, causing the
	// other peer losing the connection and the message, and no EOF will be received. To guarantee
	// the final message is sent, we need a signal (`FIN`) to indicate whether this is the final
	// message, and close the connection on the receiver side.
	Fin bool `json:"fin"`
}

func DecodeMessage

func DecodeMessage(packet *[]byte, bufRead []byte, eof bool) []ControlMessage

type Guest

type Guest struct {
	AppName string
	AppUrl  string
	// contains filtered or unexported fields
}

func NewGuest

func NewGuest(app config.App, onStopCommand func(msgId string)) *Guest

func (*Guest) Join

func (self *Guest) Join()

func (*Guest) Leave

func (self *Guest) Leave(reason string, replyId string) bool

func (*Guest) Send

func (self *Guest) Send(msg ...ControlMessage) error

type Host

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

The Host-Guest model is a mechanism used to hold communication between all apps running on the same machine.

This mechanism is primarily used for the CLI tool sending control commands to the apps.

func NewHost

func NewHost(conf config.Config, standalone bool) *Host

func (*Host) Start

func (self *Host) Start(wait bool) error

func (*Host) Stop

func (self *Host) Stop()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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