Files
plugin-gb28181/tu/server.go
langhuihui dd27ba82d8 更新
2020-09-08 08:01:46 +08:00

49 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package tu
import (
"github.com/Monibuca/plugin-gb28181/transaction"
"sync"
)
//TODO:参考http服务使用者仅需要根据需要实现某些handler替换某些header fileds or body信息。其他的处理都由库来实现。
type Server struct {
*transaction.Core //SIP transaction manager
registers sync.Map //管理所有已经注册的设备端
//routers:TODO:消息路由应用层可以处理消息体或者针对某些消息的callback
}
//提供config参数
func NewServer(config *transaction.Config) *Server {
return &Server{
Core: transaction.NewCore(config),
}
}
//运行一个sip server
func RunServer() {
config := &transaction.Config{
SipIP: "192.168.1.102",
SipPort: 5060,
SipNetwork: "UDP",
Serial: "34020000002000000001",
Realm: "3402000000",
AckTimeout: 10,
RegisterValidity: 3600,
RegisterInterval: 60,
HeartbeatInterval: 60,
HeartbeatRetry: 3,
AudioEnable: true,
WaitKeyFrame: true,
MediaPortMin: 58200,
MediaPortMax: 58300,
MediaIdleTimeout: 30,
}
s := NewServer(config)
s.Start()
select {}
}