Documentation ¶
Index ¶
- type PeriodicTimer
- type PeriodicTimerTimeoutHandler
- type Transaction
- type TransactionConfig
- type TransactionMap
- type TransactionResult
- type TryLock
- type UDPConn
- func (c *UDPConn) Close() error
- func (c *UDPConn) FindAddrByChannelNumber(chNum uint16) (net.Addr, bool)
- func (c *UDPConn) HandleInbound(data []byte, from net.Addr)
- func (c *UDPConn) LocalAddr() net.Addr
- func (c *UDPConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)
- func (c *UDPConn) SetDeadline(t time.Time) error
- func (c *UDPConn) SetReadDeadline(t time.Time) error
- func (c *UDPConn) SetWriteDeadline(t time.Time) error
- func (c *UDPConn) WriteTo(p []byte, addr net.Addr) (int, error)
- type UDPConnConfig
- type UDPConnObserver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PeriodicTimer ¶
type PeriodicTimer struct {
// contains filtered or unexported fields
}
PeriodicTimer is a periodic timer
func NewPeriodicTimer ¶
func NewPeriodicTimer(id int, timeoutHandler PeriodicTimerTimeoutHandler, interval time.Duration) *PeriodicTimer
NewPeriodicTimer create a new timer
func (*PeriodicTimer) IsRunning ¶
func (t *PeriodicTimer) IsRunning() bool
IsRunning tests if the timer is running. Debug purpose only
type PeriodicTimerTimeoutHandler ¶
type PeriodicTimerTimeoutHandler func(timerID int)
PeriodicTimerTimeoutHandler is a handler called on timeout
type Transaction ¶
type Transaction struct { Key string // read-only Raw []byte // read-only To net.Addr // read-only // contains filtered or unexported fields }
Transaction represents a transaction
func NewTransaction ¶
func NewTransaction(config *TransactionConfig) *Transaction
NewTransaction creates a new instance of Transaction
func (*Transaction) Retries ¶
func (t *Transaction) Retries() int
Retries returns the number of retransmission it has made
func (*Transaction) StartRtxTimer ¶
func (t *Transaction) StartRtxTimer(onTimeout func(trKey string, nRtx int))
StartRtxTimer starts the transaction timer
func (*Transaction) StopRtxTimer ¶
func (t *Transaction) StopRtxTimer()
StopRtxTimer stop the transaction timer
func (*Transaction) WaitForResult ¶
func (t *Transaction) WaitForResult() TransactionResult
WaitForResult waits for the transaction result
func (*Transaction) WriteResult ¶
func (t *Transaction) WriteResult(res TransactionResult) bool
WriteResult writes the result to the result channel
type TransactionConfig ¶
TransactionConfig is a set of confi params used by NewTransaction
type TransactionMap ¶
type TransactionMap struct {
// contains filtered or unexported fields
}
TransactionMap is a thread-safe transaction map
func NewTransactionMap ¶
func NewTransactionMap() *TransactionMap
NewTransactionMap create a new instance of the transaction map
func (*TransactionMap) CloseAndDeleteAll ¶
func (m *TransactionMap) CloseAndDeleteAll()
CloseAndDeleteAll closes and deletes all transactions
func (*TransactionMap) Delete ¶
func (m *TransactionMap) Delete(key string)
Delete deletes a transaction by its key
func (*TransactionMap) Find ¶
func (m *TransactionMap) Find(key string) (*Transaction, bool)
Find looks up a transaction by its key
func (*TransactionMap) Insert ¶
func (m *TransactionMap) Insert(key string, tr *Transaction) bool
Insert inserts a trasaction to the map
func (*TransactionMap) Size ¶
func (m *TransactionMap) Size() int
Size returns the length of the transaction map
type TransactionResult ¶
TransactionResult is a bag of result values of a transaction
type TryLock ¶
type TryLock struct {
// contains filtered or unexported fields
}
TryLock implement the classic "try-lock" operation.
type UDPConn ¶
type UDPConn struct {
// contains filtered or unexported fields
}
UDPConn is the implementation of the Conn and PacketConn interfaces for UDP network connections. comatible with net.PacketConn and net.Conn
func NewUDPConn ¶
func NewUDPConn(config *UDPConnConfig) *UDPConn
NewUDPConn creates a new instance of UDPConn
func (*UDPConn) Close ¶
Close closes the connection. Any blocked ReadFrom or WriteTo operations will be unblocked and return errors.
func (*UDPConn) FindAddrByChannelNumber ¶
FindAddrByChannelNumber returns a peer address associated with the channel number on this UDPConn
func (*UDPConn) HandleInbound ¶
HandleInbound passes inbound data in UDPConn
func (*UDPConn) ReadFrom ¶
ReadFrom reads a packet from the connection, copying the payload into p. It returns the number of bytes copied into p and the return address that was on the packet. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered. Callers should always process the n > 0 bytes returned before considering the error err. ReadFrom can be made to time out and return an Error with Timeout() == true after a fixed time limit; see SetDeadline and SetReadDeadline.
func (*UDPConn) SetDeadline ¶
SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations fail with a timeout (see type Error) instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to ReadFrom or WriteTo. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
An idle timeout can be implemented by repeatedly extending the deadline after successful ReadFrom or WriteTo calls.
A zero value for t means I/O operations will not time out.
func (*UDPConn) SetReadDeadline ¶
SetReadDeadline sets the deadline for future ReadFrom calls and any currently-blocked ReadFrom call. A zero value for t means ReadFrom will not time out.
func (*UDPConn) SetWriteDeadline ¶
SetWriteDeadline sets the deadline for future WriteTo calls and any currently-blocked WriteTo call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means WriteTo will not time out.
type UDPConnConfig ¶
type UDPConnConfig struct { Observer UDPConnObserver RelayedAddr net.Addr Integrity stun.MessageIntegrity Nonce stun.Nonce Lifetime time.Duration Log logging.LeveledLogger }
UDPConnConfig is a set of configuration params use by NewUDPConn
type UDPConnObserver ¶
type UDPConnObserver interface { TURNServerAddr() net.Addr Username() stun.Username Realm() stun.Realm WriteTo(data []byte, to net.Addr) (int, error) PerformTransaction(msg *stun.Message, to net.Addr, dontWait bool) (TransactionResult, error) OnDeallocated(relayedAddr net.Addr) }
UDPConnObserver is an interface to UDPConn observer