Documentation ¶
Index ¶
- Constants
- Variables
- func PrintPanicStack()
- type NetConnIF
- type NetPacket
- type TCPSession
- func (s *TCPSession) Close()
- func (s *TCPSession) DirectSend(packet *NetPacket) bool
- func (s *TCPSession) DirectSendAndClose(packet *NetPacket)
- func (s *TCPSession) HandleConn(filter func(*NetPacket) bool)
- func (s *TCPSession) IsClosed() bool
- func (s *TCPSession) ParsePacket(pkt []byte) *NetPacket
- func (s *TCPSession) ReadLoop(filter func(*NetPacket) bool)
- func (s *TCPSession) RemoteAddr() net.Addr
- func (s *TCPSession) RemoteIp() string
- func (s *TCPSession) Send(packet *NetPacket) bool
- func (s *TCPSession) SendLoop()
- func (s *TCPSession) SetCipher(encodeKey, decodeKey []byte) error
- func (s *TCPSession) SetParameter(readDelay, sendDelay time.Duration, maxRecvSize uint32, sendFullClose bool)
- func (s *TCPSession) SetRpmParameter(rpmLimit uint32, rpmInterval int64, msg *NetPacket)
- func (s *TCPSession) TraceErrorf(format string, a ...interface{})
- func (s *TCPSession) TraceFinish(traceDefer func(*expvar.Map, int64))
- func (s *TCPSession) TracePrintf(format string, a ...interface{})
- func (s *TCPSession) TraceStart(family, title string, expvar bool)
Constants ¶
View Source
const ( //消息报头字节数 HEAD_SIZE = 4 //消息号占用的字节数 MSG_ID_SIZE = 2 )
View Source
const ( SESS_KEYEXCG = 0x1 // 是否已经交换完毕KEY SESS_ENCRYPT = 0x2 // 是否可以开始加密 )
View Source
const (
PACKET_LIMIT = 65536
)
Variables ¶
View Source
var (
ServerEndian = binary.LittleEndian
)
Functions ¶
Types ¶
type NetPacket ¶
type NetPacket struct { MsgId uint16 Data []byte Session *TCPSession }
type TCPSession ¶
type TCPSession struct { //*net.TCPConn Conn NetConnIF SendChan chan *NetPacket ReadChan chan *NetPacket //离线消息管道,用于外部接收连接断开的消息并处理后续 OffChan chan int64 // ID SessionId int64 // 会话标记 Flag int32 // Declares how many times we will try to resend message MaxSendRetries int CloseState chanutil.DoneChan OnLineTime int64 OffLineTime int64 EncodeKey []byte DecodeKey []byte // contains filtered or unexported fields }
func NewSession ¶
func NewSession(conn NetConnIF, readChan, sendChan chan *NetPacket, offChan chan int64) *TCPSession
func (*TCPSession) Close ¶
func (s *TCPSession) Close()
func (*TCPSession) DirectSend ¶
func (s *TCPSession) DirectSend(packet *NetPacket) bool
func (*TCPSession) DirectSendAndClose ¶ added in v1.1.2
func (s *TCPSession) DirectSendAndClose(packet *NetPacket)
func (*TCPSession) HandleConn ¶
func (s *TCPSession) HandleConn(filter func(*NetPacket) bool)
func (*TCPSession) IsClosed ¶ added in v1.0.7
func (s *TCPSession) IsClosed() bool
func (*TCPSession) ParsePacket ¶
func (s *TCPSession) ParsePacket(pkt []byte) *NetPacket
func (*TCPSession) ReadLoop ¶
func (s *TCPSession) ReadLoop(filter func(*NetPacket) bool)
func (*TCPSession) Send ¶
func (s *TCPSession) Send(packet *NetPacket) bool
func (*TCPSession) SendLoop ¶ added in v1.0.7
func (s *TCPSession) SendLoop()
func (*TCPSession) SetCipher ¶
func (s *TCPSession) SetCipher(encodeKey, decodeKey []byte) error
RC4加密解密
func (*TCPSession) SetParameter ¶
func (s *TCPSession) SetParameter(readDelay, sendDelay time.Duration, maxRecvSize uint32, sendFullClose bool)
设置链接参数
func (*TCPSession) SetRpmParameter ¶
func (s *TCPSession) SetRpmParameter(rpmLimit uint32, rpmInterval int64, msg *NetPacket)
包频率控制参数
func (*TCPSession) TraceErrorf ¶ added in v1.0.10
func (s *TCPSession) TraceErrorf(format string, a ...interface{})
func (*TCPSession) TraceFinish ¶ added in v1.0.10
func (s *TCPSession) TraceFinish(traceDefer func(*expvar.Map, int64))
func (*TCPSession) TracePrintf ¶ added in v1.0.10
func (s *TCPSession) TracePrintf(format string, a ...interface{})
func (*TCPSession) TraceStart ¶ added in v1.0.10
func (s *TCPSession) TraceStart(family, title string, expvar bool)
Click to show internal directories.
Click to hide internal directories.