server

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PConfig connection.PacketConfig `json:"packet_config" yaml:"packet_config"`
	Host    string                  `json:"host" yaml:"host"`
	Port    int                     `json:"port" yaml:"port"`
}

func (*Config) Load

func (c *Config) Load(path string) error

func (*Config) Yaml

func (c *Config) Yaml(path string) error

type Context

type Context struct {
	*object.ObjNoCtx
	*pool.Context
	// contains filtered or unexported fields
}

func NewContext added in v1.0.7

func NewContext(parent context.Context) *Context

func (*Context) Connection

func (c *Context) Connection() connection.IConnection

func (*Context) Pack

func (c *Context) Pack() connection.IPacket

func (*Context) Reset

func (c *Context) Reset()

func (*Context) SetConnection

func (c *Context) SetConnection(conn connection.IConnection)

func (*Context) SetPack

func (c *Context) SetPack(pack connection.IPacket)

func (*Context) SetSpanId

func (c *Context) SetSpanId(spanId string)

func (*Context) SetTraceId

func (c *Context) SetTraceId(traceId string)

func (*Context) SpanId

func (c *Context) SpanId() string

func (*Context) TraceId

func (c *Context) TraceId() string

type HostInfo

type HostInfo struct {
	Host string `json:"host" yaml:"host"`
	Port int    `json:"port" yaml:"port"`
}

type IHandler

type IHandler interface {
	Connect(connection.IConnection) error
	Receive(*Context) error
	Close(connection.IConnection) error
	Packet([]byte) (connection.IPacket, error)
}

type IService

type IService interface {
	Listen(host string, port int) error
	Accept() (connection.IConnection, error)
	Close()
	Shutdown()
	IsClosed() bool
}

type Server

type Server struct {
	OnSuccess func(*Server)
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config Config) *Server

func (*Server) Close

func (s *Server) Close(fd uint64) error

func (*Server) Maintain

func (s *Server) Maintain()

func (*Server) Run

func (s *Server) Run()

func (*Server) Send

func (s *Server) Send(pack connection.IPacket, fd int) error

func (*Server) SetHandler

func (s *Server) SetHandler(handler IHandler) *Server

func (*Server) SetService

func (s *Server) SetService(service IService) *Server

func (*Server) Shutdown

func (s *Server) Shutdown()

type TcpService

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

func NewTcpService

func NewTcpService(connMax int) *TcpService

func (*TcpService) Accept

func (t *TcpService) Accept() (connection.IConnection, error)

func (*TcpService) Close

func (t *TcpService) Close()

func (*TcpService) IsClosed added in v0.1.7

func (t *TcpService) IsClosed() bool

func (*TcpService) Listen

func (t *TcpService) Listen(host string, port int) error

func (*TcpService) Shutdown

func (t *TcpService) Shutdown()

type WebSocketService

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

func NewWebSocketService

func NewWebSocketService(connMax int) *WebSocketService

func (*WebSocketService) Accept

func (*WebSocketService) Close

func (t *WebSocketService) Close()

func (*WebSocketService) IsClosed added in v0.1.7

func (t *WebSocketService) IsClosed() bool

func (*WebSocketService) Listen

func (t *WebSocketService) Listen(host string, port int) error

func (*WebSocketService) Shutdown

func (t *WebSocketService) Shutdown()

Jump to

Keyboard shortcuts

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