v0.0.0-...-aadac20 Latest Latest

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 5 Imported by: 0



Package client contains everything required to connect to a server.

Stimmtausch uses a hierarchy of concepts within a client:

 ├── server type
 │   ├── server
 │   │   ├── world
 │   │   │   └── conection
 │   │   ├── world
 │   │   ...
 │   ├── server
 │   ...
 ├── server type

A client can contain any number of server types. These are the various kinds of games out there, such as MUCKs, MUDs, MOOs, etc. Each server type can, in turn, contain any number of servers. Each server can then contain any number of worlds, which are the union of a character and a server. Finally, each world can contain any number of connections (though, in practice, usually only one).

This maps directly to a good chunk of the configuration file, handily.

Responsibility is passed throughout this chain. For instance, you call connect on the client, which decides how to do so by looking at the worlds and servers it knows about. Ditto closing connections. Similarly, errors percolate through the tree.

The client is designed to be agnostic as far as interacting with it goes. Stimmtausch has a UI, but that is not required; you can run the client in headless mode and it will maintain the connection for you, and you can interact with it without using the termbox UI.

This works on the fact that Stimmtausch's client manages the connection and all of its interaction through two files: an output file which streams data received from the connection, and an input file which is actually a FIFO. When you write to the input file, that data gets sent to the server while any responses are written to the output file.

This mirrors the IRC client [`ii`](, and, in turn, the MUCK client [`mm`]( The latter was a heavy inspiration for Stimmtausch.

The upside to this is that the combination of everything being an instance of io.Writer - the output file, the FIFO, the history buffers, the termbox views, everything - is that the whole thing is just a well-organized set of fmt.Fprint*() statements once it's all set up.



This section is empty.


This section is empty.


This section is empty.


type Client

type Client struct {
	// The current configuration object holding all worlds, servers, etc.
	Config *config.Config

	// The signal environment.
	Env *signal.Dispatcher
	// contains filtered or unexported fields

Client contains all of the information and objects Stimmtausch knows about. This pretty efficiently maps to information in the config file, and it may be worth simplifying that in the future.

func New

func New(cfg *config.Config, env *signal.Dispatcher) (*Client, error)

New creates a new Client and populates it using information from the config.

func (*Client) Close

func (c *Client) Close(name string)

Close will close a connection with the given name (usually the connectStr).

func (*Client) CloseAll

func (c *Client) CloseAll()

CloseAll will attempt to close all open connections.

func (*Client) Conn

func (c *Client) Conn(name string) (*connection.Connection, bool)

func (*Client) Connect

func (c *Client) Connect(connectStr string) (*connection.Connection, error)

Connect accepts a string and tries to connect to it in the following ways:

  • If the string is the name of a world, it will connect that world; otherwise
  • If the string is the name of a server, it will connect to it with a new world created for that purpose; otherwise
  • It will try to connect to that string as if it were a host:port; finally
  • It will fail.

Jump to

Keyboard shortcuts

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