network

package
v0.0.0-...-9421834 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTcpServer

func NewTcpServer(cfg string) interfaces.IServer

func RegistHead

func RegistHead(head interfaces.IHead)

Types

type HeadBase

type HeadBase struct {
}

func (*HeadBase) Check

func (h *HeadBase) Check() error

func (*HeadBase) GetBodyLen

func (h *HeadBase) GetBodyLen() uint32

func (*HeadBase) GetHeadLen

func (h *HeadBase) GetHeadLen() uint32

func (*HeadBase) GetOpcode

func (h *HeadBase) GetOpcode() uint32

func (*HeadBase) Marshal

func (h *HeadBase) Marshal() []byte

func (*HeadBase) PreHandle

func (h *HeadBase) PreHandle(buf []byte) ([]byte, error)

func (*HeadBase) PreSend

func (h *HeadBase) PreSend(buf []byte) ([]byte, error)

func (*HeadBase) SetBodyLen

func (h *HeadBase) SetBodyLen(uint32)

func (*HeadBase) SetHeadLen

func (h *HeadBase) SetHeadLen(l uint32)

func (*HeadBase) SetOpcode

func (h *HeadBase) SetOpcode(uint32)

func (*HeadBase) UnMarshal

func (h *HeadBase) UnMarshal(buf []byte) error

type Request

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

func (*Request) GetMsg

func (r *Request) GetMsg() []byte

func (*Request) GetOpcode

func (r *Request) GetOpcode() uint32

func (*Request) GetSessionID

func (r *Request) GetSessionID() string

type Response

type Response struct {
	Opcode uint32
	Msg    []byte
}

type Session

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

func NewSession

func NewSession(conn net.Conn, server interfaces.IServer) (*Session, error)

func (*Session) GetRemoteAddr

func (s *Session) GetRemoteAddr() string

func (*Session) GetSessionID

func (s *Session) GetSessionID() string

func (*Session) PushMsg

func (s *Session) PushMsg(opcode uint32, msg []byte)

func (*Session) Start

func (s *Session) Start()

func (*Session) Stop

func (s *Session) Stop()

type SessionMgr

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

func NewSessionManage

func NewSessionManage() *SessionMgr

func (*SessionMgr) Add

func (sm *SessionMgr) Add(s interfaces.ISession)

func (*SessionMgr) GetSession

func (sm *SessionMgr) GetSession(sid string) interfaces.ISession

func (*SessionMgr) Len

func (sm *SessionMgr) Len() uint32

func (*SessionMgr) Remove

func (sm *SessionMgr) Remove(sid string)

func (*SessionMgr) RemoveAll

func (sm *SessionMgr) RemoveAll()

func (*SessionMgr) Size

func (sm *SessionMgr) Size() uint32

func (*SessionMgr) Start

func (sm *SessionMgr) Start()

func (*SessionMgr) Stop

func (sm *SessionMgr) Stop()

type TcpServer

type TcpServer struct {
	Addr         string
	SessionMgr   interfaces.ISessionMgr
	HandlerMgr   interfaces.IHandleMgr
	OnConnect    interfaces.NotifyCallback
	OnDisConnect interfaces.NotifyCallback
	// contains filtered or unexported fields
}

func (*TcpServer) CallOnConnect

func (s *TcpServer) CallOnConnect(sid string)

func (*TcpServer) CallOnDisConnect

func (s *TcpServer) CallOnDisConnect(sid string)

func (*TcpServer) GetHandleMgr

func (s *TcpServer) GetHandleMgr() interfaces.IHandleMgr

func (*TcpServer) GetSessionMgr

func (s *TcpServer) GetSessionMgr() interfaces.ISessionMgr

func (*TcpServer) Push

func (s *TcpServer) Push(sid string, opcode uint32, msg []byte)

func (*TcpServer) RegisterOnConnect

func (s *TcpServer) RegisterOnConnect(connect interfaces.NotifyCallback)

func (*TcpServer) RegisterOnDisConnect

func (s *TcpServer) RegisterOnDisConnect(disconnect interfaces.NotifyCallback)

func (*TcpServer) RegisterRouter

func (s *TcpServer) RegisterRouter(id uint32, router interfaces.RouterCallback)

func (*TcpServer) Serve

func (s *TcpServer) Serve()

func (*TcpServer) Stop

func (s *TcpServer) Stop()

Jump to

Keyboard shortcuts

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