ssmp

package
v0.0.0-...-79deb2b Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2017 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package ssmp provides constants and utilities shared between client and server.

Index

Constants

View Source
const (
	CodeLength          = 3
	MaxVerbLength       = 16
	MaxIdentifierLength = 64
	MaxPayloadLength    = 1024
	BinaryPayloadPrefix = 2

	MaxMessageLength = CodeLength + 5 + MaxVerbLength + 2*MaxIdentifierLength + BinaryPayloadPrefix + MaxPayloadLength
)
View Source
const (
	LOGIN       = "LOGIN"
	SUBSCRIBE   = "SUBSCRIBE"
	UNSUBSCRIBE = "UNSUBSCRIBE"
	UCAST       = "UCAST"
	MCAST       = "MCAST"
	BCAST       = "BCAST"
	PING        = "PING"
	PONG        = "PONG"
	CLOSE       = "CLOSE"
)

Requests

View Source
const (
	CodeEvent        = 0
	CodeOk           = 200
	CodeBadRequest   = 400
	CodeUnauthorized = 401
	CodeNotFound     = 404
)

Response codes

View Source
const Anonymous = "."

Reserved identifier for anonymous login.

View Source
const (
	PRESENCE = "PRESENCE"
)

Options

Variables

View Source
var ErrInvalidMessage error = fmt.Errorf("invalid message")

Functions

func Equal

func Equal(b []byte, s string) bool

Equal compares a byte array to a string, to avoid unecessary conversions.

func IsValidIdentifier

func IsValidIdentifier(s string) bool

IsValidIdentifier reports whether s is a valid SSMP IDENTIFIER field.

Types

type ByteSet

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

A ByteSet is a compact representation of an immutable set of bytes, which offers constant-time membership queries.

var ID_CHARSET *ByteSet = NewByteSet(
	Range('a', 'z'),
	Range('A', 'Z'),
	Range('0', '9'),
	All(".:@/-_+=~"),
)

ID_CHARSET is a ByteSet matching SSMP IDENTIFIER fields.

var VERB_CHARSET *ByteSet = NewByteSet(
	Range('A', 'Z'),
)

VERB_CHARSRT is a ByteSet matching SSMP VERB fields.

func NewByteSet

func NewByteSet(initializers ...ByteSetInitializer) *ByteSet

Creates a new ByteSet as the union of the given initializers.

func (*ByteSet) Contains

func (s *ByteSet) Contains(c byte) bool

Contains reports whether byte c is in the set.

type ByteSetInitializer

type ByteSetInitializer func(*ByteSet)

func All

func All(cs string) ByteSetInitializer

Initializer for a list of bytes.

func Byte

func Byte(c byte) ByteSetInitializer

Initializer for a single byte.

func Range

func Range(a, b byte) ByteSetInitializer

Initializer for a range of bytes.

type Decoder

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

func NewDecoder

func NewDecoder(rd io.Reader) *Decoder

func (*Decoder) AtEnd

func (d *Decoder) AtEnd() bool

func (*Decoder) DecodeCode

func (d *Decoder) DecodeCode() (int, error)

func (*Decoder) DecodeCompat

func (d *Decoder) DecodeCompat() ([]byte, error)

optional id and optional payload

func (*Decoder) DecodeId

func (d *Decoder) DecodeId() ([]byte, error)

func (*Decoder) DecodePayload

func (d *Decoder) DecodePayload() ([]byte, error)

func (*Decoder) DecodeVerb

func (d *Decoder) DecodeVerb() ([]byte, error)

func (*Decoder) RawMessage

func (d *Decoder) RawMessage() []byte

func (*Decoder) Reset

func (d *Decoder) Reset()

Called after a message was decoded, before decoding the next one

Jump to

Keyboard shortcuts

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