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 ¶ added in v1.3.0
type PeriodicTimer struct {
// contains filtered or unexported fields
}
PeriodicTimer is a periodic timer
func NewPeriodicTimer ¶ added in v1.3.0
func NewPeriodicTimer(id int, timeoutHandler PeriodicTimerTimeoutHandler, interval time.Duration) *PeriodicTimer
NewPeriodicTimer create a new timer
func (*PeriodicTimer) IsRunning ¶ added in v1.3.0
func (t *PeriodicTimer) IsRunning() bool
IsRunning tests if the timer is running. Debug purpose only
func (*PeriodicTimer) Start ¶ added in v1.3.0
func (t *PeriodicTimer) Start() bool
Start starts the timer.
type PeriodicTimerTimeoutHandler ¶ added in v1.3.0
type PeriodicTimerTimeoutHandler func(timerID int)
PeriodicTimerTimeoutHandler is a handler called on timeout
type Transaction ¶ added in v1.3.0
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 ¶ added in v1.3.0
func NewTransaction(config *TransactionConfig) *Transaction
NewTransaction creates a new instance of Transaction
func (*Transaction) Close ¶ added in v1.3.0
func (t *Transaction) Close()
Close closes the transaction
func (*Transaction) Retries ¶ added in v1.3.0
func (t *Transaction) Retries() int
Retries returns the number of retransmission it has made
func (*Transaction) StartRtxTimer ¶ added in v1.3.0
func (t *Transaction) StartRtxTimer(onTimeout func(trKey string, nRtx int))
StartRtxTimer starts the transaction timer
func (*Transaction) StopRtxTimer ¶ added in v1.3.0
func (t *Transaction) StopRtxTimer()
StopRtxTimer stop the transaction timer
func (*Transaction) WaitForResult ¶ added in v1.3.0
func (t *Transaction) WaitForResult() TransactionResult
WaitForResult waits for the transaction result
func (*Transaction) WriteResult ¶ added in v1.3.0
func (t *Transaction) WriteResult(res TransactionResult) bool
WriteResult writes the result to the result channel
type TransactionConfig ¶ added in v1.3.0
TransactionConfig is a set of confi params used by NewTransaction
type TransactionMap ¶ added in v1.3.0
type TransactionMap struct {
// contains filtered or unexported fields
}
TransactionMap is a thread-safe transaction map
func NewTransactionMap ¶ added in v1.3.0
func NewTransactionMap() *TransactionMap
NewTransactionMap create a new instance of the transaction map
func (*TransactionMap) CloseAndDeleteAll ¶ added in v1.3.0
func (m *TransactionMap) CloseAndDeleteAll()
CloseAndDeleteAll closes and deletes all transactions
func (*TransactionMap) Delete ¶ added in v1.3.0
func (m *TransactionMap) Delete(key string)
Delete deletes a transaction by its key
func (*TransactionMap) Find ¶ added in v1.3.0
func (m *TransactionMap) Find(key string) (*Transaction, bool)
Find looks up a transaction by its key
func (*TransactionMap) Insert ¶ added in v1.3.0
func (m *TransactionMap) Insert(key string, tr *Transaction) bool
Insert inserts a trasaction to the map
func (*TransactionMap) Size ¶ added in v1.3.0
func (m *TransactionMap) Size() int
Size returns the length of the transaction map
type TransactionResult ¶ added in v1.3.0
TransactionResult is a bag of result values of a transaction
type TryLock ¶ added in v1.3.0
type TryLock struct {
// contains filtered or unexported fields
}
TryLock implement the classic "try-lock" operation.
type UDPConn ¶ added in v1.3.0
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 ¶ added in v1.3.0
func NewUDPConn(config *UDPConnConfig) *UDPConn
NewUDPConn creates a new instance of UDPConn
func (*UDPConn) Close ¶ added in v1.3.0
Close closes the connection. Any blocked ReadFrom or WriteTo operations will be unblocked and return errors.
func (*UDPConn) FindAddrByChannelNumber ¶ added in v1.3.0
FindAddrByChannelNumber returns a peer address associated with the channel number on this UDPConn
func (*UDPConn) HandleInbound ¶ added in v1.3.0
HandleInbound passes inbound data in UDPConn
func (*UDPConn) ReadFrom ¶ added in v1.3.0
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 ¶ added in v1.3.0
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 ¶ added in v1.3.0
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 ¶ added in v1.3.0
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 ¶ added in v1.3.0
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 ¶ added in v1.3.0
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