eventio

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorEmptyPacket     = errors.New("Packet length should be at least 1 byte")
	ErrorHttpStatusNotOk = errors.New("HTTP Status Not OK")
)

Functions

func EncodePacket

func EncodePacket(p Packet) ([]byte, error)

func EncodePayloads

func EncodePayloads(packets []Packet) ([]byte, error)

Types

type Client

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

func NewClient

func NewClient(url string, logger log.Logger) *Client

func (*Client) FullUrl

func (c *Client) FullUrl() string

func (*Client) Handle

func (c *Client) Handle(h Handler)

func (*Client) HandleOpen

func (c *Client) HandleOpen(r OpenResponse) error

func (*Client) HandlePacket

func (c *Client) HandlePacket(p Packet) error

func (*Client) Open

func (c *Client) Open() error

func (*Client) Send

func (c *Client) Send(msg string)

func (*Client) SendMessage

func (c *Client) SendMessage(m string)

type Handler

type Handler interface {
	HandleMessage(msg string)
}

type OpenResponse

type OpenResponse struct {
	Sid          string   `json:"sid"`
	Upgrades     []string `json:"upgrades"`
	PingInterval int      `json:"pingInterval"`
	PingTimeout  int      `json:"pingTimeout"`
}

type Packet

type Packet struct {
	Type PacketType
	Data string
}

func ParsePacket

func ParsePacket(packet string) (Packet, error)

func ParsePayloads

func ParsePayloads(data string) ([]Packet, error)

func ParseResponse

func ParseResponse(resp *http.Response) ([]Packet, error)

type PacketType

type PacketType int
const (
	Open PacketType = iota
	Close
	Ping
	Pong
	Message
	Upgrade
	Noop
)

func (PacketType) String

func (pt PacketType) String() string

Jump to

Keyboard shortcuts

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