hub

package
v0.0.0-...-9403371 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2015 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeError       = "Error"
	TypeHeartbeat   = "Heartbeat"
	TypeWelcome     = "Welcome"
	TypeSubscribe   = "Subscribe"
	TypeUnsubscribe = "Unsubscribe"
	TypeMessage     = "Message"
	TypeAuthorize   = "Authorize"
	TypeAck         = "Ack"
)
View Source
const (
	TypeJSONError          = "JSONError"
	TypeAuthorizationError = "AuthorizationError"
	TypeSyntaxError        = "SyntaxError"
)

Variables

This section is empty.

Functions

func Connect

func Connect(session_id, origin, location string) (OutgoingMessage, IncomingMessage)

Types

type Authorizer

type Authorizer func(uri, token string, write bool) (authorized bool, err error)

type Error

type Error struct {
	Message string
	Type    ErrorType
}

type ErrorType

type ErrorType string

type IncomingMessage

type IncomingMessage <-chan Message

func (IncomingMessage) Next

func (in IncomingMessage) Next(msg_type MessageType) Message

type Message

type Message struct {
	Type    MessageType
	Id      string      `json:",omitempty"`
	Welcome *Welcome    `json:",omitempty"`
	Error   *Error      `json:",omitempty"`
	Data    interface{} `json:",omitempty"`
	URI     string      `json:",omitempty"`
	Token   string      `json:",omitempty"`
	Write   bool        `json:",omitempty"`
}

type MessagePipe

type MessagePipe interface {
	Close() error
	ReceiveMessage() (*Message, error)
	SendMessage(*Message) error
}

type MessageType

type MessageType string

type OutgoingMessage

type OutgoingMessage chan<- Message

type PusherSessionStats

type PusherSessionStats map[string]int

type PusherStats

type PusherStats struct {
	Sessions      map[string]PusherSessionStats            `json:"sessions"`
	Subscriptions map[string]map[string]PusherSessionStats `json:"subscriptions"`
	Subscribers   []string                                 `json:"subscribers"`
}

type Server

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

func NewServer

func NewServer() *Server

func StartServer

func StartServer() (net.Listener, *Server)

func (*Server) Authorizer

func (self *Server) Authorizer(f Authorizer) *Server

func (*Server) Close

func (self *Server) Close()

func (*Server) Debugf

func (self *Server) Debugf(f string, i ...interface{})

func (*Server) Emit

func (self *Server) Emit(message Message)

func (*Server) Errorf

func (self *Server) Errorf(fmt string, i ...interface{})

func (*Server) Fatalf

func (self *Server) Fatalf(fmt string, i ...interface{})

func (*Server) GetSession

func (self *Server) GetSession(id string) (result *Session)

func (*Server) Infof

func (self *Server) Infof(fmt string, i ...interface{})

func (*Server) InternalPipe

func (hub *Server) InternalPipe(session_id string) (*Session, OutgoingMessage, IncomingMessage)

func (*Server) Logger

func (self *Server) Logger(l *log.Logger) *Server

func (*Server) Loglevel

func (self *Server) Loglevel(i int) *Server

func (*Server) ServeHTTP

func (self *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Stats

func (self *Server) Stats() PusherStats

type Session

type Session struct {
	RemoteAddr string
	// contains filtered or unexported fields
}

func (*Session) Handle

func (self *Session) Handle(ws MessagePipe)

* Handle works as the session main-loop listening on events * on a websocket or other source that implements io.ReadWriteCloser.

type Welcome

type Welcome struct {
	Heartbeat          time.Duration
	HeartbeatGracetime time.Duration
	SessionTimeout     time.Duration
	Id                 string
}

Jump to

Keyboard shortcuts

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