icb

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: ISC Imports: 5 Imported by: 0

README

package icb // import "suah.dev/icb"


FUNCTIONS

func DefaultHandlers() map[string]interface{}
    DefaultHandlers produces a set of handlers that will print messages to
    stdout. Ping ("l") packets will also be Pong'd ("m") if received.


TYPES

type Client struct {
	Conn     net.Conn
	Handlers map[string]interface{}
}
    Client gives us a convenient way to Read and Write ICB packets to a remote
    server.

func (c *Client) Connect(s string) (err error)
    Connect connects to specified ICB server.

func (c *Client) Read() (*Packet, error)
    Read reads the next packet from the server. The first byte contains the
    length of the packet to be read.

func (c *Client) RunHandlers(s []string) error
    RunHandlers iterates over each handler and executes on the corresponding
    packet type. If the packet is unhandled, we return an error containing the
    packet type.

func (c *Client) Write(s []string) error
    Write writes a packet to an ICB server

type Packet struct {
	Buffer bytes.Buffer
}
    Packet represents a packet as described by
    https://www.icb.net/_jrudd/protocol.html

func (p *Packet) Decode() (*[]string, error)
    Decode reads from the buffer and decodes the packet.

func (p *Packet) Encode(params []string) error
    Encode writes an ICB formatted packet to the Buffer.

func (p *Packet) Send(c net.Conn) error
    Send takes a connection and sends the ICB packet over it.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultHandlers

func DefaultHandlers() map[string]interface{}

DefaultHandlers produces a set of handlers that will print messages to stdout. Ping ("l") packets will also be Pong'd ("m") if received.

Types

type Client

type Client struct {
	Conn     net.Conn
	Handlers map[string]interface{}
}

Client gives us a convenient way to Read and Write ICB packets to a remote server.

func (*Client) Connect

func (c *Client) Connect(s string) (err error)

Connect connects to specified ICB server.

func (*Client) Read

func (c *Client) Read() (*Packet, error)

Read reads the next packet from the server. The first byte contains the length of the packet to be read.

func (*Client) RunHandlers

func (c *Client) RunHandlers(s []string) error

RunHandlers iterates over each handler and executes on the corresponding packet type. If the packet is unhandled, we return an error containing the packet type.

func (*Client) Write

func (c *Client) Write(s []string) error

Write writes a packet to an ICB server

type Packet

type Packet struct {
	Buffer bytes.Buffer
}

Packet represents a packet as described by https://www.icb.net/_jrudd/protocol.html

func (*Packet) Decode

func (p *Packet) Decode() (*[]string, error)

Decode reads from the buffer and decodes the packet.

func (*Packet) Encode

func (p *Packet) Encode(params []string) error

Encode writes an ICB formatted packet to the Buffer.

func (*Packet) Send

func (p *Packet) Send(c net.Conn) error

Send takes a connection and sends the ICB packet over it.

Directories

Path Synopsis
cmd
icbc command

Jump to

Keyboard shortcuts

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