ws

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2015 License: BSD-2-Clause Imports: 7 Imported by: 0

README

Pivo/Websocket

Websocket connector for the Pivo package

Getting started

Documentation
Installation

Install the Pivo library using the following go command.

$ go get gopkg.in/pivo.v1
Dependencies

The Pivo/Websocket connector depends on the Gorilla Websocket library.

$ go get github.com/gorilla/websocket

License

Use of this source code is governed by a Simplified BSD license that can be found in the LICENSE file.

Documentation

Overview

Package ws implements the Pivo/Websocket connector.

Index

Constants

View Source
const DefaultPingTimeout = 60

Default ping timeout value in seconds

View Source
const DefaultPortBufferSize = 64

Default port buffer size

View Source
const DefaultReadBufferSize = 1024

Default read buffer size

View Source
const DefaultWriteBufferSize = 1024

Default write buffer size

View Source
const DefaultWriteTimeout = 10

Default write timeout value in seconds

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {

	// Ping timeout
	PingTimeout time.Duration

	// Write timeout
	WriteTimeout time.Duration

	// Port buffer size
	PortBufferSize int

	// Those settings are only used by upgraders.
	// See http://godoc.org/github.com/gorilla/websocket#Upgrader
	CheckOrigin     func(*http.Request) bool
	ReadBufferSize  int
	WriteBufferSize int
	// contains filtered or unexported fields
}

Conn specifies parameters for this connector.

func NewConn

func NewConn() *Conn

NewConn instantiate a connector with default settings.

func (*Conn) Close

func (c *Conn) Close(err error) error

Close sends a closure message to the remote end.

func (*Conn) Dial

func (c *Conn) Dial(url string, h http.Header) (*Conn, *http.Response, error)

Dial opens a connection to the given URL with the provided header.

func (*Conn) Receiver

func (c *Conn) Receiver(rc pivo.OnReadCloser) error

Receiver is an event loop that either calls OnCloser if the connection has terminated or OnReader when data has been read from the socket.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the IP address of the remote end.

func (*Conn) Sender

func (c *Conn) Sender() chan []byte

Sender kicks off a goroutine reading from the returned channel and writing the bytes harvested through the socket. The goroutine will run until one of the following conditions are met:

1. The returned channel has been closed 2. An error occured writing on the socket 3. A ping timeout occured.

func (*Conn) Upgrade

func (c *Conn) Upgrade(w http.ResponseWriter, r *http.Request, h http.Header) error

Upgrade tries to upgrade an HTTP request to a Websocket session.

Directories

Path Synopsis
bin

Jump to

Keyboard shortcuts

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