command

package
v0.0.3-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package command provides methods and functions for creating and parsing Altid control messages

go get github.com/altid/server/command

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdType

type CmdType int

CmdType is a type of default command

const (
	OtherCmd CmdType = iota
	OpenCmd
	ReloadCmd
	BufferCmd
	CloseCmd
	LinkCmd
	QuitCmd
)

Currently supported cmdtypes

type Command

type Command struct {
	// The sending client ID
	UUID    uint32
	CmdType CmdType
	// Arguments for known commands, such as buffer/open/close/link
	Args []string
	// The raw command bytes
	Data []byte
}

Command is a ctl message

func FromBytes

func FromBytes(uuid uint32, b []byte) (*Command, error)

FromBytes returns a command from byte input, or an error if it was unable to parse

func FromString

func FromString(uuid uint32, s string) (*Command, error)

FromString retruns a command from string input, or an error if it was unable to parse

cmdChannel <- FromString(clientuuid, "buffer newbuffer")
cmdChannel <- FromString(clientuuid, "link new old")

func New

func New(uuid uint32, cmdType CmdType, data []byte, args ...string) *Command

New - helper func with varargs

cmdChannel <- New(clientuuid, BufferCmd, nil, "newbuffer")
cmdChannel <- New(clientuuid, CloseCmd, nil, "oldbuffer")
cmdChannel <- New(clientuuid, OtherCmd, []byte("emote I swapped buffers"))
cmdChannel <- New(clientuuid, LinkCmd, nil, "newbuffer", "oldbuffer")

func (*Command) WriteOut

func (c *Command) WriteOut(w io.Writer) error

WriteOut will write the command correctly to the Writer If a command is poorly formatted, it will return an error

Jump to

Keyboard shortcuts

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