eventsocketclient

package module
v0.0.0-...-a1b20e5 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2015 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const MESSAGE_TYPE_BROADCAST = 1
View Source
const MESSAGE_TYPE_REPLY = 4
View Source
const MESSAGE_TYPE_REQUEST = 3
View Source
const MESSAGE_TYPE_STANDARD = 2
View Source
const MESSAGE_TYPE_SUSCRIBE = 5
View Source
const MESSAGE_TYPE_UNSUSCRIBE = 6

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// The client Id, provided by the server
	Id string `json:"Id"`

	// channels for receiving messages
	RecvBroadcast chan *Received `json:"-"`
	RecvRequest   chan *Received `json:"-"`
	RecvError     chan error     `json:"-"`
	// contains filtered or unexported fields
}

Client is the main eventsocket client

func NewClient

func NewClient(url string) (*Client, error)

NewClient registers a new client with the server

func (*Client) Broadcast

func (client *Client) Broadcast(p *Payload) error

Broadcast a payload

func (*Client) Close

func (client *Client) Close()

Close closes the connections

func (*Client) DialWs

func (client *Client) DialWs() error

DialWs will dial the websocket server, and get a websocket connection in return

func (*Client) Emit

func (client *Client) Emit(event string, p *Payload) error

Emit an event

func (*Client) Reconnect

func (client *Client) Reconnect() error

Reconnect attempts a reconnect with the server

func (*Client) Recv

func (client *Client) Recv() error

Recv reads from the socket

func (*Client) Reply

func (client *Client) Reply(requestID, cid string, p *Payload) error

Reply sends a reply to a request

func (*Client) Request

func (client *Client) Request(id string, p *Payload) (<-chan *Received, error)

Request will execute a request against a client

func (*Client) SetMaxMessageSize

func (client *Client) SetMaxMessageSize(limit int64)

SetMaxMessageSize sets the max message size. Note: this is not the max frame size

func (*Client) SetReadDeadline

func (client *Client) SetReadDeadline(t time.Duration)

SetReadDeadline sets the deadline to receive a response on the socket

func (*Client) Suscribe

func (client *Client) Suscribe(events ...string) (<-chan *Received, error)

Suscribe to an event(s)

type Message

type Message struct {
	MessageType MessageType `json:MessageType`
	Event       string      `json:Event,omitempty`
	RequestId   string      `json:RequestId,omitempty`
	// ReplyTo         string      `json:ReplyTo,omitempty`
	ReplyClientId   string   `json:ReplyClientId,omitempty`
	RequestClientId string   `json:RequestClientId,omitempty`
	Payload         *Payload `json:Payload`
}

type MessageType

type MessageType int

type Payload

type Payload map[string]interface{}

func NewPayload

func NewPayload() Payload

type Received

type Received struct {
	Message *Message
	Err     error
}

Directories

Path Synopsis
Godeps
_workspace/src/github.com/gorilla/websocket
Package websocket implements the WebSocket protocol defined in RFC 6455.
Package websocket implements the WebSocket protocol defined in RFC 6455.
_workspace/src/github.com/gorilla/websocket/examples/autobahn
Command server is a test server for the Autobahn WebSockets Test Suite.
Command server is a test server for the Autobahn WebSockets Test Suite.
_workspace/src/github.com/nu7hatch/gouuid
This package provides immutable UUID structs and the functions NewV3, NewV4, NewV5 and Parse() for generating versions 3, 4 and 5 UUIDs as specified in RFC 4122.
This package provides immutable UUID structs and the functions NewV3, NewV4, NewV5 and Parse() for generating versions 3, 4 and 5 UUIDs as specified in RFC 4122.

Jump to

Keyboard shortcuts

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