rendezvous

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package rendezvous provides a client for magic wormhole rendezvous servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(url, sideID, appID string, opts ...ClientOption) *Client

NewClient returns a Rendezvous client. URL is the websocket url of Rendezvous server. SideID is the id for the client to use to distinguish messages in a mailbox from the other client. AppID is the application identity string of the client.

Two clients can only communicate if they have the same AppID.

func (*Client) AddMessage

func (c *Client) AddMessage(ctx context.Context, phase, body string) error

AddMessage adds a message to the opened mailbox. This must be called after either CreateMailbox or AttachMailbox.

func (*Client) AttachMailbox

func (c *Client) AttachMailbox(ctx context.Context, nameplate string) error

AttachMailbox opens an existing mailbox and releases the associated nameplate.

func (*Client) Close

func (c *Client) Close(ctx context.Context, mood Mood) error

Close sends mood to server and then tears down the connection.

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) (*ConnectInfo, error)

Connect opens a connection and binds to the rendezvous server. It returns the Welcome information the server responds with.

func (*Client) CreateMailbox

func (c *Client) CreateMailbox(ctx context.Context) (string, error)

CreateMailbox allocates a nameplate, claims it, and then opens the associated mailbox. It returns the nameplate id string.

func (*Client) ListNameplates

func (c *Client) ListNameplates(ctx context.Context) ([]string, error)

ListNameplates returns a list of active nameplates on the rendezvous server.

func (*Client) MsgChan

func (c *Client) MsgChan(ctx context.Context) <-chan MailboxEvent

MsgChan returns a channel of Mailbox message events. Each message from the other side will be published to this channel.

type ClientOption added in v1.0.1

type ClientOption interface {
	// contains filtered or unexported methods
}

func WithVersion added in v1.0.1

func WithVersion(agentID string, version string) ClientOption

WithVersion returns a ClientOption to override the default client identifier and version reported to the rendezvous server.

type ConnectInfo

type ConnectInfo struct {
	MOTD              string
	CurrentCLIVersion string
}

type MailboxEvent

type MailboxEvent struct {
	// Error will be non nil if an error occurred
	// while waiting for messages
	Error error
	Side  string
	Phase string
	Body  string
}

type Mood

type Mood string
const (
	Happy  Mood = "happy"
	Lonely Mood = "lonely"
	Scary  Mood = "scary"
	Errory Mood = "errory"
)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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