Documentation ¶
Index ¶
- Variables
- func AppendToFile(fileName string, content string) error
- func ExternalIP() (net.IP, error)
- func Format(source map[string]gjson.Result) map[string]interface{}
- func GetHostID(nodeIDFile string) (string, error)
- func Source(l *logrus.Entry) *logrus.Entry
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Cap() int
- func (b *Buffer) Grow(n int)
- func (b *Buffer) Len() int
- func (b *Buffer) Next(n int) []byte
- func (b *Buffer) Read(p []byte) (n int, err error)
- func (b *Buffer) ReadByte() (c byte, err error)
- func (b *Buffer) ReadBytes(delim byte) (line []byte, err error)
- func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error)
- func (b *Buffer) ReadRune() (r rune, size int, err error)
- func (b *Buffer) ReadString(delim byte) (line string, err error)
- func (b *Buffer) Reset()
- func (b *Buffer) String() string
- func (b *Buffer) Truncate(n int)
- func (b *Buffer) UnreadByte() error
- func (b *Buffer) UnreadRune() error
- func (b *Buffer) Write(p []byte) (n int, err error)
- func (b *Buffer) WriteByte(c byte) error
- func (b *Buffer) WriteRune(r rune) (n int, err error)
- func (b *Buffer) WriteString(s string) (n int, err error)
- func (b *Buffer) WriteTo(w io.Writer) (n int64, err error)
- type Config
- type Conn
- type ConnCallback
- type MessagePacket
- type MessageProtocol
- type Packet
- type Protocol
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrConnClosing = errors.New("use of closed network connection") ErrWriteBlocking = errors.New("write packet was blocking") ErrReadBlocking = errors.New("read packet was blocking") )
Error type
Functions ¶
func AppendToFile ¶
AppendToFile 文件名字(带全路径) content: 写入的内容
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
func (*Buffer) UnreadByte ¶
func (*Buffer) UnreadRune ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn exposes a set of callbacks for the various events that occur on a connection
func (*Conn) AsyncWritePacket ¶
AsyncWritePacket async writes a packet, this method will never block
func (*Conn) GetExtraData ¶
func (c *Conn) GetExtraData() interface{}
GetExtraData gets the extra data from the Conn
func (*Conn) GetRawConn ¶
GetRawConn returns the raw net.TCPConn from the Conn
func (*Conn) PutExtraData ¶
func (c *Conn) PutExtraData(data interface{})
PutExtraData puts the extra data with the Conn
type ConnCallback ¶
type ConnCallback interface { // OnConnect is called when the connection was accepted, // If the return value of false is closed OnConnect(*Conn) bool // OnMessage is called when the connection receives a packet, // If the return value of false is closed OnMessage(Packet) bool // OnClose is called when the connection closed OnClose(*Conn) }
ConnCallback is an interface of methods that are used as callbacks on a connection
type MessagePacket ¶
type MessagePacket struct {
// contains filtered or unexported fields
}
func (*MessagePacket) IsNull ¶
func (m *MessagePacket) IsNull() bool
func (*MessagePacket) IsPing ¶
func (m *MessagePacket) IsPing() bool
func (*MessagePacket) Serialize ¶
func (m *MessagePacket) Serialize() []byte
type MessageProtocol ¶
type MessageProtocol struct {
// contains filtered or unexported fields
}
func (*MessageProtocol) ReadPacket ¶
func (m *MessageProtocol) ReadPacket() (Packet, error)
ReadPacket 获取消息流
func (*MessageProtocol) SetConn ¶
func (m *MessageProtocol) SetConn(conn *net.TCPConn)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(config *Config, callback ConnCallback, ctx context.Context) *Server
NewServer creates a server
Source Files ¶
Click to show internal directories.
Click to hide internal directories.