Documentation ¶
Index ¶
- Constants
- func DefaultAddress() string
- func SuitablePack(b []byte, packet Packet) error
- func SuitableUnpack(packet Packet) ([]byte, error)
- type Config
- type Packet
- type PingPacket
- type Pingu
- func (p *Pingu) BroadcastPingWithTicker(ticker time.Ticker, per time.Duration) chan struct{}
- func (p *Pingu) Close(cancels ...chan struct{}) error
- func (p *Pingu) IsAlive(raw string) bool
- func (p *Pingu) LocalAddr() net.Addr
- func (p *Pingu) PingPong(addr *net.UDPAddr, timeout time.Duration) error
- func (p *Pingu) PingPongWithRawAddr(raw string, timeout time.Duration) error
- func (p *Pingu) PingTable() map[string]bool
- func (p *Pingu) Pingus() []string
- func (p *Pingu) Register(addr *net.UDPAddr)
- func (p *Pingu) RegisterWithRawAddr(raw string) error
- func (p *Pingu) RemoteAddr() net.Addr
- func (p *Pingu) Start()
- func (p *Pingu) Stop()
- func (p *Pingu) Unregister(addr *net.UDPAddr)
- func (p *Pingu) UnregisterWithRawAddr(raw string) error
- type PongPacket
Constants ¶
View Source
const ( Ping = iota Pong )
View Source
const ( PingType = 1 + iota MaxPacketSize = 4 )
View Source
const DefultRecvBufferSize = 256
Variables ¶
This section is empty.
Functions ¶
func DefaultAddress ¶
func DefaultAddress() string
func SuitablePack ¶
SuitablePack is the logic for parse the UDP Payload.
func SuitableUnpack ¶
SuitableUnpack is change Packet to suitable protocol message. If send message, you must use this method.
Types ¶
type PingPacket ¶
type PingPacket struct {
// contains filtered or unexported fields
}
func (*PingPacket) Kind ¶
func (p *PingPacket) Kind() byte
func (*PingPacket) Sender ¶
func (p *PingPacket) Sender() *net.UDPAddr
func (*PingPacket) SetSender ¶
func (p *PingPacket) SetSender(s *net.UDPAddr)
type Pingu ¶
type Pingu struct {
// contains filtered or unexported fields
}
func NewPingu ¶
Pingu is not accept double use to net.UDPConn. It's should only be used once. Generate net.UDPConn in NewPingu to avoid confusion.
func (*Pingu) BroadcastPingWithTicker ¶
Send broadcast with ticker.
func (*Pingu) PingPongWithRawAddr ¶
func (*Pingu) RegisterWithRawAddr ¶
func (*Pingu) RemoteAddr ¶
func (*Pingu) Stop ¶
func (p *Pingu) Stop()
Stop stops the packet controll loop. If you stop the Pingu, it will clears the peer state map.
func (*Pingu) Unregister ¶
Unregister is remove input address from broadcast list.
func (*Pingu) UnregisterWithRawAddr ¶
type PongPacket ¶
type PongPacket struct {
// contains filtered or unexported fields
}
func (*PongPacket) Kind ¶
func (p *PongPacket) Kind() byte
func (*PongPacket) Sender ¶
func (p *PongPacket) Sender() *net.UDPAddr
func (*PongPacket) SetSender ¶
func (p *PongPacket) SetSender(s *net.UDPAddr)
Click to show internal directories.
Click to hide internal directories.