ctrl

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

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 AService

func AService() xctrl.XNodeService

AsyncService 异步调用2,使用Context

func AsyncService

func AsyncService() xctrl.XNodeService

AsyncService 异步调用

func Call

func Call(topic string, req *Request, timeout time.Duration) (*nats.Message, error)

Call 发起 request 请求

func ContextWithID

func ContextWithID(id string) context.Context

ContextWithID 创建带请求ID的context

func DelChannel

func DelChannel(uuid string) error

DelChannel get channel

func DoResultCallback

func DoResultCallback(msg *Message)

func EnableApp

func EnableApp(topic string) error

EnableApp APP事件 cn.xswitch.app.callcenter 呼叫队列 cn.xswitch.app.autodialer 预测外呼

func EnableEvent

func EnableEvent(topic string, queue string) error

EnableEvent 开启事件监听 cn.xswitch.event.cdr cn.xswitch.event.custom.sofia>

func EnableNodeStatus

func EnableNodeStatus() error

EnableNodeStatus 启用节点状态事件 cn.xswitch.node.status

func EnableRequest

func EnableRequest(topic string) error

EnableRequest 开启Request请求监听 FetchXMl Dialplan

func EnableResult

func EnableResult(topic string) error

func ExecAPI

func ExecAPI(hostname string, cmd string, args ...string) (string, error)

ExecAPI 执行原生 API

func GetChannelState

func GetChannelState(uuid string) string

GetChannelState 获取 channel 状态

func GetNodeList

func GetNodeList() map[string]*xctrl.Node

GetNodeList 获取当前注册节点列表

func Hostname

func Hostname(uuid string) string

Hostname 根据 node uuid 获取 hostname

func Init

func Init(h Handler, trace bool, subject, addrs string) error

Init 初始化Ctrl global 是否接收全局事件, addrs nats消息队列连接地址

func Node

func Node(hostname string) *xctrl.Node

Node 根据 hostname 获取 node 节点信息

func NodeAddress

func NodeAddress(nodeUUID string) string

WithAddress 创建NODE地址

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 RawMessage

func RawMessage(data []byte) *json.RawMessage

RawMessage .

func Respond

func Respond(topic string, resp *Response, opts ...nats.PublishOption) error

Respond 响应nats request 请求

func Service

func Service() xctrl.XNodeService

Service 同步调用

func Subscribe

func Subscribe(topic string, cb nats.EventCallback, queue string) (nats.Subscriber, error)

func ToRawMessage

func ToRawMessage(vPoint interface{}) *json.RawMessage

func Transfer

func Transfer(ctrlID string, channel *xctrl.ChannelEvent) error

func TranslateMethod

func TranslateMethod(method string) string

TranslateMethod change request method to NativeJSAPI

func UUID

func UUID() string

UUID get ctrl uuid

func WithAddress

func WithAddress(nodeUUID string) client.CallOption

WithAddress 创建NODE地址

func WithAddressNot

func WithAddressNot() client.CallOption

WithAddress 创建NODE地址

func XCall

func XCall(topic string, method string, params interface{}, timeout time.Duration) (*nats.Message, error)

XCall 发起 request 请求

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 FindChannel(condition string, argument string) []*Channel

func NewChannel

func NewChannel(channel_uuid string) *Channel

only call at the first time

func ReadChannel

func ReadChannel(uuid string) (*Channel, error)

ReadChannel get channel

func WriteChannel

func WriteChannel(uuid string, channel *Channel) *Channel

WriteChannel save channel

func (*Channel) AI

func (channel *Channel) AI(req *xctrl.AIRequest) *xctrl.AIResponse

AI

func (*Channel) Accept

func (channel *Channel) Accept(takeover bool) *xctrl.Response

Accept 接管

func (*Channel) Answer

func (channel *Channel) Answer() *xctrl.Response

Answer 应答

func (*Channel) Bridge

func (channel *Channel) Bridge(req *xctrl.BridgeRequest, async bool) *xctrl.Response

Bridge 在把当前呼叫桥接(发起)另一个呼叫

func (*Channel) Broadcast

func (channel *Channel) Broadcast(req *xctrl.BroadcastRequest) *xctrl.Response

