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 ForkDTMFEventToChannelEventThread() error
- func GetChannelState(uuid string) string
- func GetNodeList() map[string]*xctrl.Node
- 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 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 Respond(topic string, resp *Response, opts ...nats.PublishOption) error
- func Service() xctrl.XNodeService
- func SetLogLevel(level LogLevel)
- func SetLogger(l Logger)
- func Subscribe(subject 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 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 (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) 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 (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 (h *Ctrl) NewCManService(addr string) cman.CManService
- func (h *Ctrl) Subscribe(topic string, cb nats.EventCallback, queue string) (nats.Subscriber, error)
- type EmptyAppHandler
- type EmptyEventHandler
- type EmptyRequestHandler
- type Error
- type EventHandler
- type LogLevel
- type Logger
- type Message
- type NodeHashFun
- 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 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 RegisterHashNodeFun ¶ added in v1.1.0
func RegisterHashNodeFun(nodeCallbackFunc NodeHashFun)
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(subject 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
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 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) 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 (*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) 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 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 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{})