Documentation ¶
Index ¶
- Constants
- Variables
- type ClientClose
- type ClientSocket
- func (c *ClientSocket) Connect() bool
- func (this *ClientSocket) DoSend(buff []byte) int
- func (c *ClientSocket) Init(ip string, port int, params ...OpOption) bool
- func (c *ClientSocket) OnDisconnect()
- func (c *ClientSocket) OnNetFail(int)
- func (c *ClientSocket) Restart() bool
- func (c *ClientSocket) Run() bool
- func (c *ClientSocket) Send(head rpc.RpcHead, packet rpc.Packet) int
- func (c *ClientSocket) SendMsg(head rpc.RpcHead, funcName string, params ...interface{})
- func (this *ClientSocket) SendPacket(head rpc.RpcHead, funcName string, msg proto.Message) int
- func (c *ClientSocket) Start() bool
- type HandlePacket
- type IClientSocket
- type IServerSocket
- type IServerSocketClient
- type ISocket
- type Op
- type OpOption
- type PacketConfig
- type PacketFunc
- type PacketParser
- type ServerSocket
- func (s *ServerSocket) AddClinet(conn net.Conn, addr string, connectType int) *ServerSocketClient
- func (s *ServerSocket) AssignClientId() uint32
- func (s *ServerSocket) ClientSocket(ctx context.Context) *ServerSocketClient
- func (s *ServerSocket) Close()
- func (s *ServerSocket) Connect() bool
- func (s *ServerSocket) DelClinet(client *ServerSocketClient) bool
- func (s *ServerSocket) Disconnect(bool) bool
- func (s *ServerSocket) GetClientById(id uint32) *ServerSocketClient
- func (s *ServerSocket) Init(ip string, port int, params ...OpOption) bool
- func (s *ServerSocket) LoadClient() *ServerSocketClient
- func (s *ServerSocket) OnNetFail(int)
- func (s *ServerSocket) Restart() bool
- func (s *ServerSocket) Run() bool
- func (s *ServerSocket) RunKcp() bool
- func (s *ServerSocket) Send(head rpc.RpcHead, packet rpc.Packet) int
- func (s *ServerSocket) SendMsg(head rpc.RpcHead, funcName string, params ...interface{})
- func (s *ServerSocket) SendPacket(head rpc.RpcHead, funcName string, packet proto.Message) int
- func (s *ServerSocket) Start() bool
- func (s *ServerSocket) StopClient(id uint32)
- type ServerSocketClient
- func (s *ServerSocketClient) Close()
- func (s *ServerSocketClient) DoSend(buff []byte) int
- func (s *ServerSocketClient) GetProperty() (p any)
- func (s *ServerSocketClient) Init(ip string, port int, params ...OpOption) bool
- func (s *ServerSocketClient) OnNetFail(error int)
- func (s *ServerSocketClient) RemoveProperty()
- func (s *ServerSocketClient) Run() bool
- func (s *ServerSocketClient) Send(head rpc.RpcHead, packet rpc.Packet) int
- func (s *ServerSocketClient) SendLoop() bool
- func (s *ServerSocketClient) SendMsg(head rpc.RpcHead, funcName string, params ...interface{}) int
- func (s *ServerSocketClient) SendPacket(head rpc.RpcHead, funcName string, msg proto.Message) int
- func (s *ServerSocketClient) SetProperty(p any)
- func (s *ServerSocketClient) Start() bool
- func (s *ServerSocketClient) Stop() bool
- func (s *ServerSocketClient) Update()
- type Socket
- func (this *Socket) BindPacketFunc(callfunc PacketFunc)
- func (this *Socket) CallMsg(head rpc.RpcHead, funcName string, params ...interface{})
- func (this *Socket) Clear()
- func (this *Socket) Close()
- func (this *Socket) Connect() bool
- func (this *Socket) Disconnect(bool) bool
- func (this *Socket) GetClientClose() ClientClose
- func (this *Socket) GetId() uint32
- func (this *Socket) GetMaxPacketLen() int
- func (this *Socket) GetReceiveBufferSize() int
- func (this *Socket) GetState() int32
- func (this *Socket) HandlePacket(buff []byte)
- func (this *Socket) Init(ip string, port int, params ...OpOption) bool
- func (this *Socket) OnNetFail(int)
- func (this *Socket) Restart() bool
- func (this *Socket) Run() bool
- func (this *Socket) Send(rpc.RpcHead, rpc.Packet) int
- func (this *Socket) SendMsg(head rpc.RpcHead, funcName string, params ...interface{})
- func (this *Socket) SetClientClose(c ClientClose)
- func (this *Socket) SetConn(conn net.Conn)
- func (this *Socket) SetConnectType(nType int)
- func (this *Socket) SetMaxPacketLen(maxReceiveSize int)
- func (this *Socket) SetReceiveBufferSize(maxSendSize int)
- func (this *Socket) SetState(state int32)
- func (this *Socket) Start() bool
- func (this *Socket) Stop() bool
Constants ¶
View Source
const ( SSF_NULL = iota SSF_RUN = iota SSF_STOP = iota //已经关闭 )
View Source
const ( CLIENT_CONNECT = iota //对外 SERVER_CONNECT = iota //对内 )
View Source
const ( MAX_SEND_CHAN = 512 HEART_TIME_OUT = 60 )
View Source
const ( PACKET_LEN_BYTE = 1 PACKET_LEN_WORD = 2 PACKET_LEN_DWORD = 4 )
View Source
const ( IDLE_TIMEOUT = iota CONNECT_TIMEOUT = iota CONNECT_TYPE = iota )
Variables ¶
View Source
var ( DISCONNECTINT = crc32.ChecksumIEEE([]byte("DISCONNECT")) HEART_PACKET = crc32.ChecksumIEEE([]byte("heardpacket")) )
Functions ¶
This section is empty.
Types ¶
type ClientClose ¶
type ClientSocket ¶
type ClientSocket struct { Socket // contains filtered or unexported fields }
func (*ClientSocket) Connect ¶
func (c *ClientSocket) Connect() bool
func (*ClientSocket) DoSend ¶
func (this *ClientSocket) DoSend(buff []byte) int
func (*ClientSocket) Init ¶
func (c *ClientSocket) Init(ip string, port int, params ...OpOption) bool
func (*ClientSocket) OnDisconnect ¶
func (c *ClientSocket) OnDisconnect()
func (*ClientSocket) OnNetFail ¶
func (c *ClientSocket) OnNetFail(int)
func (*ClientSocket) Restart ¶
func (c *ClientSocket) Restart() bool
func (*ClientSocket) Run ¶
func (c *ClientSocket) Run() bool
func (*ClientSocket) SendMsg ¶
func (c *ClientSocket) SendMsg(head rpc.RpcHead, funcName string, params ...interface{})
func (*ClientSocket) SendPacket ¶
func (*ClientSocket) Start ¶
func (c *ClientSocket) Start() bool
type HandlePacket ¶
type HandlePacket func(buff []byte)
type IClientSocket ¶
type IClientSocket interface { ISocket }
type IServerSocket ¶
type IServerSocket interface { ISocket AssignClientId() uint32 GetClientById(uint32) *ServerSocketClient LoadClient() *ServerSocketClient AddClinet(*net.TCPConn, string, int) *ServerSocketClient DelClinet(*ServerSocketClient) bool StopClient(uint32) }
type IServerSocketClient ¶
type IServerSocketClient interface { ISocket }
type ISocket ¶
type ISocket interface { Init(string, int, ...OpOption) bool Start() bool Stop() bool Run() bool Restart() bool Connect() bool Disconnect(bool) bool OnNetFail(int) Clear() Close() SendMsg(rpc.RpcHead, string, ...interface{}) Send(rpc.RpcHead, rpc.Packet) int CallMsg(rpc.RpcHead, string, ...interface{}) //回调消息处理 GetId() uint32 GetState() int32 SetState(int32) SetReceiveBufferSize(int) GetReceiveBufferSize() int SetMaxPacketLen(int) GetMaxPacketLen() int BindPacketFunc(PacketFunc) SetConnectType(int) SetConn(net.Conn) HandlePacket([]byte) SetClientClose(ClientClose) GetClientClose() ClientClose }
type PacketConfig ¶
type PacketConfig struct { MaxPacketLen *int Func HandlePacket }
-------------- | len | data | --------------
type PacketFunc ¶
type PacketParser ¶
type PacketParser struct {
// contains filtered or unexported fields
}
-------------- | len | data | --------------
func NewPacketParser ¶
func NewPacketParser(conf PacketConfig) PacketParser
func (*PacketParser) Read ¶
func (p *PacketParser) Read(dat []byte) bool
func (*PacketParser) Write ¶
func (p *PacketParser) Write(dat []byte) []byte
type ServerSocket ¶
type ServerSocket struct { Socket // contains filtered or unexported fields }
func (*ServerSocket) AddClinet ¶
func (s *ServerSocket) AddClinet(conn net.Conn, addr string, connectType int) *ServerSocketClient
func (*ServerSocket) AssignClientId ¶
func (s *ServerSocket) AssignClientId() uint32
func (*ServerSocket) ClientSocket ¶
func (s *ServerSocket) ClientSocket(ctx context.Context) *ServerSocketClient
ClientSocket 给客户发送消息
func (*ServerSocket) Close ¶
func (s *ServerSocket) Close()
func (*ServerSocket) Connect ¶
func (s *ServerSocket) Connect() bool
func (*ServerSocket) DelClinet ¶
func (s *ServerSocket) DelClinet(client *ServerSocketClient) bool
func (*ServerSocket) Disconnect ¶
func (s *ServerSocket) Disconnect(bool) bool
func (*ServerSocket) GetClientById ¶
func (s *ServerSocket) GetClientById(id uint32) *ServerSocketClient
func (*ServerSocket) Init ¶
func (s *ServerSocket) Init(ip string, port int, params ...OpOption) bool
func (*ServerSocket) LoadClient ¶
func (s *ServerSocket) LoadClient() *ServerSocketClient
func (*ServerSocket) OnNetFail ¶
func (s *ServerSocket) OnNetFail(int)
func (*ServerSocket) Restart ¶
func (s *ServerSocket) Restart() bool
func (*ServerSocket) Run ¶
func (s *ServerSocket) Run() bool
func (*ServerSocket) RunKcp ¶
func (s *ServerSocket) RunKcp() bool
func (*ServerSocket) SendMsg ¶
func (s *ServerSocket) SendMsg(head rpc.RpcHead, funcName string, params ...interface{})
func (*ServerSocket) SendPacket ¶
func (*ServerSocket) Start ¶
func (s *ServerSocket) Start() bool
func (*ServerSocket) StopClient ¶
func (s *ServerSocket) StopClient(id uint32)
type ServerSocketClient ¶
func (*ServerSocketClient) Close ¶
func (s *ServerSocketClient) Close()
func (*ServerSocketClient) DoSend ¶
func (s *ServerSocketClient) DoSend(buff []byte) int
func (*ServerSocketClient) Init ¶
func (s *ServerSocketClient) Init(ip string, port int, params ...OpOption) bool
func (*ServerSocketClient) OnNetFail ¶
func (s *ServerSocketClient) OnNetFail(error int)
func (*ServerSocketClient) Run ¶
func (s *ServerSocketClient) Run() bool
func (*ServerSocketClient) SendLoop ¶
func (s *ServerSocketClient) SendLoop() bool
func (*ServerSocketClient) SendMsg ¶
func (s *ServerSocketClient) SendMsg(head rpc.RpcHead, funcName string, params ...interface{}) int
func (*ServerSocketClient) SendPacket ¶
func (*ServerSocketClient) Start ¶
func (s *ServerSocketClient) Start() bool
func (*ServerSocketClient) Stop ¶
func (s *ServerSocketClient) Stop() bool
type Socket ¶
type Socket struct {
// contains filtered or unexported fields
}
func (*Socket) BindPacketFunc ¶
func (this *Socket) BindPacketFunc(callfunc PacketFunc)
func (*Socket) Disconnect ¶
func (*Socket) GetClientClose ¶
func (this *Socket) GetClientClose() ClientClose
func (*Socket) GetMaxPacketLen ¶
func (*Socket) GetReceiveBufferSize ¶
func (*Socket) HandlePacket ¶
func (*Socket) SetClientClose ¶
func (this *Socket) SetClientClose(c ClientClose)
func (*Socket) SetConnectType ¶
func (*Socket) SetMaxPacketLen ¶
func (*Socket) SetReceiveBufferSize ¶
Click to show internal directories.
Click to hide internal directories.