package allocation
import (
"net"
"time"
"github.com/pion/logging"
"github.com/pion/turn/v4/internal/proto"
)
type ChannelBind struct {
Peer net .Addr
Number proto .ChannelNumber
allocation *Allocation
lifetimeTimer *time .Timer
log logging .LeveledLogger
}
func NewChannelBind (number proto .ChannelNumber , peer net .Addr , log logging .LeveledLogger ) *ChannelBind {
return &ChannelBind {
Number : number ,
Peer : peer ,
log : log ,
}
}
func (c *ChannelBind ) start (lifetime time .Duration ) {
c .lifetimeTimer = time .AfterFunc (lifetime , func () {
if !c .allocation .RemoveChannelBind (c .Number ) {
c .log .Errorf ("Failed to remove ChannelBind for %v %x %v" , c .Number , c .Peer , c .allocation .fiveTuple )
}
})
}
func (c *ChannelBind ) refresh (lifetime time .Duration ) {
if !c .lifetimeTimer .Reset (lifetime ) {
c .log .Errorf ("Failed to reset ChannelBind timer for %v %x %v" , c .Number , c .Peer , c .allocation .fiveTuple )
}
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .