oortcloud

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

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

Go to latest
Published: Nov 29, 2015 License: MIT Imports: 11 Imported by: 0

README

oortcloud

simple web-socket/sever-sent-event to http translater

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectionIdNotFound = errors.New("oortcloud: connection id not found")

Functions

This section is empty.

Types

type Connection

type Connection interface {
	Send(data []byte) error
}

type ConnectionMap

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

func NewConnectionMap

func NewConnectionMap() *ConnectionMap

func (*ConnectionMap) Delete

func (c *ConnectionMap) Delete(id string)

func (*ConnectionMap) Get

func (c *ConnectionMap) Get(id string) (Connection, bool)

func (*ConnectionMap) New

func (c *ConnectionMap) New(con Connection) string

type Event

type Event struct {
	ConnectionId string
	Type         EventType
	Data         []byte
}

type EventType

type EventType int
const (
	Connect EventType = iota
	Disconnect
	Receive
	Send
)

func (EventType) String

func (t EventType) String() string

type FuncConnection

type FuncConnection struct {
	SendFunc func(data []byte) error
}

func (*FuncConnection) Send

func (c *FuncConnection) Send(data []byte) error

type FuncNotifier

type FuncNotifier struct {
	ConnectFunc    func(con Connection, request *http.Request) (string, *http.Response, error)
	DisconnectFunc func(id string) error
	NotifyFunc     func(id string, data []byte) error
}

func (*FuncNotifier) Connect

func (n *FuncNotifier) Connect(con Connection, request *http.Request) (string, *http.Response, error)

func (*FuncNotifier) Disconnect

func (n *FuncNotifier) Disconnect(id string) error

func (*FuncNotifier) Notify

func (n *FuncNotifier) Notify(id string, data []byte) error

type HTTPNotifier

type HTTPNotifier struct {
	URLs     []string
	BodyType string
	Client   *http.Client
	// contains filtered or unexported fields
}

func NewHTTPNotifier

func NewHTTPNotifier(urls []string) *HTTPNotifier

func (*HTTPNotifier) Connect

func (n *HTTPNotifier) Connect(con Connection, request *http.Request) (string, *http.Response, error)

func (*HTTPNotifier) Disconnect

func (n *HTTPNotifier) Disconnect(id string) error

func (*HTTPNotifier) Notify

func (n *HTTPNotifier) Notify(id string, data []byte) error

func (*HTTPNotifier) ServeHTTP

func (n *HTTPNotifier) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Notifier

type Notifier interface {
	Notify(id string, data []byte) error
	Connect(con Connection, request *http.Request) (string, *http.Response, error)
	Disconnect(id string) error
}

type WebSocketConnection

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

func (*WebSocketConnection) Send

func (c *WebSocketConnection) Send(data []byte) error

type WebSocketConnector

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

func NewWebSocketConnector

func NewWebSocketConnector(notifier Notifier, binary bool) *WebSocketConnector

func (*WebSocketConnector) ServeHTTP

func (c *WebSocketConnector) ServeHTTP(w http.ResponseWriter, req *http.Request)

Handle implements the http.Handler interface

Directories

Path Synopsis
_examples
bench command
chat command
cmd
oortcloud command

Jump to

Keyboard shortcuts

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