server

package
v0.0.0-...-2187358 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_NAMESPACE = "lobby"

	MAX_READ_BUF_SIZE  = 1024
	MAX_WRITE_BUF_SIZE = 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server implements http.Handler and SocketServer

func NewServer

func NewServer(handler connection.ConnectionHandler, nsHandler connection.NamespaceHandler) *Server

func (*Server) Emit

func (s *Server) Emit(eventName string, conn connection.Connection)

func (*Server) On

func (s *Server) On(eventName string, callback ServerEventCallback)

func (*Server) ServeHTTP

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

ServeHTTP handles a connection upgrade request, and handles socket connection admission

type ServerEventCallback

type ServerEventCallback func(connection.Connection)

type SocketServer

type SocketServer interface {
	// On receives a string and a ServerEventCallback function and stores
	// the callback in an internal list, mapped to the given string.
	On(string, ServerEventCallback)
	// Emit receives a string and a Socket connection, and calls every ServerEventCallback
	// mapped to that string, passing the Socket connection as its only argument.
	Emit(string, connection.Connection)
}

Jump to

Keyboard shortcuts

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