socket

package
v0.0.0-...-e5c2c3a Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseMessage

type BaseMessage struct {
	Path string `json:"p"`
	Data string `json:"d"`
}

func NewBaseMessage

func NewBaseMessage(path string, data interface{}) (*BaseMessage, error)

type Client

type Client struct {
	Out     chan *BaseMessage
	FatalCh chan error
	Conn    *websocket.Conn
}

func NewClient

func NewClient(ws *websocket.Conn) *Client

func (*Client) Close

func (c *Client) Close()

func (*Client) Fatal

func (c *Client) Fatal(err error)

func (*Client) Send

func (c *Client) Send(msg *BaseMessage)

func (*Client) SendError

func (c *Client) SendError(err error)

type ErrorMessage

type ErrorMessage struct {
	Error string `json:"error"`
}

type Handler

type Handler func(r *Request, client *Client)

type Request

type Request struct {
	Path string
	Data []byte
}

func (*Request) Decode

func (r *Request) Decode(s interface{}) error

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) Handle

func (u *Server) Handle(path string, handler Handler)

func (*Server) Server

func (u *Server) Server(ws *websocket.Conn)

Jump to

Keyboard shortcuts

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