host

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package host connects the terminal to a Greenscreen application. The application's screens come from its API (see docs/protocol.md): this package sends each AID key with the screen's input and draws the screen that comes back. Only the logon screen, which signs in through Cloudflare Access, is drawn locally.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Host() string
	Logon(ctx context.Context) (string, error)
	Logoff(ctx context.Context) error
	Screen(ctx context.Context, req api.ScreenRequest) (api.ScreenResponse, error)
}

Backend is the API the session talks to. *api.Client implements it.

type Config

type Config struct {
	SystemName  string // e.g. "SYS1"
	Title       string // the application's name on the logon screen, e.g. "POINT OF SALE"
	Tagline     string // shown there instead of the title, if set
	Prefix      string // starts the terminal's own message IDs, e.g. "POS"; default "GSC"
	Banner      []string
	Backend     Backend
	DownloadDir string // where files sent with a screen are saved
	Live        bool   // the application serves GET /v1/live
	Snapshots   bool   // the application serves POST /v1/snapshot
	HaveInfo    bool   // the above came from the application (SetInfo)
}

func (*Config) SetInfo added in v0.2.1

func (c *Config) SetInfo(info api.AppInfo)

SetInfo takes what the application says about itself. The system name is only taken if none was given.

type Downloader added in v0.2.0

type Downloader interface {
	Download(ctx context.Context, path string) ([]byte, error)
}

Downloader is a Backend that can fetch the files screens send along, such as an invoice PDF. *api.Client implements it.

type Informer added in v0.2.1

type Informer interface {
	Info(ctx context.Context) (api.AppInfo, error)
}

Informer is a Backend that can say what the application calls itself and what it serves: GET /v1/screen/info. *api.Client implements it.

type Listener added in v0.2.0

type Listener interface {
	Listen(ctx context.Context, opened func(), on func(event string)) error
}

Listener is a Backend that can push: see api.Client.Listen.

type Session

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

Session is the terminal's connection to the application. It implements tn3270.Host.

func NewSession

func NewSession(cfg *Config, lu string) *Session

func (*Session) Pushes added in v0.2.0

func (s *Session) Pushes() <-chan struct{}

Pushes implements tn3270.Pusher: a value comes when the host has said the screen should be redrawn.

func (*Session) Redraw

func (s *Session) Redraw(rows, cols int) *t3.Screen

Redraw asks the application for the current screen at the terminal's new size. It returns nil, keeping the old layout, if that fails.

func (*Session) Snapshot added in v0.2.0

func (s *Session) Snapshot(scr *t3.Screen, format string) (string, error)

Snapshot implements tn3270.Snapshotter: the application draws the screen as it shows, typed input included, and the file goes in the download directory.

func (*Session) Start

func (s *Session) Start() *t3.Screen

func (*Session) Submit

func (s *Session) Submit(aid t3.AID, scr *t3.Screen) *t3.Screen

type SnapshotTaker added in v0.2.0

type SnapshotTaker interface {
	Snapshot(ctx context.Context, req api.SnapshotRequest) ([]byte, string, error)
}

SnapshotTaker is a Backend that can draw a screen as a picture. *api.Client implements it.

Jump to

Keyboard shortcuts

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