Documentation ¶
Index ¶
- func ACall(subject string, method string, req interface{}, opts ...*AsyncCallOption) error
- func AService() xctrl.XNodeService
- func AsyncService() xctrl.XNodeService
- func CManService() cman.CManService
- func Call(topic string, req *Request, timeout time.Duration) (*nats.Message, error)
- func ContextWithID(id string) context.Context
- func CtrlStartUp(req *xctrl.CtrlStartUpRequest) error
- func DelChannel(uuid string) error
- func DeliverToChannelEventThread(channel *Channel, natsEvent nats.Event)
- func DoResultCallback(msg *Message)
- func EnableApp(handler AppHandler, subject string, queue string) error
- func EnableEvent(handler EventHandler, subject string, queue string) error
- func EnableNodeStatus(subject string) error
- func EnableRequest(handler RequestHandler, subject string, queue string) error
- func EnableTenancy()
- func ForkDTMFEventToChannelEventThread() error
- func GetChannelState(uuid string) string
- func GetNATSConn() *natsio.Conn
- func GetNodeList() map[string]*xctrl.Node
- func GetTenancyTopicAddress(userPrefix string, topic string) string
- func GetTenancyTopicAndUser(rawTopic string) (user string, topic string)
- func GetTenantID(subject string) string
- func GetTenantId(subject string) string
- func Hostname(uuid string) string
- func Init(trace bool, addrs string) error
- func InitCManService(addr string) error
- func Node(hostname string) *xctrl.Node
- func NodeAddress(nodeUUID string) string
- func OnEvicted(f func(string, interface{}))
- func Publish(topic string, msg []byte, opts ...nats.PublishOption) error
- func PublishJSON(topic string, obj interface{}, opts ...nats.PublishOption) error
- func RawMessage(data []byte) *json.RawMessage
- func RegisterHashNodeFun(nodeCallbackFunc NodeHashFun)
- func RegisterHashNodeWithTenancyFun(nodeCallbackFunc NodeHashWithTenacyFun)
- func Respond(topic string, resp *Response, opts ...nats.PublishOption) error
- func Service() xctrl.XNodeService
- func SetFromPrefix(prefix string)
- func SetLogLevel(level LogLevel)
- func SetLogger(l Logger)
- func SetMaxChannelLifeTime(time uint)
- func SetToPrefix(prefix string)
- func Subscribe(subject string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
- func TenantNodeAddress(tenant string, nodeUUID string) string
- func ToRawMessage(vPoint interface{}) *json.RawMessage
- func Transfer(ctrlID string, channel *xctrl.ChannelEvent) error
- func TranslateMethod(method string) string
- func UUID() string
- func WithAddress(nodeUUID string) client.CallOption
- func WithAddressDefault() client.CallOption
- func WithAsync() client.CallOption
- func WithRequestTimeout(d time.Duration) client.CallOption
- func WithTenantAddress(tenant string, nodeUUID string) client.CallOption
- func WithTimeout(d time.Duration) client.CallOption
- func XCall(topic string, method string, params interface{}, timeout time.Duration) (*nats.Message, error)
- type AppHandler
- type AsyncCallOption
- type Channel
- func FindChannel(condition string, argument string) []*Channel
- func NewChannel(channel_uuid string) *Channel
- func NewChannelEvent() *Channel
- func NewChannelEventWithPrefix(prefix string) *Channel
- func ReadChannel(uuid string) (*Channel, error)
- func ReadChannelByInstance(c *Ctrl, uuid string) (*Channel, error)
- func WriteChannel(uuid string, channel *Channel) *Channel
- func (channel *Channel) Accept0(opts ...client.CallOption) *xctrl.Response
- func (channel *Channel) AcceptAndTakeOver(opts ...client.CallOption) *xctrl.Response
- func (channel *Channel) AcceptWithChannelParams(channel_params []string, opts ...client.CallOption) *xctrl.Response
- func (channel *Channel) AcceptWithChannelParamsAndTakeOver(channel_params []string, opts ...client.CallOption) *xctrl.Response
- func (channel *Channel) Answer0(opts ...client.CallOption) *xctrl.Response
- func (channel *Channel) AnswerWithChannelParams(channel_params []string, opts ...client.CallOption) *xctrl.Response
- func (channel *Channel) Bridge0(req *xctrl.BridgeRequest, async bool) *xctrl.Response
- func (channel *Channel) DetectSpeech0(req *xctrl.DetectRequest, async bool) *xctrl.DetectResponse
- func (channel *Channel) FullCtrlUuid() string
- func (channel *Channel) GetChannelEvent() *xctrl.ChannelEvent
- func (channel *Channel) GetNatsEvent() nats.Event
- func (channel *Channel) GetTenantID() string
- func (channel *Channel) GetUserData() interface{}
- func (channel *Channel) GetVariable0(key string) string
- func (channel *Channel) Hangup0(cause string, flag xctrl.HangupRequest_HangupFlag) *xctrl.Response
- func (channel *Channel) Marshal() []byte
- func (channel *Channel) NodeAddress() client.CallOption
- func (channel *Channel) Play0(req *xctrl.PlayRequest) *xctrl.Response
- func (channel *Channel) PlayFile(file string, opts ...client.CallOption) *xctrl.Response
- func (channel *Channel) PlayTTS(engine string, voice string, text string, opts ...client.CallOption) *xctrl.Response
- func (channel *Channel) PlayWithTimeout(req *xctrl.PlayRequest, timeout time.Duration) *xctrl.Response
- func (channel *Channel) Ready() bool
- func (channel *Channel) RingBackDetection0(req *xctrl.RingBackDetectionRequest, async bool) *xctrl.Response
- func (channel *Channel) Save() *Channel
- func (channel *Channel) SendDTMF0(dtmf string) *xctrl.Response
- func (channel *Channel) SetUserData(userData interface{})
- func (channel *Channel) SetVariable0(key, value string) error
- func (channel *Channel) SetVariables(vars map[string]string) error
- func (channel *Channel) Stop0() *xctrl.Response
- func (channel *Channel) String() string
- func (channel *Channel) Subscribe(subject string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
- type ContextKey
- type Ctrl
- func (c *Ctrl) AService() xctrl.XNodeService
- func (c *Ctrl) AsyncService() xctrl.XNodeService
- func (c *Ctrl) CManService() cman.CManService
- func (c *Ctrl) Call(topic string, req *Request, timeout time.Duration) (*nats.Message, error)
- func (c *Ctrl) CtrlStartUp(req *xctrl.CtrlStartUpRequest) error
- func (h *Ctrl) EnableApp(handler AppHandler, subject string, queue string) error
- func (h *Ctrl) EnableEvent(handler EventHandler, subject string, queue string) error
- func (h *Ctrl) EnableRequest(handler RequestHandler, subject string, queue string) error
- func (h *Ctrl) EnbaleNodeStatus(subject string) error
- func (h *Ctrl) ForkDTMFEventToChannelEventThread() error
- func (c *Ctrl) GetInstanceName() string
- func (c *Ctrl) GetNATSConn() *natsio.Conn
- func (c *Ctrl) GetNodeList() map[string]*xctrl.Node
- func (c *Ctrl) GetTenancyTopicAddress(userPrefix string, topic string) string
- func (c *Ctrl) GetTenancyTopicAndUser(rawTopic string) (user string, topic string)
- func (c *Ctrl) GetTenantID(subject string) string
- func (c *Ctrl) GetTenantId(subject string) string
- func (h *Ctrl) NewCManService(addr string) cman.CManService
- func (h *Ctrl) OnEvicted(f func(string, interface{}))
- func (c *Ctrl) Publish(topic string, msg []byte, opts ...nats.PublishOption) error
- func (c *Ctrl) PublishJSON(topic string, obj interface{}, opts ...nats.PublishOption) error
- func (c *Ctrl) Respond(topic string, resp *Response, opts ...nats.PublishOption) error
- func (c *Ctrl) Service() xctrl.XNodeService
- func (c *Ctrl) SetFromPrefix(prefix string)
- func (c *Ctrl) SetInstanceName(instanceName string)
- func (c *Ctrl) SetMaxChannelLifeTime(time uint)
- func (c *Ctrl) SetTenancyStatus(status bool)
- func (c *Ctrl) SetToPrefix(prefix string)
- func (h *Ctrl) Subscribe(topic string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
- func (c *Ctrl) TenantNodeAddress(tenant string, nodeUUID string) string
- func (c *Ctrl) Transfer(ctrlID string, channel *xctrl.ChannelEvent) error
- func (c *Ctrl) UUID() string
- func (c *Ctrl) WithTenantAddress(tenant string, nodeUUID string) client.CallOption
- func (c *Ctrl) XCall(topic string, method string, params interface{}, timeout time.Duration) (*nats.Message, error)
- type CtrlNodes
- type EmptyAppHandler
- type EmptyEventHandler
- type EmptyRequestHandler
- type Error
- type EventHandler
- type LogLevel
- type Logger
- type Message
- type NodeHashFun
- type NodeHashWithTenacyFun
- type Request
- type RequestHandler
- type Response
- type Result
- type ResultCallbackFunc
- type XRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ACall ¶
func ACall(subject string, method string, req interface{}, opts ...*AsyncCallOption) error
func CtrlStartUp ¶
func CtrlStartUp(req *xctrl.CtrlStartUpRequest) error
func DoResultCallback ¶
func DoResultCallback(msg *Message)
func EnableApp ¶
func EnableApp(handler AppHandler, subject string, queue string) error
EnableApp APP事件
func EnableEvent ¶
func EnableEvent(handler EventHandler, subject string, queue string) error
EnableEvent 开启事件监听 cn.xswitch.ctrl.event.cdr cn.xswitch.ctrl.event.custom.sofia>
func EnableNodeStatus ¶
EnableNodeStatus 启用节点状态事件 cn.xswitch.node.status
func EnableRequest ¶
func EnableRequest(handler RequestHandler, subject string, queue string) error
EnableRequest 开启Request请求监听 FetchXMl Dialplan
func EnableTenancy ¶ added in v1.2.3
func EnableTenancy()
func ForkDTMFEventToChannelEventThread ¶
func ForkDTMFEventToChannelEventThread() error
ForkDTMFEventToChannelEvent 将DTMF事件放到ChannelEvent事件相同的线程处理
func GetNATSConn ¶ added in v1.1.19
func GetNodeList ¶
func GetTenancyTopicAddress ¶ added in v1.2.3
func GetTenancyTopicAndUser ¶ added in v1.2.3
func GetTenantID ¶ added in v1.2.0
func GetTenantId ¶ added in v1.1.20
deprecated over GetTenantID
func InitCManService ¶
func Publish ¶
func Publish(topic string, msg []byte, opts ...nats.PublishOption) error
Publish 发送消息
func PublishJSON ¶
func PublishJSON(topic string, obj interface{}, opts ...nats.PublishOption) error
PublishJSON 发送JSON消息
func RegisterHashNodeFun ¶ added in v1.1.0
func RegisterHashNodeFun(nodeCallbackFunc NodeHashFun)
func RegisterHashNodeWithTenancyFun ¶ added in v1.2.3
func RegisterHashNodeWithTenancyFun(nodeCallbackFunc NodeHashWithTenacyFun)
func Respond ¶
func Respond(topic string, resp *Response, opts ...nats.PublishOption) error
Respond 响应NATS Request 请求
func SetFromPrefix ¶ added in v1.1.20
func SetFromPrefix(prefix string)
func SetLogLevel ¶
func SetLogLevel(level LogLevel)
func SetMaxChannelLifeTime ¶ added in v1.1.14
func SetMaxChannelLifeTime(time uint)
func SetToPrefix ¶ added in v1.1.20
func SetToPrefix(prefix string)
func Subscribe ¶
func Subscribe(subject string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
func TenantNodeAddress ¶ added in v1.2.1
TenantNodeAddress Get tenant node add string
func ToRawMessage ¶
func ToRawMessage(vPoint interface{}) *json.RawMessage
func TranslateMethod ¶
TranslateMethod change request method to NativeJSAPI
func WithAddressDefault ¶
func WithAddressDefault() client.CallOption
func WithAsync ¶ added in v1.1.11
func WithAsync() client.CallOption
func WithRequestTimeout ¶
func WithRequestTimeout(d time.Duration) client.CallOption
NATS Request Timeout
func WithTenantAddress ¶ added in v1.1.20
func WithTenantAddress(tenant string, nodeUUID string) client.CallOption
WithTenantAddress 创建租户对应的Node地址
func WithTimeout ¶
func WithTimeout(d time.Duration) client.CallOption
Types ¶
type AppHandler ¶
type AsyncCallOption ¶
type AsyncCallOption struct {
// contains filtered or unexported fields
}
func ACallOption ¶
func ACallOption() *AsyncCallOption
func (*AsyncCallOption) WithCallback ¶
func (opt *AsyncCallOption) WithCallback(f ResultCallbackFunc) *AsyncCallOption
func (*AsyncCallOption) WithData ¶
func (opt *AsyncCallOption) WithData(data interface{}) *AsyncCallOption
type Channel ¶
type Channel struct { *xctrl.ChannelEvent // the parent ChannelEvent CtrlUuid string // the Controller UUID // contains filtered or unexported fields }
Channel call channel
func FindChannel ¶
func NewChannelEvent ¶
func NewChannelEvent() *Channel
func NewChannelEventWithPrefix ¶ added in v1.1.20
func ReadChannelByInstance ¶ added in v1.1.20
func WriteChannel ¶
WriteChannel save channel
func (*Channel) Accept0 ¶
func (channel *Channel) Accept0(opts ...client.CallOption) *xctrl.Response
Accept 接管
func (*Channel) AcceptAndTakeOver ¶
func (channel *Channel) AcceptAndTakeOver(opts ...client.CallOption) *xctrl.Response
Accept 接管
func (*Channel) AcceptWithChannelParams ¶
func (channel *Channel) AcceptWithChannelParams(channel_params []string, opts ...client.CallOption) *xctrl.Response
Accept 接管
func (*Channel) AcceptWithChannelParamsAndTakeOver ¶
func (channel *Channel) AcceptWithChannelParamsAndTakeOver(channel_params []string, opts ...client.CallOption) *xctrl.Response
Accept 接管
func (*Channel) Answer0 ¶
func (channel *Channel) Answer0(opts ...client.CallOption) *xctrl.Response
Answer 应答
func (*Channel) AnswerWithChannelParams ¶
func (channel *Channel) AnswerWithChannelParams(channel_params []string, opts ...client.CallOption) *xctrl.Response
Answer 应答
func (*Channel) DetectSpeech0 ¶
func (channel *Channel) DetectSpeech0(req *xctrl.DetectRequest, async bool) *xctrl.DetectResponse
DetectSpeech 语音识别
func (*Channel) FullCtrlUuid ¶
func (*Channel) GetChannelEvent ¶
func (channel *Channel) GetChannelEvent() *xctrl.ChannelEvent
GetChannelEvent .
func (*Channel) GetNatsEvent ¶
func (*Channel) GetTenantID ¶ added in v1.1.20
func (*Channel) GetUserData ¶
func (channel *Channel) GetUserData() interface{}
func (*Channel) GetVariable0 ¶
GetVariable 获取通道变量
func (*Channel) NodeAddress ¶
func (channel *Channel) NodeAddress() client.CallOption
NodeAddress 生成NODE地址
func (*Channel) Play0 ¶
func (channel *Channel) Play0(req *xctrl.PlayRequest) *xctrl.Response
Play 播放一个文件,默认超时时间1小时
func (*Channel) PlayWithTimeout ¶
func (channel *Channel) PlayWithTimeout(req *xctrl.PlayRequest, timeout time.Duration) *xctrl.Response
PlayWithTimeout 播放一个文件,可传入超时时间
func (*Channel) RingBackDetection0 ¶
func (channel *Channel) RingBackDetection0(req *xctrl.RingBackDetectionRequest, async bool) *xctrl.Response
RingBackDetection 回铃音检测
func (*Channel) SetUserData ¶
func (channel *Channel) SetUserData(userData interface{})
func (*Channel) SetVariable0 ¶
SetVariable 保存通道变量
func (*Channel) SetVariables ¶
SetVariables 保存多个通道变量
func (*Channel) Subscribe ¶
func (channel *Channel) Subscribe(subject string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
type ContextKey ¶
type ContextKey string
type Ctrl ¶
type Ctrl struct {
// contains filtered or unexported fields
}
Ctrl 控制中心
func NewCtrlInstance ¶ added in v1.1.20
func (*Ctrl) AService ¶ added in v1.1.20
func (c *Ctrl) AService() xctrl.XNodeService
func (*Ctrl) AsyncService ¶ added in v1.1.20
func (c *Ctrl) AsyncService() xctrl.XNodeService
AsyncService 异步调用,Depracated
func (*Ctrl) CManService ¶ added in v1.1.20
func (c *Ctrl) CManService() cman.CManService
CManService 同步调用
func (*Ctrl) CtrlStartUp ¶ added in v1.1.20
func (c *Ctrl) CtrlStartUp(req *xctrl.CtrlStartUpRequest) error
func (*Ctrl) EnableApp ¶
func (h *Ctrl) EnableApp(handler AppHandler, subject string, queue string) error
EnableApp APP事件
func (*Ctrl) EnableEvent ¶
func (h *Ctrl) EnableEvent(handler EventHandler, subject string, queue string) error
EnableEvent 开启事件监听
func (*Ctrl) EnableRequest ¶
func (h *Ctrl) EnableRequest(handler RequestHandler, subject string, queue string) error
EnableRequest 开启Request请求监听
func (*Ctrl) EnbaleNodeStatus ¶
EnbaleNodeStatus 开启节点监听
func (*Ctrl) ForkDTMFEventToChannelEventThread ¶
ForkDTMFEventToChannelEventThread
func (*Ctrl) GetInstanceName ¶ added in v1.1.20
func (*Ctrl) GetNATSConn ¶ added in v1.1.20
func (*Ctrl) GetTenancyTopicAddress ¶ added in v1.2.3
func (*Ctrl) GetTenancyTopicAndUser ¶ added in v1.2.3
func (*Ctrl) GetTenantID ¶ added in v1.2.0
func (*Ctrl) GetTenantId ¶ added in v1.1.20
func (*Ctrl) NewCManService ¶
func (h *Ctrl) NewCManService(addr string) cman.CManService
NewCManService 创建 CManService
func (*Ctrl) PublishJSON ¶ added in v1.1.20
func (c *Ctrl) PublishJSON(topic string, obj interface{}, opts ...nats.PublishOption) error
PublishJSON 发送JSON消息
func (*Ctrl) SetFromPrefix ¶ added in v1.1.20
func (*Ctrl) SetInstanceName ¶ added in v1.1.20
func (*Ctrl) SetMaxChannelLifeTime ¶ added in v1.1.20
func (*Ctrl) SetTenancyStatus ¶ added in v1.2.3
func (*Ctrl) SetToPrefix ¶ added in v1.1.20
func (*Ctrl) Subscribe ¶
func (h *Ctrl) Subscribe(topic string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
订阅消息
func (*Ctrl) TenantNodeAddress ¶ added in v1.2.1
func (*Ctrl) Transfer ¶ added in v1.1.20
func (c *Ctrl) Transfer(ctrlID string, channel *xctrl.ChannelEvent) error
func (*Ctrl) WithTenantAddress ¶ added in v1.1.20
func (c *Ctrl) WithTenantAddress(tenant string, nodeUUID string) client.CallOption
type CtrlNodes ¶ added in v1.1.20
type CtrlNodes struct {
// contains filtered or unexported fields
}
func InitCtrlNodes ¶ added in v1.1.20
func InitCtrlNodes() CtrlNodes
func (*CtrlNodes) GetNodeList ¶ added in v1.1.20
type EmptyAppHandler ¶
type EmptyAppHandler struct{}
func (*EmptyAppHandler) ChannelEvent ¶
func (h *EmptyAppHandler) ChannelEvent(context.Context, *Channel)
type EmptyEventHandler ¶
type EmptyEventHandler struct{}
func (*EmptyEventHandler) Event ¶
func (h *EmptyEventHandler) Event(*Request)
type EmptyRequestHandler ¶
type EmptyRequestHandler struct{}
type Error ¶
type Error struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` }
Error represent JSON-RPC 2.0 "Error object".
func ServerError ¶
ServerError convert errors returned by Client.Call() into Error. User should check for rpc.ErrShutdown and io.ErrUnexpectedEOF before calling ServerError.
type EventHandler ¶
Handler Ctrl事件响应
type Message ¶
type Message struct { Version string `json:"jsonrpc"` Method string `json:"method"` ID *json.RawMessage `json:"id"` Params *json.RawMessage `json:"params"` Result *json.RawMessage `json:"result,omitempty"` Error *json.RawMessage `json:"error,omitempty"` }
Message Node异步请求消息
type NodeHashFun ¶ added in v1.1.0
type NodeHashWithTenacyFun ¶ added in v1.2.3
type Request ¶
type Request struct { Version string `json:"jsonrpc"` Method string `json:"method"` ID *json.RawMessage `json:"id"` Params *json.RawMessage `json:"params"` }
Request RPC 请求对象
func (*Request) RawMessage ¶
func (r *Request) RawMessage() *json.RawMessage
type RequestHandler ¶
type Response ¶
type Response struct { Version string `json:"jsonrpc"` ID *json.RawMessage `json:"id"` Result interface{} `json:"result,omitempty"` Error interface{} `json:"error,omitempty"` }
Response RPC 返回对象
type Result ¶
type Result struct { Version string `json:"jsonrpc"` ID *json.RawMessage `json:"id"` Result *json.RawMessage `json:"result,omitempty"` Error *json.RawMessage `json:"error,omitempty"` }
Result RPC 异步返回对象
type ResultCallbackFunc ¶
type ResultCallbackFunc func(msg *Message, data interface{})