engine

package
v0.0.0-...-ea53bbc Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Connection  *sockets.Connection
	Engine      Interface
	Data        interface{}
	Params      interface{}
	RequestData []byte
}

func (*Context) GetDataMap

func (C *Context) GetDataMap() map[string]interface{}

func (*Context) JSON

func (C *Context) JSON(data []byte)

func (Context) New

func (C Context) New(connection *sockets.Connection, engine Interface) *Context

type Engine

type Engine struct {
	Handlers           map[string][]*Handler
	Collection         sockets.CollectionInterface
	HandshakeProcessor handshake.Interface
}

func (*Engine) AddCommand

func (E *Engine) AddCommand(command string, handlers ...HandlerFunc)

func (*Engine) AddHandler

func (E *Engine) AddHandler(command string, method HandlerMethod, handlers ...HandlerFunc) error

func (*Engine) AddJSON

func (E *Engine) AddJSON(command string, handlers ...HandlerFunc)

func (*Engine) GetCollection

func (E *Engine) GetCollection() sockets.CollectionInterface

func (Engine) New

func (E Engine) New(collection sockets.CollectionInterface, handshakeProcessor handshake.Interface) *Engine

func (*Engine) ParseData

func (E *Engine) ParseData(input []byte) (HandlerMethod, sockets.Request)

func (*Engine) ReadMessage

func (E *Engine) ReadMessage(connection *sockets.Connection, msg []byte)

func (*Engine) ReadMessageWithEngine

func (E *Engine) ReadMessageWithEngine(connection *sockets.Connection, msg []byte, engine Interface)

func (*Engine) Run

func (E *Engine) Run()

type Handler

type Handler struct {
	Method      HandlerMethod
	HandlerFunc HandlerFunc
}

type HandlerFunc

type HandlerFunc func(context *Context)

type HandlerMethod

type HandlerMethod int
const (
	COMMAND_HANDLER HandlerMethod = 0
	JSON_HANDLER    HandlerMethod = 1
)

type Interface

type Interface interface {
	AddCommand(command string, handlers ...HandlerFunc)
	AddHandler(command string, method HandlerMethod, handlers ...HandlerFunc) error
	AddJSON(command string, handlers ...HandlerFunc)
	GetCollection() sockets.CollectionInterface
	ReadMessage(connection *sockets.Connection, msg []byte)
	Run()
}

Jump to

Keyboard shortcuts

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