eio

package
v0.0.0-...-4ea3bf1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnknownTransport = iota
	UnknownSid
	BadHandshakeMethod
	BadRequest
	Forbidden
)

Variables

This section is empty.

Functions

func GenerateID

func GenerateID() (string, error)

Types

type Broadcaster

type Broadcaster struct {
	Publisher chan<- interface{}
	// contains filtered or unexported fields
}

type Config

type Config struct {
	PingTimeout    int
	PingInterval   int
	UpgradeTimeout int
}

type ConnectHandlerFunc

type ConnectHandlerFunc func(socket *Socket)

type MessageHandlerFunc

type MessageHandlerFunc func(socket *Socket, data []byte, isBinary bool)

type ReadyState

type ReadyState int
const (
	ReadyStateOpening ReadyState = iota
	ReadyStateOpen
	ReadyStateClosing
	ReadyStateClosed
)

type RequestError

type RequestError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type Server

type Server struct {
	MsgHandler     MessageHandlerFunc
	ConnectHandler ConnectHandlerFunc

	Path         string
	PingInterval time.Duration
	PingTimeout  time.Duration

	//poll
	MaxHttpBufferSize uint64
	HttpCompression   bool

	PerMessageDeflate bool
	// contains filtered or unexported fields
}

func NewServer

func NewServer(path string, packet bytes.Buffer) (*Server, error)

func (*Server) HandleUpgrade

func (s *Server) HandleUpgrade(query url.Values, w http.ResponseWriter, r *http.Request)

func (*Server) Handshake

func (s *Server) Handshake(query url.Values, w http.ResponseWriter, r *http.Request)

func (*Server) OnConnection

func (s *Server) OnConnection(handlerFunc ConnectHandlerFunc)

func (*Server) OnMessage

func (s *Server) OnMessage(handlerFunc MessageHandlerFunc)

if sync is set the message handler gets called in a synchronized manner so you don't have to synchronize access to data.

func (*Server) SendError

func (s *Server) SendError(w http.ResponseWriter, r *http.Request, errCode int)

func (*Server) ServeHTTP

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

func (*Server) VerifyRequest

func (s *Server) VerifyRequest(query url.Values, r *http.Request, upgrade bool) (bool, int)

type Socket

type Socket struct {
	Id string

	Transport transport.ITransport
	// contains filtered or unexported fields
}

func NewSocket

func NewSocket(id string, server *Server, transport transport.ITransport, req *http.Request) *Socket

func (*Socket) Close

func (s *Socket) Close()

func (*Socket) HandleTransport

func (s *Socket) HandleTransport(transport transport.ITransport, upgrading bool)

func (*Socket) Open

func (s *Socket) Open()

func (*Socket) SendMessage

func (s *Socket) SendMessage(data []byte, isBinary bool)

type UpgradeState

type UpgradeState int
const (
	UpgradeStateNone UpgradeState = iota
	UpgradeStateUpgrading
	UpgradeStateUpgraded
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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