package tgsig import ( "dev.narayana.im/narayana/telegabber/calls/signaling" log "github.com/sirupsen/logrus" "github.com/zelenin/go-tdlib/client" ) // tg-side Caller for XMPP-originated calls type Caller struct { callBase } // invoked by Bridge under its mutex; bridge re-entry must be deferred func (c *Caller) Start() { entry := log.WithFields(log.Fields{"user_id": c.userID, "is_video": c.isVideo, "jid": c.adapter.jid}) c.adapter.withCallContext(func() { resp, err := c.adapter.tdlib.CreateCall(&client.CreateCallRequest{ UserId: c.userID, Protocol: callProtocol(), IsVideo: c.isVideo, }) if err != nil { entry.WithError(err).Error("tgsig.Caller.Start: CreateCall failed") if b := c.getBridge(); b != nil { go b.Terminate(signaling.ReasonUnknown) } return } c.setCallID(resp.Id) c.adapter.registerSide(c.userID, &c.callBase) c.adapter.mgr.Register(c.adapter.jid, resp.Id, &c.callBase) entry.WithField("call_id", resp.Id).Info("CreateCall issued") }) }