Broadcast 播放多个文件

func (*Channel) Callcenter

func (channel *Channel) Callcenter(req *xctrl.CallcenterRequest) *xctrl.CallcenterResponse

Callcenter 呼叫中心Callcenter

func (*Channel) ChannelBridge

func (channel *Channel) ChannelBridge(req *xctrl.ChannelBridgeRequest) *xctrl.Response

ChannelBridge 桥接两个呼叫

func (*Channel) Conference

func (channel *Channel) Conference(req *xctrl.ConferenceRequest) *xctrl.ConferenceResponse

Conference 会议

func (*Channel) Consult

func (channel *Channel) Consult(req *xctrl.ConsultRequest) *xctrl.Response

Consult 协商转移

func (*Channel) DetectFace

func (channel *Channel) DetectFace(req *xctrl.DetectFaceRequest) *xctrl.Response

DetectFace 人脸识别

func (*Channel) DetectSpeech

func (channel *Channel) DetectSpeech(req *xctrl.DetectRequest, async bool) *xctrl.DetectResponse

DetectSpeech 语音识别

func (*Channel) Dial

func (channel *Channel) Dial(req *xctrl.DialRequest) *xctrl.DialResponse

Dial 外呼

func (*Channel) FIFO

func (channel *Channel) FIFO(req *xctrl.FIFORequest) *xctrl.FIFOResponse

FIFO 呼叫中心FIFO队列(先入先出)

func (*Channel) FullCtrlUuid

func (channel *Channel) FullCtrlUuid() string

func (*Channel) GetChannelData

func (channel *Channel) GetChannelData(req *xctrl.GetChannelDataRequest) *xctrl.ChannelDataResponse

GetChannelData 获取通道数据

func (*Channel) GetChannelEvent

func (channel *Channel) GetChannelEvent() *xctrl.ChannelEvent

GetChannelEvent .

func (*Channel) GetStates

func (channel *Channel) GetStates() *xctrl.StateResponse

GetStates 获取通道状态

func (*Channel) GetVar

func (channel *Channel) GetVar(req *xctrl.GetVarRequest) *xctrl.VarResponse

GetVar 获取通道变量

func (*Channel) GetVariable

func (channel *Channel) GetVariable(key string) string

GetVariable 获取通道变量

func (*Channel) Hangup

func (channel *Channel) Hangup(cause string, flag xctrl.HangupRequest_HangupFlag) *xctrl.Response

Hangup 挂机

func (*Channel) Hold

func (channel *Channel) Hold(req *xctrl.HoldRequest) *xctrl.Response

Hold 呼叫保持

func (*Channel) HttAPI

func (channel *Channel) HttAPI(req *xctrl.HttAPIRequest) *xctrl.HttAPIResponse

func (*Channel) Intercept

func (channel *Channel) Intercept(req *xctrl.InterceptRequest) *xctrl.Response

Intercept 强插

func (*Channel) Lua

func (channel *Channel) Lua(req *xctrl.LuaRequest) *xctrl.LuaResponse

Lua

func (*Channel) Marshal

func (channel *Channel) Marshal() []byte

Marshal marshal to JSON

func (*Channel) NativeAPI

func (channel *Channel) NativeAPI(req *xctrl.NativeRequest) *xctrl.NativeResponse

NativeAPI native Api

func (*Channel) NativeApp

func (channel *Channel) NativeApp(req *xctrl.NativeRequest) *xctrl.NativeResponse

NativeApp native App

func (*Channel) NativeJSAPI

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

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

func (channel *Channel) ReadDTMF(req *xctrl.DTMFRequest) *xctrl.DTMFResponse

ReadDTMF 读取DTMF按键

func (*Channel) ReadDigits

func (channel *Channel) ReadDigits(req *xctrl.DigitsRequest) *xctrl.DigitsResponse

ReadDTMF 收集DTMF按键,支持正则和错误音提示

func (*Channel) Ready

func (channel *Channel) Ready() bool

Ready 判断通道是否正常状态

func (*Channel) Record

func (channel *Channel) Record(req *xctrl.RecordRequest) *xctrl.RecordResponse

