ctrl

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: MIT Imports: 21 Imported by: 1

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 CManService

func CManService() cman.CManService

CManService 同步调用

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 added in v1.0.4

func EnableResult(topic string) error

func ForkDTMFEventToChannelEventThread

func ForkDTMFEventToChannelEventThread() error

ForkDTMFEventToChannelEvent 将DTMF事件放到ChannelEvent事件相同的线程处理

func GetChannelState

func GetChannelState(uuid string) string

GetChannelState 获取 channel 状态

func GetNodeList

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

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 InitCManService

func InitCManService(addr string) error

func Node

func Node(hostname string) *xctrl.Node

Node 根据 hostname 获取 node 节点信息

func NodeAddress

func NodeAddress(nodeUUID string) string

Node Address 标准化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 SetLogLevel

func SetLogLevel(level LogLevel)

func SetLogger

func SetLogger(l Logger)

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 WithAddressDefault

func WithAddressDefault() client.CallOption

func WithRequestTimeout

func WithRequestTimeout(d time.Duration) client.CallOption

NATS Request Timeout

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 added in v1.0.4

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

AI

func (*Channel) Accept added in v1.0.4

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

Accept 接管

func (*Channel) Answer added in v1.0.4

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

Answer 应答

func (*Channel) Bridge added in v1.0.4

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

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

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 *Channel) FullCtrlUuid() string

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

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

GetVariable 获取通道变量

func (*Channel) Hangup added in v1.0.4

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

Hangup 挂机

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

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

Marshal marshal to JSON

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

func (channel *Channel) Ready() bool

Ready 判断通道是否正常状态

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

func (channel *Channel) Save() *Channel

func (*Channel) SendDTMF added in v1.0.4

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

SendDTMF 发送DTMF

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

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 added in v1.0.4

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 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 转移(待定)

func (*Channel) UnBridge added in v1.0.4

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

UnBridge 停止bridge

func (*Channel) UnBridge2 added in v1.0.4

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 added in v1.0.4

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

EnableApp Result 事件

func (*Ctrl) EnbaleNodeStatus

func (h *Ctrl) EnbaleNodeStatus() error

EnbaleNodeStatus 开启节点监听

func (*Ctrl) ForkDTMFEventToChannelEventThread

func (h *Ctrl) ForkDTMFEventToChannelEventThread() error

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) App added in v1.0.4

func (*EmptyHandler) Event added in v1.0.4

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

func (*EmptyHandler) Request added in v1.0.4

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

func (*EmptyHandler) Result added in v1.0.4

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 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 LogLevel

type LogLevel int
const (
	LLFatal LogLevel = iota
	LLError
	LLWarn
	LLInfo
	LLDebug
	LLTrace
)

type Logger

type Logger interface {
	Log(level int, v ...interface{})
	Logf(level int, format string, v ...interface{})
}

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