Documentation ¶
Overview ¶
Copyright 2019-2020 Axetroy. All rights reserved. MIT license.
Index ¶
- Variables
- type Client
- type Matcher
- func (c *Matcher) AddWaiter(waiterSocketUUID string)
- func (c *Matcher) GetIdleWaiter() *string
- func (c *Matcher) GetMatcher() map[string][]string
- func (c *Matcher) GetMyUsers(waiterSocketUUID string) []string
- func (c *Matcher) GetMyWaiter(userSocketUUID string) *string
- func (c *Matcher) GetPendingLength() int
- func (c *Matcher) Join(userSocketUUID string, prepend ...bool) *string
- func (c *Matcher) Leave(userSocketUUID string)
- func (c *Matcher) RemoveWaiter(waiterSocketUUID string)
- func (c *Matcher) ShiftPending() *string
- type Message
- type Pool
- type TypeRequestUser
- type TypeRequestWaiter
- type TypeResponseUser
- type TypeResponseWaiter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( UserPoll = NewPool() WaiterPoll = NewPool() )
View Source
var MatcherPool = NewMatcher()
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { sync.RWMutex UUID string // Socket 连接的唯一标识符 // contains filtered or unexported fields }
func (*Client) GetProfile ¶
func (c *Client) GetProfile() *schema.ProfilePublic
func (*Client) UpdateProfile ¶
func (c *Client) UpdateProfile(profile schema.ProfilePublic)
type Matcher ¶
type Matcher struct { sync.RWMutex Broadcast chan bool // 调度器,当收到通知时,就安排客服接待排队的用户 // contains filtered or unexported fields }
func NewMatcher ¶
func NewMatcher() *Matcher
func (*Matcher) GetMatcher ¶
func (*Matcher) GetMyUsers ¶
获取这个客服当前服务的用户
func (*Matcher) GetMyWaiter ¶
获取当前接待我的客服
func (*Matcher) GetPendingLength ¶
func (*Matcher) ShiftPending ¶
type Message ¶
type Message struct { From string `json:"from,omitempty"` // 从谁发出来的 To string `json:"to,omitempty"` // 要发送的目标 ID,只有客服才需要带 target 字段,指明发送给谁 Type string `json:"type" valid:"required~请输入会话类型"` // 会话类型 Payload interface{} `json:"payload,omitempty"` // 本次消息的数据 }
来回传输的消息体
type Pool ¶
type Pool struct { Broadcast chan Message // 广播频道 // contains filtered or unexported fields }
type TypeRequestUser ¶
type TypeRequestUser typeForWriteMessage // 用户发出的消息类型
const ( TypeRequestUserAuth TypeRequestUser = "auth" // 认证帐号 TypeRequestUserConnect TypeRequestUser = "connect" // 请求连接一个客服 TypeRequestUserDisconnect TypeRequestUser = "disconnect" // 请求和客服断开连接 TypeRequestUserMessageText TypeRequestUser = "message_text" // 发送文本消息 )
用户可以发出的消息类型
type TypeRequestWaiter ¶
type TypeRequestWaiter typeForWriteMessage // 客服发出的消息类型
const ( TypeRequestWaiterAuth TypeRequestWaiter = "auth" // 身份认证 TypeRequestWaiterReady TypeRequestWaiter = "ready" // 客服已准备就绪,可以开始接收客人 TypeRequestWaiterMessageText TypeRequestWaiter = "message_text" // 客服发出文本消息 TypeRequestWaiterDisconnect TypeRequestWaiter = "disconnect" // 请求断开连接 )
客服发出的消息类型
type TypeResponseUser ¶
type TypeResponseUser typeForWriteMessage // 输出给用户的消息类型
const ( TypeResponseUserAuthSuccess TypeResponseUser = "auth_success" // 初始化,告诉用户当前的链接 ID TypeResponseUserNotConnect TypeResponseUser = "not_connect" // 尚未连接 TypeResponseUserConnectSuccess TypeResponseUser = "connect_success" // 连接成功,现在可以开始对话 TypeResponseUserDisconnected TypeResponseUser = "disconnected" // 客服与用户断开连接 TypeResponseUserConnectQueue TypeResponseUser = "connect_queue" // 正在排队,请等待 TypeResponseUserMessageText TypeResponseUser = "message_text" // 用户收到文本消息 TypeResponseUserError TypeResponseUser = "error" // 用户收到一个错误 )
用户收到的类型
type TypeResponseWaiter ¶
type TypeResponseWaiter typeForWriteMessage // 输出给客服的消息类型
const ( TypeResponseWaiterMessageText TypeResponseWaiter = "message_text" // 客服收到文本消息 TypeResponseWaiterNewConnection TypeResponseWaiter = "new_connection" // 有新连接 TypeResponseWaiterDisconnected TypeResponseWaiter = "disconnected" // 有新连接断开 TypeResponseWaiterError TypeResponseWaiter = "error" // 有新连接断开 )
客服收到的消息
Click to show internal directories.
Click to hide internal directories.