Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
im-pool
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoyanbin
im-pool
Commits
0bbe94eb
Commit
0bbe94eb
authored
Dec 01, 2022
by
haoyanbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
4d5d4553
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
154 deletions
+88
-154
client.go
pool/client.go
+17
-16
publicApi.go
pool/publicApi.go
+63
-117
ws_server.go
ws_server.go
+8
-21
No files found.
pool/client.go
View file @
0bbe94eb
...
...
@@ -60,20 +60,20 @@ type RuntimeInfo struct {
}
type
SendMsg
struct
{
MsgId
string
`json:"msg
Id"`
SendTime
string
`json:"sendTime"`
//消息发送时间
FromClientId
string
`json:"fromClientId"`
//指令消息的来源。发送者的连接ID
ToClientId
string
`json:"toClientId"`
//指令消息的接收者。发送给对应的客户端连接ID
CmdData
[]
byte
`json:"cmdData"`
//对应指令的CmdData1的protobuf的message
Status
int
`json:"status"`
//消息发送响应状态
Priority
int
`json:"priority"`
//用于处理指令队列的优先级的权重值
BusinessId
string
`json:"businessId"`
//客户端标识消息的id,主要区分相同cmd的不同消息,方便收到回复分发处理等效果,考虑长度问题定义成string
GroupId
string
`json:"groupId"`
//服务端发送消息的ID,主要区分相同cmd的不同消息,方便服务端收到回复分发处理等效果,考虑长度问题定义成string
Channel
[]
string
`json:"channel"`
//指定需要广播的频道,可以指定一个或多个频道
ProcedureType
int
`json:"procedureType"`
//会话状态 1 开始导诊 2 等待连接 3 离线 4 双方建立连接 5 结束会话 6 对话 7 已读 8 超时关闭
MsgType
int
`json:"msgType"`
// msg类型 procedureType=6时填写 1 文本消息 2 图片消息
Msg
string
`json:"msg"`
//一般用于json数据传递,或消息发送响应内容
Desc
string
`json:"desc"`
//消息介绍内容,或其它数据
ConversationId
int
`json:"conversation
Id"`
SendTime
string
`json:"sendTime"`
//消息发送时间
FromClientId
string
`json:"fromClientId"`
//指令消息的来源。发送者的连接ID
ToClientId
string
`json:"toClientId"`
//指令消息的接收者。发送给对应的客户端连接ID
CmdData
[]
byte
`json:"cmdData"`
//对应指令的CmdData1的protobuf的message
Status
int
`json:"status"`
//消息发送响应状态
Priority
int
`json:"priority"`
//用于处理指令队列的优先级的权重值
BusinessId
string
`json:"businessId"`
//客户端标识消息的id,主要区分相同cmd的不同消息,方便收到回复分发处理等效果,考虑长度问题定义成string
GroupId
string
`json:"groupId"`
//服务端发送消息的ID,主要区分相同cmd的不同消息,方便服务端收到回复分发处理等效果,考虑长度问题定义成string
Channel
[]
string
`json:"channel"`
//指定需要广播的频道,可以指定一个或多个频道
ProcedureType
int
`json:"procedureType"`
//会话状态 1 开始导诊 2 等待连接 3 离线 4 双方建立连接 5 结束会话 6 对话 7 已读 8 超时关闭
MsgType
int
`json:"msgType"`
// msg类型 procedureType=6时填写 1 文本消息 2 图片消息
Msg
string
`json:"msg"`
//一般用于json数据传递,或消息发送响应内容
Desc
string
`json:"desc"`
//消息介绍内容,或其它数据
}
// Client is a middleman between the websocket connection and the hub.
...
...
@@ -114,8 +114,9 @@ type Client struct {
//}
type
Conversation
struct
{
CustomerClientId
string
`json:"customerClientId"`
UserClientId
string
`json:"userClientId"`
ConversationId
int
`json:"conversationId"`
Promoter
string
`json:"promoter"`
Participant
string
`json:"participant"`
StartTime
string
`json:"startTime"`
StartReceiveDate
string
`json:"startReceiveDate"`
Status
int
`json:"status"`
...
...
pool/publicApi.go
View file @
0bbe94eb
This diff is collapsed.
Click to expand it.
ws_server.go
View file @
0bbe94eb
...
...
@@ -97,12 +97,6 @@ func ws(w http.ResponseWriter, r *http.Request) {
//接收消息
client
.
OnMessage
(
func
(
msg
*
pool
.
SendMsg
)
{
user
:=
pool
.
GetClientInfoById
(
client
.
Id
)
if
user
.
Promoter
==
"1"
{
msg
.
BusinessId
=
user
.
Source
}
else
if
user
.
Promoter
==
"2"
{
msg
.
GroupId
=
user
.
Source
}
if
msg
.
Status
==
3
{
fmt
.
Println
(
"OnMessage:收到出错消息=》"
,
client
.
Id
,
msg
.
Desc
)
...
...
@@ -143,24 +137,17 @@ func ws(w http.ResponseWriter, r *http.Request) {
closeMsg
:=
&
pool
.
SetMsgReq
{}
closeMsg
.
ProcedureType
=
5
closeMsg
.
EndTime
=
time
.
Now
()
.
Format
(
"2006-01-02 15:04:05"
)
closeMsg
.
Promoter
=
user
.
Promoter
if
user
.
Promoter
==
"1"
{
closeMsg
.
Finish
=
"3"
if
user
.
CustomerType
==
"1"
{
closeMsg
.
Promoter
=
client
.
Id
if
userInfo
.
Source
!=
""
{
closeMsg
.
BusinessId
,
_
=
pool
.
DataAesDecrypt
(
userInfo
.
Source
)
}
closeMsg
.
CustomerId
=
userInfo
.
CustomerId
pool
.
PublishData
(
closeMsg
)
fmt
.
Println
(
"用户关闭连接"
,
client
.
Id
)
}
if
user
.
Promoter
==
"2"
{
closeMsg
.
Finish
=
"4"
closeMsg
.
GroupId
=
userInfo
.
Source
closeMsg
.
UserId
=
userInfo
.
CustomerId
if
user
.
CustomerType
==
"2"
{
closeMsg
.
Participant
=
client
.
Id
pool
.
PublishData
(
closeMsg
)
fmt
.
Println
(
"专家关闭连接"
,
client
.
Id
)
}
...
...
@@ -182,17 +169,17 @@ func ws(w http.ResponseWriter, r *http.Request) {
func
GetClientList
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
data
:=
r
.
URL
.
Query
()
list
:=
pool
.
GetList
(
data
[
"source"
][
0
],
data
[
"
promoter
"
][
0
])
list
:=
pool
.
GetList
(
data
[
"source"
][
0
],
data
[
"
sourceId"
][
0
],
data
[
"customerType
"
][
0
])
reply
:=
make
([]
string
,
0
)
for
k
:=
range
list
{
reply
=
append
(
reply
,
k
)
}
resp
(
w
,
reply
)
resp
(
w
,
reply
)
}
func
resp
(
w
http
.
ResponseWriter
,
data
interface
{})
{
func
resp
(
w
http
.
ResponseWriter
,
data
interface
{})
{
w
.
Header
()
.
Set
(
"content-type"
,
"text/json"
)
w
.
WriteHeader
(
200
)
w
.
Write
(
pool
.
SerializeJson
(
data
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment