svarmrgo

package module
v0.0.0-...-4ca3ce5 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: GPL-3.0 Imports: 9 Imported by: 15

README

svarmrgo

Go support libraries for svarmr

Documentation

Overview

Support functions for svarmr

Index

Constants

This section is empty.

Variables

View Source
var AppDir, SvarmrDir string

Functions

func CliConnect

func CliConnect() net.Conn

Read command line options, connect to svarmr server as directed from the command line

Command line must be "program host port" where host and port are the connection details for the svarmr server

func ConnectHub

func ConnectHub(server, port string) net.Conn

Connect to a svarmr server on host:port

func Debug

func Debug(s string)

func HandleConnection

func HandleConnection(conn net.Conn, Q chan message)

func HandleInputLoop

func HandleInputLoop(conn net.Conn, callback MessageHandler2)

Handle incoming messages. This will read a message, unpack the JSON, and call the MessageHandler with the unpacked message

MessageHandler must look like:

func handleMessage (m svarmrgo.Message) []svarmrgo.Message

We call handleMessage with a message, and it returns an array of svarmrgo.Message We then send all the returned messages

func SendMessage

func SendMessage(conn net.Conn, m Message)

Send a message. Messages will soon contain unique ID numbers, allowing responses to be matched to messages

If conn is nil, then it will use whatever port the message was received on, the same as RespondMessage

func SimpleSend

func SimpleSend(conn net.Conn, selector, arg string)

func WireFormat

func WireFormat(m Message) string

Prepares the wire format version of the message, suitable for printing or sending

Types

type Message

type Message struct {
	Conn      net.Conn
	Selector  string
	Arg       string
	Args      []string
	NamedArgs map[string]string
}

func (*Message) Respond

func (m *Message) Respond(response Message)

Respond to a message. Messages will soon contain unique ID numbers, allowing responses to be matched to messages

Always replies on the same port we received the message from

func (*Message) Response

func (m *Message) Response(response Message) string

Build a response to a message. Messages will soon contain unique ID numbers, allowing responses to be matched to messages

type MessageHandler

type MessageHandler func(net.Conn, Message)

type MessageHandler2

type MessageHandler2 func(Message) []Message

type SubProx

type SubProx struct {
	In  io.WriteCloser
	Out io.ReadCloser
	Err io.ReadCloser
	Cmd *exec.Cmd
}

Jump to

Keyboard shortcuts

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