func (d *Dialer0) Add(auth sys.AuthRemote, addr string) { d.lk.Lock() _, present := d.tels[*auth.GetId()] d.lk.Unlock() if present { return } t := makeTel(d, auth, addr) d.lk.Lock() d.tels[*auth.GetId()] = t d.dials[*auth.GetAcceptKey()] = t d.lk.Unlock() t.rebalance() }
func makeTel(d *Dialer0, auth sys.AuthRemote, addr string) *telephone { return &telephone{ d: d, auth: auth, addr: addr, presence: sys.Presence{ Id: *auth.GetId(), MaybeOnline: true, Reachable: true, Rating: sys.InitialRating, }, uptime: uptime.Make(sys.Halflife, sys.RatingBound), authing: make(map[*Conn]int), conns: make(map[*Conn]int), } }