websockets

package
v0.0.0-...-8e5ba82 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 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 Client

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

Client is the representation of a listener.

func NewClient

func NewClient(ws *websocket.Conn, server *Server) *Client

NewClient creates a new chat client.

func (*Client) Conn

func (c *Client) Conn() *websocket.Conn

Conn returns the websocket connection

func (*Client) Done

func (c *Client) Done()

Done closes the client

func (*Client) Listen

func (c *Client) Listen()

Listen writes and reads request via channel

func (*Client) Ping

func (c *Client) Ping()

Ping sends a ping message to the client

func (*Client) Write

func (c *Client) Write(msg *Message)

Write sends a message or drops the connection

type Message

type Message struct {
	Data interface{} `json:"data"`
}

Message is the data to send back

type Ping

type Ping struct {
	P int `json:"p"`
}

Ping is a simple ping message

type Server

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

Server represents Websocket server

func NewServer

func NewServer() *Server

NewServer creates new chat server

func (*Server) Add

func (s *Server) Add(c *Client)

Add adds a new client

func (*Server) Del

func (s *Server) Del(c *Client)

Del deletes a client

func (*Server) Done

func (s *Server) Done()

Done closes the server

func (*Server) Err

func (s *Server) Err(err error)

Err sends an error

func (*Server) Listen

func (s *Server) Listen()

Listen and serve. It serves client connection and broadcast request.

func (*Server) OnConnected

func (s *Server) OnConnected(ws *websocket.Conn)

OnConnected is the function to be passed to http.Handle(), wrapped in a websocket.Handler().

func (*Server) Pulse

func (s *Server) Pulse()

Pulse sends a pulse message to keep the connections alive

func (*Server) SendAll

func (s *Server) SendAll(msg *Message)

SendAll sends a broadcast message

Jump to

Keyboard shortcuts

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