Documentation ¶
Index ¶
- Constants
- Variables
- func NewFakeConn(node fatchoy.NodeID, addr string) fatchoy.Endpoint
- type Buffer
- func (b *Buffer) PeekBool() bool
- func (b *Buffer) PeekFloat32() float32
- func (b *Buffer) PeekFloat64() float64
- func (b *Buffer) PeekInt() int
- func (b *Buffer) PeekInt16() int16
- func (b *Buffer) PeekInt32() int32
- func (b *Buffer) PeekInt64() int64
- func (b *Buffer) PeekInt8() int8
- func (b *Buffer) PeekUint() uint
- func (b *Buffer) PeekUint16() uint16
- func (b *Buffer) PeekUint32() uint32
- func (b *Buffer) PeekUint64() uint64
- func (b *Buffer) PeekUint8() uint8
- func (b *Buffer) ReadBool() bool
- func (b *Buffer) ReadFloat32() float32
- func (b *Buffer) ReadFloat64() float64
- func (b *Buffer) ReadInt() int
- func (b *Buffer) ReadInt16() int16
- func (b *Buffer) ReadInt32() int32
- func (b *Buffer) ReadInt64() int64
- func (b *Buffer) ReadInt8() int8
- func (b *Buffer) ReadUint() uint
- func (b *Buffer) ReadUint16() uint16
- func (b *Buffer) ReadUint32() uint32
- func (b *Buffer) ReadUint64() uint64
- func (b *Buffer) ReadUint8() uint8
- func (b *Buffer) WriteBool(v bool)
- func (b *Buffer) WriteFloat32(f float32)
- func (b *Buffer) WriteFloat64(f float64)
- func (b *Buffer) WriteInt(n int)
- func (b *Buffer) WriteInt16(n int16)
- func (b *Buffer) WriteInt32(n int32)
- func (b *Buffer) WriteInt64(n int64)
- func (b *Buffer) WriteInt8(n int8)
- func (b *Buffer) WriteUInt8(n uint8)
- func (b *Buffer) WriteUint(n uint)
- func (b *Buffer) WriteUint16(n uint16)
- func (b *Buffer) WriteUint32(n uint32)
- func (b *Buffer) WriteUint64(n uint64)
- type Error
- type FakeConn
- type StreamConn
- func (c *StreamConn) IsClosing() bool
- func (c *StreamConn) NodeID() fatchoy.NodeID
- func (c *StreamConn) RemoteAddr() string
- func (c *StreamConn) SetEncryptPair(encrypt cipher.BlockCryptor, decrypt cipher.BlockCryptor)
- func (c *StreamConn) SetNodeID(node fatchoy.NodeID)
- func (c *StreamConn) SetRemoteAddr(addr string)
- func (c *StreamConn) SetUserData(ud interface{})
- func (c *StreamConn) Stats() *stats.Stats
- func (c *StreamConn) UserData() interface{}
- type TcpConn
- type TcpServer
- type WsConn
- type WsServer
Constants ¶
View Source
const ( StatBytesRecv int = iota // bytes received StatBytesSent // bytes sent StatPacketsRecv // packets received StatPacketsSent // packets sent NumStat )
View Source
const (
WSCONN_MAX_PAYLOAD = 16 * 1024 // 消息最大大小
)
Variables ¶
View Source
var ( ErrConnIsClosing = errors.New("connection is closing when sending") ErrConnOutboundOverflow = errors.New("connection outbound queue overflow") ErrConnForceClose = errors.New("connection forced to close") )
View Source
var ErrBufferOutOfRange = errors.New("buffer out of range")
View Source
var (
TConnReadTimeout = 200
)
View Source
var (
WSConnReadTimeout = 100 * time.Second
)
Functions ¶
func NewFakeConn ¶
func NewFakeConn(node fatchoy.NodeID, addr string) fatchoy.Endpoint
Types ¶
type Buffer ¶ added in v1.1.0
func (*Buffer) PeekFloat32 ¶ added in v1.1.0
func (*Buffer) PeekFloat64 ¶ added in v1.1.0
func (*Buffer) PeekUint16 ¶ added in v1.1.0
func (*Buffer) PeekUint32 ¶ added in v1.1.0
func (*Buffer) PeekUint64 ¶ added in v1.1.0
func (*Buffer) ReadFloat32 ¶ added in v1.1.0
func (*Buffer) ReadFloat64 ¶ added in v1.1.0
func (*Buffer) ReadUint16 ¶ added in v1.1.0
func (*Buffer) ReadUint32 ¶ added in v1.1.0
func (*Buffer) ReadUint64 ¶ added in v1.1.0
func (*Buffer) WriteFloat32 ¶ added in v1.1.0
func (*Buffer) WriteFloat64 ¶ added in v1.1.0
func (*Buffer) WriteInt16 ¶ added in v1.1.0
func (*Buffer) WriteInt32 ¶ added in v1.1.0
func (*Buffer) WriteInt64 ¶ added in v1.1.0
func (*Buffer) WriteUInt8 ¶ added in v1.1.0
func (*Buffer) WriteUint16 ¶ added in v1.1.0
func (*Buffer) WriteUint32 ¶ added in v1.1.0
func (*Buffer) WriteUint64 ¶ added in v1.1.0
type FakeConn ¶
type FakeConn struct {
StreamConn
}
a fake endpoint
func (*FakeConn) ForceClose ¶
func (*FakeConn) SendPacket ¶
type StreamConn ¶
type StreamConn struct {
// contains filtered or unexported fields
}
TcpConn和WsConn的公共基类
func (*StreamConn) IsClosing ¶
func (c *StreamConn) IsClosing() bool
func (*StreamConn) NodeID ¶
func (c *StreamConn) NodeID() fatchoy.NodeID
func (*StreamConn) RemoteAddr ¶
func (c *StreamConn) RemoteAddr() string
func (*StreamConn) SetEncryptPair ¶
func (c *StreamConn) SetEncryptPair(encrypt cipher.BlockCryptor, decrypt cipher.BlockCryptor)
func (*StreamConn) SetNodeID ¶
func (c *StreamConn) SetNodeID(node fatchoy.NodeID)
func (*StreamConn) SetRemoteAddr ¶
func (c *StreamConn) SetRemoteAddr(addr string)
func (*StreamConn) SetUserData ¶
func (c *StreamConn) SetUserData(ud interface{})
func (*StreamConn) Stats ¶
func (c *StreamConn) Stats() *stats.Stats
func (*StreamConn) UserData ¶
func (c *StreamConn) UserData() interface{}
type TcpConn ¶
type TcpConn struct { StreamConn // contains filtered or unexported fields }
TCP connection
func NewTcpConn ¶
func (*TcpConn) ForceClose ¶
func (*TcpConn) OutboundQueue ¶
func (t *TcpConn) OutboundQueue() chan fatchoy.IPacket
func (*TcpConn) SendPacket ¶
type TcpServer ¶
type TcpServer struct {
// contains filtered or unexported fields
}
func NewTcpServer ¶
func (*TcpServer) BacklogChan ¶
func (s *TcpServer) BacklogChan() chan fatchoy.Endpoint
type WsConn ¶
type WsConn struct { StreamConn // contains filtered or unexported fields }
Websocket connection
func (*WsConn) ForceClose ¶
func (*WsConn) SendPacket ¶
type WsServer ¶
type WsServer struct {
// contains filtered or unexported fields
}
Websocket server
func NewWebsocketServer ¶
func (*WsServer) BacklogChan ¶
Click to show internal directories.
Click to hide internal directories.