socket2em

package module
v0.0.0-...-93a4278 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2018 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TCP_DEFAULT_CONN_HOST = "localhost"
	TCP_DEFAULT_CONN_PORT = 3333
	TCP_DEFAULT_CONN_TYPE = "tcp"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Method string `json:"method"`
	// Data   interface{} `json:"data"`
	Data json.RawMessage `json:data`
}

type Response

type Response struct {
	Status string      `json:"status"`
	Data   interface{} `json:"data"`
}

type Server

type Server struct {
	Host           string
	Port           int
	ConnType       string
	NumClients     int
	LoggingHandler func(string)
	OnDisconnect   func(string)
	MethodHandlers map[string]func(Message, net.Conn)
	Clients        map[int]net.Conn
	// contains filtered or unexported fields
}

func (*Server) Broadcast

func (self *Server) Broadcast(message string)

func (*Server) GetNumClients

func (self *Server) GetNumClients() int

func (Server) HandleError

func (self Server) HandleError(err error, conn net.Conn)

func (Server) HandleSuccess

func (self Server) HandleSuccess(data string, conn net.Conn)

func (*Server) Help

func (self *Server) Help() string

func (*Server) Log

func (self *Server) Log(message ...string)

func (*Server) RegisterMethod

func (self *Server) RegisterMethod(method string, function func(Message, net.Conn)) error

func (Server) SendResponseFromStruct

func (self Server) SendResponseFromStruct(data interface{}, conn net.Conn)

func (*Server) Shutdown

func (self *Server) Shutdown()

func (*Server) Start

func (self *Server) Start()

Jump to

Keyboard shortcuts

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