Documentation
¶
Index ¶
- Variables
- type Config
- type Conn
- func (c *Conn) AsyncReadPacket(timeout time.Duration) (Packet, error)
- func (c *Conn) AsyncWritePacket(p Packet, timeout time.Duration) error
- func (c *Conn) Close()
- func (c *Conn) Do()
- func (c *Conn) GetExtraData() interface{}
- func (c *Conn) GetIndex() uint32
- func (c *Conn) GetMac() string
- func (c *Conn) GetRawConn() *net.TCPConn
- func (c *Conn) GetRecvBytes() *bytes.Buffer
- func (c *Conn) GetTopic() string
- func (c *Conn) IsClosed() bool
- func (c *Conn) NsqWritePacket(p Packet, timeout time.Duration) error
- func (c *Conn) PutExtraData(data interface{})
- func (c *Conn) Send(topic string, value []byte) bool
- func (c *Conn) SetID(mac string, index uint32) error
- func (c *Conn) SetMac(mac string)
- func (c *Conn) SetTimeFlag(timeflag int64)
- func (c *Conn) SetTopic(topic string)
- type ConnCallback
- type MqConfig
- type Mqhub
- 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") ErrReadHalf = errors.New("read half packet") )
Error type
Functions ¶
This section is empty.
Types ¶
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) AsyncReadPacket ¶
AsyncReadPacket async reads a packet, this method will never block
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) GetRecvBytes ¶
func (*Conn) PutExtraData ¶
func (c *Conn) PutExtraData(data interface{})
PutExtraData puts the extra data with the Conn
func (*Conn) SetTimeFlag ¶
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(*Conn, 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 Mqhub ¶
type Mqhub struct {
// contains filtered or unexported fields
}
func (*Mqhub) RemoveConn ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(config *Config, callback ConnCallback, protocol Protocol, mqhub *Mqhub) *Server
NewServer creates a server
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
das/server
command
|
|
|
echo/client
command
|
|
|
echo/server
command
|
|
|
telnet/server
command
|
Click to show internal directories.
Click to hide internal directories.