Documentation ¶
Index ¶
- Constants
- Variables
- func ConnectTCP(host string, port int) (net.Conn, error)
- func IsConnectionError(_err interface{}) bool
- func IsTemporaryNetError(err error) bool
- func ReadAll(conn io.Reader, data []byte) error
- func ReadLine(conn net.Conn) (string, error)
- func ServeForever(f interface{}, args ...interface{})
- func ServeTCP(listenAddr string, delegate TCPServerDelegate) error
- func ServeTCPForever(listenAddr string, delegate TCPServerDelegate)
- func WriteAll(conn io.Writer, data []byte) error
- type BufferedConnection
- type BufferedReadConnection
- type CompressedConnection
- type Connection
- type GobMsgPacker
- type JSONMsgPacker
- type MessagePackMsgPacker
- type MsgPacker
- type NetConnection
- type Packet
- func (p *Packet) AddRefCount(add int64)
- func (p *Packet) AppendArgs(args []interface{})
- func (p *Packet) AppendBool(b bool)
- func (p *Packet) AppendByte(b byte)
- func (p *Packet) AppendBytes(v []byte)
- func (p *Packet) AppendClientID(id common.ClientID)
- func (p *Packet) AppendData(msg interface{})
- func (p *Packet) AppendEntityID(id common.EntityID)
- func (p *Packet) AppendFloat32(f float32)
- func (p *Packet) AppendFloat64(f float64)
- func (p *Packet) AppendStringList(list []string)
- func (p *Packet) AppendUint16(v uint16)
- func (p *Packet) AppendUint32(v uint32)
- func (p *Packet) AppendUint64(v uint64)
- func (p *Packet) AppendVarBytes(v []byte)
- func (p *Packet) AppendVarStr(s string)
- func (p *Packet) ClearPayload()
- func (p *Packet) GetPayloadLen() uint32
- func (p *Packet) Payload() []byte
- func (p *Packet) PayloadCap() uint32
- func (p *Packet) PopUint32() (v uint32)
- func (p *Packet) ReadArgs() [][]byte
- func (p *Packet) ReadBool() (v bool)
- func (p *Packet) ReadByte() (v byte)
- func (p *Packet) ReadBytes(size uint32) []byte
- func (p *Packet) ReadClientID() common.ClientID
- func (p *Packet) ReadData(msg interface{})
- func (p *Packet) ReadEntityID() common.EntityID
- func (p *Packet) ReadFloat32() float32
- func (p *Packet) ReadFloat64() float64
- func (p *Packet) ReadStringList() []string
- func (p *Packet) ReadUint16() (v uint16)
- func (p *Packet) ReadUint32() (v uint32)
- func (p *Packet) ReadUint64() (v uint64)
- func (p *Packet) ReadVarBytes() []byte
- func (p *Packet) ReadVarStr() string
- func (p *Packet) Release()
- func (p *Packet) SetPayloadLen(plen uint32)
- type PacketConnection
- func (pc *PacketConnection) Close() error
- func (pc *PacketConnection) Flush() (err error)
- func (pc *PacketConnection) LocalAddr() net.Addr
- func (pc *PacketConnection) NewPacket() *Packet
- func (pc *PacketConnection) RecvPacket() (*Packet, error)
- func (pc *PacketConnection) RemoteAddr() net.Addr
- func (pc *PacketConnection) SendPacket(packet *Packet) error
- func (pc *PacketConnection) SetRecvDeadline(deadline time.Time) error
- func (pc *PacketConnection) String() string
- type RawConnection
- type SendBuffer
- type TCPServerDelegate
Constants ¶
View Source
const ( MIN_PAYLOAD_CAP = 128 CAP_GROW_SHIFT = uint(2) PAYLOAD_LEN_MASK = 0x7FFFFFFF COMPRESSED_BIT_MASK = 0x80000000 )
View Source
const ( PACKET_SIZE_SMALL = 1024 PACKET_SIZE_BIG = 1024 * 64 PACKET_SIZE_HUGE = 1024 * 1024 * 4 )
View Source
const ( MAX_PACKET_SIZE = 25 * 1024 * 1024 SIZE_FIELD_SIZE = 4 PREPAYLOAD_SIZE = SIZE_FIELD_SIZE MAX_PAYLOAD_LENGTH = MAX_PACKET_SIZE - PREPAYLOAD_SIZE )
View Source
const (
RESTART_TCP_SERVER_INTERVAL = 3 * time.Second
)
View Source
const (
SEND_BUFFER_SIZE = 8192 * 2
)
Variables ¶
View Source
var ( PACKET_ENDIAN = binary.LittleEndian PREDEFINE_PAYLOAD_CAPACITIES []uint32 )
View Source
var (
NETWORK_ENDIAN = binary.LittleEndian
)
Functions ¶
func IsConnectionError ¶
func IsConnectionError(_err interface{}) bool
func IsTemporaryNetError ¶
func ServeForever ¶
func ServeForever(f interface{}, args ...interface{})
func ServeTCP ¶
func ServeTCP(listenAddr string, delegate TCPServerDelegate) error
func ServeTCPForever ¶
func ServeTCPForever(listenAddr string, delegate TCPServerDelegate)
Types ¶
type BufferedConnection ¶
type BufferedConnection struct { Connection sync.Mutex // contains filtered or unexported fields }
func NewBufferedConnection ¶
func NewBufferedConnection(conn Connection, delay time.Duration) *BufferedConnection
func (*BufferedConnection) Close ¶
func (bc *BufferedConnection) Close() error
func (*BufferedConnection) String ¶
func (bc *BufferedConnection) String() string
type BufferedReadConnection ¶
type BufferedReadConnection struct { Connection // contains filtered or unexported fields }
func NewBufferedReadConnection ¶
func NewBufferedReadConnection(conn Connection) *BufferedReadConnection
type CompressedConnection ¶
type CompressedConnection struct { Connection // contains filtered or unexported fields }
func NewCompressedConnection ¶
func NewCompressedConnection(conn Connection) *CompressedConnection
func (*CompressedConnection) Close ¶
func (cc *CompressedConnection) Close() error
func (*CompressedConnection) Flush ¶
func (cc *CompressedConnection) Flush() error
type Connection ¶
type GobMsgPacker ¶
type GobMsgPacker struct{}
func (GobMsgPacker) PackMsg ¶
func (mp GobMsgPacker) PackMsg(msg interface{}, buf []byte) ([]byte, error)
func (GobMsgPacker) UnpackMsg ¶
func (mp GobMsgPacker) UnpackMsg(data []byte, msg interface{}) error
type JSONMsgPacker ¶
type JSONMsgPacker struct { }
func (JSONMsgPacker) PackMsg ¶
func (mp JSONMsgPacker) PackMsg(msg interface{}, buf []byte) ([]byte, error)
func (JSONMsgPacker) UnpackMsg ¶
func (mp JSONMsgPacker) UnpackMsg(data []byte, msg interface{}) error
type MessagePackMsgPacker ¶
type MessagePackMsgPacker struct{}
func (MessagePackMsgPacker) PackMsg ¶
func (mp MessagePackMsgPacker) PackMsg(msg interface{}, buf []byte) ([]byte, error)
func (MessagePackMsgPacker) UnpackMsg ¶
func (mp MessagePackMsgPacker) UnpackMsg(data []byte, msg interface{}) error
type MsgPacker ¶
type MsgPacker interface { PackMsg(msg interface{}, buf []byte) ([]byte, error) UnpackMsg(data []byte, msg interface{}) error }
var (
MSG_PACKER MsgPacker = MessagePackMsgPacker{}
)
type NetConnection ¶
func (NetConnection) Flush ¶
func (c NetConnection) Flush() error
type Packet ¶
type Packet struct {
// contains filtered or unexported fields
}
func (*Packet) AddRefCount ¶
func (*Packet) AppendArgs ¶
func (p *Packet) AppendArgs(args []interface{})
Append arguments to packet one by one
func (*Packet) AppendBool ¶
func (*Packet) AppendByte ¶
func (*Packet) AppendBytes ¶
func (*Packet) AppendClientID ¶
func (*Packet) AppendData ¶
func (p *Packet) AppendData(msg interface{})
func (*Packet) AppendEntityID ¶
func (*Packet) AppendFloat32 ¶
func (*Packet) AppendFloat64 ¶
func (*Packet) AppendStringList ¶
func (*Packet) AppendUint16 ¶
func (*Packet) AppendUint32 ¶
func (*Packet) AppendUint64 ¶
func (*Packet) AppendVarBytes ¶
func (*Packet) AppendVarStr ¶
func (*Packet) ClearPayload ¶
func (p *Packet) ClearPayload()
func (*Packet) GetPayloadLen ¶
func (*Packet) PayloadCap ¶
func (*Packet) ReadClientID ¶
func (*Packet) ReadEntityID ¶
func (*Packet) ReadFloat32 ¶
func (*Packet) ReadFloat64 ¶
func (*Packet) ReadStringList ¶
func (*Packet) ReadUint16 ¶
func (*Packet) ReadUint32 ¶
func (*Packet) ReadUint64 ¶
func (*Packet) ReadVarBytes ¶
func (*Packet) ReadVarStr ¶
func (*Packet) SetPayloadLen ¶
type PacketConnection ¶
type PacketConnection struct {
// contains filtered or unexported fields
}
func NewPacketConnection ¶
func NewPacketConnection(conn Connection, compressed bool) *PacketConnection
func (*PacketConnection) Close ¶
func (pc *PacketConnection) Close() error
func (*PacketConnection) Flush ¶
func (pc *PacketConnection) Flush() (err error)
func (*PacketConnection) LocalAddr ¶
func (pc *PacketConnection) LocalAddr() net.Addr
func (*PacketConnection) NewPacket ¶
func (pc *PacketConnection) NewPacket() *Packet
func (*PacketConnection) RecvPacket ¶
func (pc *PacketConnection) RecvPacket() (*Packet, error)
func (*PacketConnection) RemoteAddr ¶
func (pc *PacketConnection) RemoteAddr() net.Addr
func (*PacketConnection) SendPacket ¶
func (pc *PacketConnection) SendPacket(packet *Packet) error
func (*PacketConnection) SetRecvDeadline ¶
func (pc *PacketConnection) SetRecvDeadline(deadline time.Time) error
func (*PacketConnection) String ¶
func (pc *PacketConnection) String() string
type RawConnection ¶
func NewRawConnection ¶
func NewRawConnection(conn net.Conn) RawConnection
func (RawConnection) Recv ¶
func (rc RawConnection) Recv(buf []byte) error
func (RawConnection) Send ¶
func (rc RawConnection) Send(data []byte) error
func (RawConnection) String ¶
func (rc RawConnection) String() string
type SendBuffer ¶
type SendBuffer struct {
// contains filtered or unexported fields
}
func (*SendBuffer) FreeSpace ¶
func (sb *SendBuffer) FreeSpace() int
type TCPServerDelegate ¶
Click to show internal directories.
Click to hide internal directories.