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 DelChannel(uuid string) error
- func DoResultCallback(msg *Message)
- func EnableApp(topic string) error
- func EnableEvent(topic string, queue string) error
- func EnableNodeStatus() error
- func EnableRequest(topic string) error
- func EnableResult(topic string) error
- func ForkDTMFEventToChannelEventThread() error
- func GetChannelState(uuid string) string
- func GetNodeList() map[string]*xctrl.Node
- func Hostname(uuid string) string
- func Init(h Handler, trace bool, subject, addrs string) error
- func InitCManService(addr string) error
- func Node(hostname string) *xctrl.Node
- func NodeAddress(nodeUUID string) string
- 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 Respond(topic string, resp *Response, opts ...nats.PublishOption) error
- func Service() xctrl.XNodeService
- func SetLogLevel(level LogLevel)
- func SetLogger(l Logger)
- func Subscribe(topic string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
- 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 WithRequestTimeout(d time.Duration) client.CallOption
- func XCall(topic string, method string, params interface{}, timeout time.Duration) (*nats.Message, error)
- type AsyncCallOption
- type Channel
- func (channel *Channel) AI(req *xctrl.AIRequest) *xctrl.AIResponse
- func (channel *Channel) Accept(takeover bool) *xctrl.Response
- func (channel *Channel) Answer() *xctrl.Response
- func (channel *Channel) Bridge(req *xctrl.BridgeRequest, async bool) *xctrl.Response
- func (channel *Channel) Broadcast(req *xctrl.BroadcastRequest) *xctrl.Response
- func (channel *Channel) Callcenter(req *xctrl.CallcenterRequest) *xctrl.CallcenterResponse
- func (channel *Channel) ChannelBridge(req *xctrl.ChannelBridgeRequest) *xctrl.Response
- func (channel *Channel) Conference(req *xctrl.ConferenceRequest) *xctrl.ConferenceResponse
- func (channel *Channel) Consult(req *xctrl.ConsultRequest) *xctrl.Response
- func (channel *Channel) DetectFace(req *xctrl.DetectFaceRequest) *xctrl.Response
- func (channel *Channel) DetectSpeech(req *xctrl.DetectRequest, async bool) *xctrl.DetectResponse
- func (channel *Channel) Dial(req *xctrl.DialRequest) *xctrl.DialResponse
- func (channel *Channel) FIFO(req *xctrl.FIFORequest) *xctrl.FIFOResponse
- func (channel *Channel) FullCtrlUuid() string
- func (channel *Channel) GetChannelData(req *xctrl.GetChannelDataRequest) *xctrl.ChannelDataResponse
- func (channel *Channel) GetChannelEvent() *xctrl.ChannelEvent
- func (channel *Channel) GetStates() *xctrl.StateResponse
- func (channel *Channel) GetVar(req *xctrl.GetVarRequest) *xctrl.VarResponse
- func (channel *Channel) GetVariable(key string) string
- func (channel *Channel) Hangup(cause string, flag xctrl.HangupRequest_HangupFlag) *xctrl.Response
- func (channel *Channel) Hold(req *xctrl.HoldRequest) *xctrl.Response
- func (channel *Channel) HttAPI(req *xctrl.HttAPIRequest) *xctrl.HttAPIResponse
- func (channel *Channel) Intercept(req *xctrl.InterceptRequest) *xctrl.Response
- func (channel *Channel) Lua(req *xctrl.LuaRequest) *xctrl.LuaResponse
- func (channel *Channel) Marshal() []byte
- func (channel *Channel) NativeAPI(req *xctrl.NativeRequest) *xctrl.NativeResponse
- func (channel *Channel) NativeApp(req *xctrl.NativeRequest) *xctrl.NativeResponse
- func (channel *Channel) NativeJSAPI(req *xctrl.XNativeJSRequest) *xctrl.XNativeJSResponse
- func (channel *Channel) NodeAddress() client.CallOption
- func (channel *Channel) Play(req *xctrl.PlayRequest) *xctrl.Response
- func (channel *Channel) PlayWithTimeout(req *xctrl.PlayRequest, timeout time.Duration) *xctrl.Response
- func (channel *Channel) ReadDTMF(req *xctrl.DTMFRequest) *xctrl.DTMFResponse
- func (channel *Channel) ReadDigits(req *xctrl.DigitsRequest) *xctrl.DigitsResponse
- func (channel *Channel) Ready() bool
- func (channel *Channel) Record(req *xctrl.RecordRequest) *xctrl.RecordResponse
- func (channel *Channel) RingBackDetection(req *xctrl.RingBackDetectionRequest, async bool) *xctrl.Response
- func (channel *Channel) Save() *Channel
- func (channel *Channel) SendDTMF(dtmf string) *xctrl.Response
- func (channel *Channel) SetMute(req *xctrl.MuteRequest) *xctrl.Response
- func (channel *Channel) SetVar(req *xctrl.SetVarRequest) *xctrl.Response
- func (channel *Channel) SetVariable(key, value string) error
- func (channel *Channel) SetVariables(varKv map[string]string) error
- func (channel *Channel) Stop() *xctrl.Response
- func (channel *Channel) String() string
- func (channel *Channel) Subscribe(topic string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
- func (channel *Channel) ThreeWay(req *xctrl.ThreeWayRequest) *xctrl.Response
- func (channel *Channel) Transfer(req *xctrl.TransferRequest) *xctrl.Response
- func (channel *Channel) UnBridge(req *xctrl.Request) *xctrl.Response
- func (channel *Channel) UnBridge2(req *xctrl.Request) *xctrl.Response
- type Ctrl
- func (h *Ctrl) EnableApp(topic string) error
- func (h *Ctrl) EnableEvent(topic string, queue string) error
- func (h *Ctrl) EnableRequest(topic string) error
- func (h *Ctrl) EnableResult(topic string) error
- func (h *Ctrl) EnbaleNodeStatus() error
- func (h *Ctrl) ForkDTMFEventToChannelEventThread() error
- func (h *Ctrl) NewCManService(addr string) cman.CManService
- func (h *Ctrl) Subscribe(topic string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
- type EmptyHandler
- type Error
- type Handler
- type LogLevel
- type Logger
- type Message
- type Request
- 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 DoResultCallback ¶
func DoResultCallback(msg *Message)
func EnableEvent ¶
EnableEvent 开启事件监听 cn.xswitch.event.cdr cn.xswitch.event.custom.sofia>
func EnableNodeStatus ¶
func EnableNodeStatus() error
EnableNodeStatus 启用节点状态事件 cn.xswitch.node.status
func EnableRequest ¶
EnableRequest 开启Request请求监听 FetchXMl Dialplan
func EnableResult ¶ added in v1.0.4
func ForkDTMFEventToChannelEventThread ¶
func ForkDTMFEventToChannelEventThread() error
ForkDTMFEventToChannelEvent 将DTMF事件放到ChannelEvent事件相同的线程处理
func GetNodeList ¶
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 Respond ¶
func Respond(topic string, resp *Response, opts ...nats.PublishOption) error
Respond 响应nats request 请求
func SetLogLevel ¶
func SetLogLevel(level LogLevel)
func Subscribe ¶
func Subscribe(topic string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
func ToRawMessage ¶
func ToRawMessage(vPoint interface{}) *json.RawMessage
func TranslateMethod ¶
TranslateMethod change request method to NativeJSAPI
func WithAddressDefault ¶
func WithAddressDefault() client.CallOption
func WithRequestTimeout ¶
func WithRequestTimeout(d time.Duration) client.CallOption
NATS Request Timeout
Types ¶
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 CtrlUuid string // contains filtered or unexported fields }
Channel call channel
func FindChannel ¶
func WriteChannel ¶
WriteChannel save channel
func (*Channel) AI ¶ added in v1.0.4
func (channel *Channel) AI(req *xctrl.AIRequest) *xctrl.AIResponse
AI
func (*Channel) Broadcast ¶ added in v1.0.4
func (channel *Channel) Broadcast(req *xctrl.BroadcastRequest) *xctrl.Response
Broadcast 播放多个文件
func (*Channel) Callcenter ¶ added in v1.0.4
func (channel *Channel) Callcenter(req *xctrl.CallcenterRequest) *xctrl.CallcenterResponse
Callcenter 呼叫中心Callcenter
func (*Channel) ChannelBridge ¶ added in v1.0.4
func (channel *Channel) ChannelBridge(req *xctrl.ChannelBridgeRequest) *xctrl.Response
ChannelBridge 桥接两个呼叫
func (*Channel) Conference ¶ added in v1.0.4
func (channel *Channel) Conference(req *xctrl.ConferenceRequest) *xctrl.ConferenceResponse
Conference 会议
func (*Channel) Consult ¶ added in v1.0.4
func (channel *Channel) Consult(req *xctrl.ConsultRequest) *xctrl.Response
Consult 协商转移
func (*Channel) DetectFace ¶ added in v1.0.4
func (channel *Channel) DetectFace(req *xctrl.DetectFaceRequest) *xctrl.Response
DetectFace 人脸识别
func (*Channel) DetectSpeech ¶ added in v1.0.4
func (channel *Channel) DetectSpeech(req *xctrl.DetectRequest, async bool) *xctrl.DetectResponse
DetectSpeech 语音识别
func (*Channel) Dial ¶ added in v1.0.4
func (channel *Channel) Dial(req *xctrl.DialRequest) *xctrl.DialResponse
Dial 外呼
func (*Channel) FIFO ¶ added in v1.0.4
func (channel *Channel) FIFO(req *xctrl.FIFORequest) *xctrl.FIFOResponse
FIFO 呼叫中心FIFO队列(先入先出)
func (*Channel) FullCtrlUuid ¶
func (*Channel) GetChannelData ¶ added in v1.0.4
func (channel *Channel) GetChannelData(req *xctrl.GetChannelDataRequest) *xctrl.ChannelDataResponse
GetChannelData 获取通道数据
func (*Channel) GetChannelEvent ¶
func (channel *Channel) GetChannelEvent() *xctrl.ChannelEvent
GetChannelEvent .
func (*Channel) GetStates ¶ added in v1.0.4
func (channel *Channel) GetStates() *xctrl.StateResponse
GetStates 获取通道状态
func (*Channel) GetVar ¶ added in v1.0.4
func (channel *Channel) GetVar(req *xctrl.GetVarRequest) *xctrl.VarResponse
GetVar 获取通道变量
func (*Channel) GetVariable ¶ added in v1.0.4
GetVariable 获取通道变量
func (*Channel) Hold ¶ added in v1.0.4
func (channel *Channel) Hold(req *xctrl.HoldRequest) *xctrl.Response
Hold 呼叫保持
func (*Channel) HttAPI ¶ added in v1.0.4
func (channel *Channel) HttAPI(req *xctrl.HttAPIRequest) *xctrl.HttAPIResponse
func (*Channel) Intercept ¶ added in v1.0.4
func (channel *Channel) Intercept(req *xctrl.InterceptRequest) *xctrl.Response
Intercept 强插
func (*Channel) Lua ¶ added in v1.0.4
func (channel *Channel) Lua(req *xctrl.LuaRequest) *xctrl.LuaResponse
Lua
func (*Channel) NativeAPI ¶ added in v1.0.4
func (channel *Channel) NativeAPI(req *xctrl.NativeRequest) *xctrl.NativeResponse
NativeAPI native Api
func (*Channel) NativeApp ¶ added in v1.0.4
func (channel *Channel) NativeApp(req *xctrl.NativeRequest) *xctrl.NativeResponse
NativeApp native App
func (*Channel) NativeJSAPI ¶ added in v1.0.4
func (channel *Channel) NativeJSAPI(req *xctrl.XNativeJSRequest) *xctrl.XNativeJSResponse
NativeJSAPI Native js api
func (*Channel) NodeAddress ¶
func (channel *Channel) NodeAddress() client.CallOption
NodeAddress 生成NODE地址
func (*Channel) Play ¶ added in v1.0.4
func (channel *Channel) Play(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) ReadDTMF ¶ added in v1.0.4
func (channel *Channel) ReadDTMF(req *xctrl.DTMFRequest) *xctrl.DTMFResponse
ReadDTMF 读取DTMF按键
func (*Channel) ReadDigits ¶ added in v1.0.4
func (channel *Channel) ReadDigits(req *xctrl.DigitsRequest) *xctrl.DigitsResponse
ReadDTMF 收集DTMF按键,支持正则和错误音提示
func (*Channel) Record ¶ added in v1.0.4
func (channel *Channel) Record(req *xctrl.RecordRequest) *xctrl.RecordResponse
Record 录音
func (*Channel) RingBackDetection ¶ added in v1.0.4
func (channel *Channel) RingBackDetection(req *xctrl.RingBackDetectionRequest, async bool) *xctrl.Response
RingBackDetection 回铃音检测
func (*Channel) SetMute ¶ added in v1.0.4
func (channel *Channel) SetMute(req *xctrl.MuteRequest) *xctrl.Response
func (*Channel) SetVar ¶ added in v1.0.4
func (channel *Channel) SetVar(req *xctrl.SetVarRequest) *xctrl.Response
设置通道变量
func (*Channel) SetVariable ¶ added in v1.0.4
SetVariable 保存通道变量
func (*Channel) SetVariables ¶
SetVariables 保存多个通道变量
func (*Channel) Subscribe ¶
func (channel *Channel) Subscribe(topic string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
func (*Channel) ThreeWay ¶ added in v1.0.4
func (channel *Channel) ThreeWay(req *xctrl.ThreeWayRequest) *xctrl.Response
ThreeWay 三方通话
func (*Channel) Transfer ¶ added in v1.0.4
func (channel *Channel) Transfer(req *xctrl.TransferRequest) *xctrl.Response
Transfer 转移(待定)
type Ctrl ¶
type Ctrl struct {
// contains filtered or unexported fields
}
Ctrl 控制中心
func (*Ctrl) EnableEvent ¶
EnableEvent 开启事件监听
func (*Ctrl) EnableRequest ¶
EnableRequest 开启Request请求监听
func (*Ctrl) EnableResult ¶ added in v1.0.4
EnableApp Result 事件
func (*Ctrl) ForkDTMFEventToChannelEventThread ¶
ForkDTMFEventToChannelEventThread
func (*Ctrl) NewCManService ¶
func (h *Ctrl) NewCManService(addr string) cman.CManService
NewCManService 创建 CManService
func (*Ctrl) Subscribe ¶
func (h *Ctrl) Subscribe(topic string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
订阅消息
type EmptyHandler ¶ added in v1.0.4
type EmptyHandler struct { }
func (*EmptyHandler) Event ¶ added in v1.0.4
func (h *EmptyHandler) Event(context.Context, string, *Request)
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 Handler ¶ added in v1.0.4
type Handler interface { // ctx , topic, reply,Params Request(context.Context, string, string, *Request) // ctx , topic ,reply Params App(context.Context, string, string, *Message) // ctx , topic , Params Event(context.Context, string, *Request) // ctx , topic , Params Result(context.Context, string, *Result) }
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 Request ¶
type Request struct { Version string `json:"jsonrpc"` Method string `json:"method"` Params *json.RawMessage `json:"params"` ID *json.RawMessage `json:"id"` }
Request RPC 请求对象
func (*Request) RawMessage ¶
func (r *Request) RawMessage() *json.RawMessage
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{})