Documentation
¶
Index ¶
- func CatchPanic(err *error, goRoutine string, functionName string)
- func NewError(s string) error
- func NewErrorContext(s string, context interface{}) error
- type CloseReason
- type Codec
- type Error
- type Event
- type EventHandler
- type EventHooker
- type EventQueue
- type MessageTransmitter
- type Meta
- type Peer
- type PeerListener
- type PeerProperty
- type Pipe
- type Processor
- type Session
- type SessionAccepted
- type SessionAccessor
- type SessionCloseNotify
- type SessionClosed
- type SessionConnectError
- type SessionConnected
- type SessionInit
- type SessionManager
- type TCPAcceptor
- type TCPConnector
- type TCPSocketOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CatchPanic ¶
CatchPanic is used to catch any Panic and log exceptions to Stdout. It will also write the stack trace.
func NewErrorContext ¶
Types ¶
type CloseReason ¶
type CloseReason int32
const ( CloseReason_IO CloseReason = iota // 普通IO断开 CloseReason_Manual // 关闭前,调用过Session.Close )
func (CloseReason) String ¶
func (r CloseReason) String() string
type EventHandler ¶
type EventHandler func(e Event)
type EventHooker ¶
type EventQueue ¶
type EventQueue interface {
StartLoop() EventQueue
StopLoop() EventQueue
Wait()
Post(callback func())
}
type MessageTransmitter ¶
type Peer ¶
type Peer interface {
PeerProperty
Start() Peer
Stop()
TypeName() string
}
type PeerListener ¶
type PeerListener interface {
Port() int
}
type PeerProperty ¶
type PeerProperty interface {
Name() string
Address() string
Queue() EventQueue
SetName(string)
SetAddress(string)
SetQueue(EventQueue)
}
type Pipe ¶
type Pipe struct {
// contains filtered or unexported fields
}
不限制大小,添加不发生阻塞,接收阻塞等待
type Processor ¶
type Processor interface {
SetHooker(h EventHooker)
SetTransmitter(t MessageTransmitter)
SetHandler(handler EventHandler)
ReadMessage(s Session) (msg interface{}, err error)
SendMessage(e Event)
ProcessEvent(e Event)
}
type SessionAccepted ¶
type SessionAccepted struct{}
func (*SessionAccepted) String ¶
func (s *SessionAccepted) String() string
func (*SessionAccepted) SystemMessage ¶
func (s *SessionAccepted) SystemMessage()
type SessionAccessor ¶
type SessionCloseNotify ¶
type SessionCloseNotify struct{}
udp通知关闭,内部使用
func (*SessionCloseNotify) String ¶
func (s *SessionCloseNotify) String() string
func (*SessionCloseNotify) SystemMessage ¶
func (s *SessionCloseNotify) SystemMessage()
type SessionClosed ¶
type SessionClosed struct {
Reason CloseReason // 断开原因
}
func (*SessionClosed) String ¶
func (s *SessionClosed) String() string
func (*SessionClosed) SystemMessage ¶
func (s *SessionClosed) SystemMessage()
type SessionConnectError ¶
type SessionConnectError struct{}
func (*SessionConnectError) String ¶
func (s *SessionConnectError) String() string
func (*SessionConnectError) SystemMessage ¶
func (s *SessionConnectError) SystemMessage()
type SessionConnected ¶
type SessionConnected struct{}
func (*SessionConnected) String ¶
func (s *SessionConnected) String() string
func (*SessionConnected) SystemMessage ¶
func (s *SessionConnected) SystemMessage()
type SessionInit ¶
type SessionInit struct{}
func (*SessionInit) String ¶
func (s *SessionInit) String() string
type SessionManager ¶
type SessionManager interface {
SessionAccessor
Add(s Session)
Remove(s Session)
Count() int
SetIDBase(base int64)
}
type TCPAcceptor ¶
type TCPAcceptor interface {
Peer
PeerListener
SessionAccessor
TCPSocketOption
}
type TCPConnector ¶
type TCPConnector interface {
Peer
PeerListener
TCPSocketOption
SetReconnectDuration(time.Duration)
ReconnectDuration() time.Duration
Session() Session
SetSessionManager(raw interface{})
}
type TCPSocketOption ¶
type TCPSocketOption interface {
// 收发缓冲大小,默认-1
SetSocketBuffer(readBufferSize, writeBufferSize int, noDelay bool)
// 设置最大的封包大小
SetMaxPacketSize(maxSize int)
// 设置读写超时,默认0,不超时
SetSocketDeadline(read, write time.Duration)
ApplySocketOption(conn net.Conn)
MaxPacketSize() int
ApplySocketReadTimeout(conn net.Conn, callback func())
ApplySocketWriteTimeout(conn net.Conn, callback func())
Init()
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.