network

package
v0.0.0-...-3c4aecd Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: MulanPSL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsyncCallLen

func AsyncCallLen(value int) func(s *serverconfig)

func EventChanLen

func EventChanLen(value int) func(s *serverconfig)

func HTTPHandleFuncs

func HTTPHandleFuncs(handles ...HTTPHandleFunc) func(s *serverconfig)

func HTTPHandlers

func HTTPHandlers(handles ...HTTPHandler) func(s *serverconfig)

func HTTPTimeout

func HTTPTimeout(value int) func(s *serverconfig)

func Keepalived

func Keepalived(interval, limit int) func(s *serverconfig)

func Listen

func Listen(addr string) func(s *serverconfig)

func MaxConnectNumber

func MaxConnectNumber(fn func() int) func(s *serverconfig)

func MaxMsgLen

func MaxMsgLen(value int) func(s *serverconfig)

func MsgLenBytes

func MsgLenBytes(value int) func(s *serverconfig)

func NewAgent

func NewAgent(id int64, conn union.Conn, mgr iMgr) hotpot.IAgent

NewAgent 创建Agent

func ReadTimeOut

func ReadTimeOut(value int) func(s *serverconfig)

func SSL

func SSL(certFile, keyFile string) func(s *serverconfig)

func Schema

func Schema(schema string) func(s *serverconfig)

"tcp", "tcp4", "tcp6"

func Serialize

func Serialize(value codec.Type) func(s *serverconfig)

func Serve

func Serve(addr string, options ...Option) hotpot.IAgentMgr

func StaticMaxConnectNumber

func StaticMaxConnectNumber(value int) func(s *serverconfig)

func TextMsg

func TextMsg(enable bool) func(s *serverconfig)

Types

type AgentMgr

type AgentMgr struct {
	sync.Mutex
	// contains filtered or unexported fields
}

AgentMgr 服务器基础类

func (*AgentMgr) AddAgent

func (am *AgentMgr) AddAgent(a hotpot.IAgent)

AddAgent 增加Agent

func (*AgentMgr) Agents

func (am *AgentMgr) Agents() []hotpot.IAgent

Agents 遍历全服Agent

func (*AgentMgr) DelAgent

func (am *AgentMgr) DelAgent(a hotpot.IAgent)

DelAgent 移除Agent

func (*AgentMgr) Error

func (am *AgentMgr) Error(cb func(err error) union.Conn)

Error 连接错误时回调

func (*AgentMgr) Get

func (am *AgentMgr) Get(id int64) hotpot.IAgent

Get 获取agent

func (*AgentMgr) IsServerRuning

func (am *AgentMgr) IsServerRuning() bool

IsServerRuning 查询服务器是否启动(监听)

func (*AgentMgr) Len

func (am *AgentMgr) Len() (count int)

Len 管理的Agent数量

func (*AgentMgr) OnError

func (am *AgentMgr) OnError(err error) union.Conn

OnError 错误时回调

func (*AgentMgr) OnReceived

func (am *AgentMgr) OnReceived(msg []byte) []byte

OnReceived 收到消息时回调

func (*AgentMgr) OnSend

func (am *AgentMgr) OnSend(msg []byte, keepalived bool) []byte

OnSend 发送消息前回调

func (*AgentMgr) Received

func (am *AgentMgr) Received(cb func(msg []byte) []byte)

Received 收到消息时回调

func (*AgentMgr) Send

func (am *AgentMgr) Send(cb func(msg []byte, keepalived bool) []byte)

Send 发送消息前回调

func (*AgentMgr) Shutdown

func (am *AgentMgr) Shutdown(immediately bool)

Shutdown 关服

type HTTPHandleFunc

type HTTPHandleFunc struct {
	Pattern string
	Handle  func(http.ResponseWriter, *http.Request)
}

type HTTPHandler

type HTTPHandler struct {
	Pattern string
	Handler http.Handler
}

type Option

type Option func(*serverconfig)

配置选项

type TCPServer

type TCPServer struct {
	*AgentMgr
	// contains filtered or unexported fields
}

TCPServer 服务器

func (*TCPServer) Listen

func (ts *TCPServer) Listen() string

func (*TCPServer) RecvChanLen

func (ts *TCPServer) RecvChanLen() int

func (*TCPServer) SendChanLen

func (ts *TCPServer) SendChanLen() int

func (*TCPServer) SerializeType

func (ts *TCPServer) SerializeType() codec.Type

Serializer 消息序列化类型

func (*TCPServer) Serializer

func (ts *TCPServer) Serializer() codec.Serializer

Serializer 消息序列化方式

func (*TCPServer) Shutdown

func (ts *TCPServer) Shutdown(immediately bool)

Shutdown 停服

func (*TCPServer) Start

func (ts *TCPServer) Start()

Start 启动服务器

func (*TCPServer) WSControlType

func (ts *TCPServer) WSControlType() union.ControlType

websocket 控制类型

type WSServer

type WSServer struct {
	*AgentMgr
	// contains filtered or unexported fields
}

WSServer websocket服务

func (*WSServer) Listen

func (wss *WSServer) Listen() string

func (*WSServer) RecvChanLen

func (wss *WSServer) RecvChanLen() int

func (*WSServer) SendChanLen

func (wss *WSServer) SendChanLen() int

func (*WSServer) SerializeType

func (wss *WSServer) SerializeType() codec.Type

func (*WSServer) Serializer

func (wss *WSServer) Serializer() codec.Serializer

Serializer 消息序列化方式

func (*WSServer) ServeHTTP

func (wss *WSServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*WSServer) Shutdown

func (wss *WSServer) Shutdown(immediately bool)

Shutdown 停服

func (*WSServer) Start

func (wss *WSServer) Start()

Start 启动

func (*WSServer) WSControlType

func (wss *WSServer) WSControlType() union.ControlType

websocket 控制类型

Jump to

Keyboard shortcuts

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