Record 录音

func (*Channel) RingBackDetection

func (channel *Channel) RingBackDetection(req *xctrl.RingBackDetectionRequest, async bool) *xctrl.Response

RingBackDetection 回铃音检测

func (*Channel) Save

func (channel *Channel) Save() *Channel

func (*Channel) SendDTMF

func (channel *Channel) SendDTMF(dtmf string) *xctrl.Response

SendDTMF 发送DTMF

func (*Channel) SetMute

func (channel *Channel) SetMute(req *xctrl.MuteRequest) *xctrl.Response

func (*Channel) SetVar

func (channel *Channel) SetVar(req *xctrl.SetVarRequest) *xctrl.Response

设置通道变量

func (*Channel) SetVariable

func (channel *Channel) SetVariable(key, value string) error

SetVariable 保存通道变量

func (*Channel) SetVariables

func (channel *Channel) SetVariables(varKv map[string]string) error

SetVariables 保存多个通道变量

func (*Channel) Stop

func (channel *Channel) Stop() *xctrl.Response

Stop 停止当前正在执行的API

func (*Channel) String

func (channel *Channel) String() string

String marshalIndent

func (*Channel) Subscribe

func (channel *Channel) Subscribe(topic string, cb nats.EventCallback, queue string) (nats.Subscriber, error)

func (*Channel) ThreeWay

func (channel *Channel) ThreeWay(req *xctrl.ThreeWayRequest) *xctrl.Response

ThreeWay 三方通话

func (*Channel) Transfer

func (channel *Channel) Transfer(req *xctrl.TransferRequest) *xctrl.Response

Transfer 转移(待定)

func (*Channel) UnBridge

func (channel *Channel) UnBridge(req *xctrl.Request) *xctrl.Response

UnBridge 停止bridge

func (*Channel) UnBridge2

func (channel *Channel) UnBridge2(req *xctrl.Request) *xctrl.Response

UnBridge2 断开桥接,park channel

type Ctrl

type Ctrl struct {
	// contains filtered or unexported fields
}

Ctrl 控制中心

func (*Ctrl) EnableApp

func (h *Ctrl) EnableApp(topic string) error

EnableApp APP事件

func (*Ctrl) EnableEvent

func (h *Ctrl) EnableEvent(topic string, queue string) error

EnableEvent 开启事件监听

func (*Ctrl) EnableRequest

func (h *Ctrl) EnableRequest(topic string) error

EnableRequest 开启Request请求监听

func (*Ctrl) EnableResult

func (h *Ctrl) EnableResult(topic string) error

EnableApp Result 事件

func (*Ctrl) EnbaleNodeStatus

func (h *Ctrl) EnbaleNodeStatus() error

EnbaleNodeStatus 开启节点监听

func (*Ctrl) Subscribe

func (h *Ctrl) Subscribe(topic string, cb nats.EventCallback, queue string) (nats.Subscriber, error)

订阅消息

type EmptyHandler

type EmptyHandler struct {
}

func (*EmptyHandler) App

func (*EmptyHandler) Event

func (h *EmptyHandler) Event(context.Context, string, *Request)

func (*EmptyHandler) Request

func (h *EmptyHandler) Request(context.Context, string, string, *Request)

func (*EmptyHandler) Result

func (h *EmptyHandler) Result(context.Context, string, *Result)

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 NewError

func NewError(code int, message string) *Error

NewError returns an Error with given code and message.

func ServerError

func ServerError(rpcerr error) *Error

ServerError convert errors returned by Client.Call() into Error. User should check for rpc.ErrShutdown and io.ErrUnexpectedEOF before calling ServerError.

func (*Error) Error

func (e *Error) Error() string

Error returns JSON representation of Error.

type Handler

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异步请求消息

func (*Message) String

func (m *Message) String() string

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) Marshal

func (r *Request) Marshal() []byte

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{})

type XRequest

type XRequest struct {
	Version string      `json:"jsonrpc"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params"`
	ID      interface{} `json:"id"`
}

Request RPC 请求对象

Directories

Path Synopsis
Package nats provides a NATS Conn
Package nats provides a NATS Conn

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL