1 Star 0 Fork 0

ZJOOPS / gosip

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
tx.go 1.23 KB
一键复制 编辑 原始数据 按行查看 历史
zhangjun 提交于 2022-07-25 15:23 . -fix 修复invite ack的bug
package transaction
import (
"fmt"
"sync"
"github.com/discoviking/fsm"
"gitee.com/zhjun2512/gosip/log"
"gitee.com/zhjun2512/gosip/sip"
)
type TxKey = sip.TransactionKey
// Tx is an common SIP transaction
type Tx interface {
Init() error
Key() TxKey
Origin() sip.Request
// Receive receives message from transport layer.
Receive(msg sip.Message) error
String() string
Transport() sip.Transport
Terminate()
Errors() <-chan error
Done() <-chan bool
}
type commonTx struct {
key TxKey
fsm *fsm.FSM
fsmMu sync.RWMutex
origin sip.Request
tpl sip.Transport
lastResp sip.Response
errs chan error
lastErr error
done chan bool
log log.Logger
}
func (tx *commonTx) String() string {
if tx == nil {
return "<nil>"
}
fields := tx.Log().Fields().WithFields(log.Fields{
"key": tx.key,
})
return fmt.Sprintf("%s<%s>", tx.Log().Prefix(), fields)
}
func (tx *commonTx) Log() log.Logger {
return tx.log
}
func (tx *commonTx) Origin() sip.Request {
return tx.origin
}
func (tx *commonTx) Key() TxKey {
return tx.key
}
func (tx *commonTx) Transport() sip.Transport {
return tx.tpl
}
func (tx *commonTx) Errors() <-chan error {
return tx.errs
}
func (tx *commonTx) Done() <-chan bool {
return tx.done
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/zhjun2512/gosip.git
git@gitee.com:zhjun2512/gosip.git
zhjun2512
gosip
gosip
v0.0.5

搜索帮助

344bd9b3 5694891 D2dac590 5694891