Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbstractSession ¶
type AbstractSession struct {
// contains filtered or unexported fields
}
func (*AbstractSession) GetUserData ¶
func (s *AbstractSession) GetUserData() any
func (*AbstractSession) SetUserData ¶
func (s *AbstractSession) SetUserData(d any)
type Packet ¶
type Packet struct { Type PacketType Data []byte // contains filtered or unexported fields }
Packet 连接状态也通过该数据包回调
type PacketType ¶
type PacketType int
const ( PacketTypeConnected PacketType = 0 // 连接成功 PacketTypeConnectLost PacketType = 1 // 连接断开 PacketTypeData PacketType = 2 // 数据包 )
func (PacketType) ToString ¶
func (p PacketType) ToString() string
type Session ¶
type Session interface { Write(packet *Packet) error GetAddress() string SetUserData(d any) GetUserData() any }
Session 会话接口
type TcpServer ¶
type TcpServer struct { core.AbstractSubject[*Packet] // contains filtered or unexported fields }
func NewTcpServer ¶
type TcpSession ¶
type TcpSession struct { AbstractSession // contains filtered or unexported fields }
func (*TcpSession) GetAddress ¶
func (s *TcpSession) GetAddress() string
func (*TcpSession) Write ¶
func (s *TcpSession) Write(packet *Packet) error
Click to show internal directories.
Click to hide internal directories.