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
e415f474
Commit
e415f474
authored
Dec 07, 2022
by
haoyanbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
End
parent
8341cca6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
11 deletions
+13
-11
client.go
pool/client.go
+1
-1
publicApi.go
pool/publicApi.go
+6
-4
ws_server.go
ws_server.go
+6
-6
No files found.
pool/client.go
View file @
e415f474
...
...
@@ -26,7 +26,7 @@ const (
//
closeWait
=
60
*
30
*
time
.
Second
// time for auto end
endDate
=
60
*
1
0
*
time
.
Second
endDate
=
60
*
3
0
*
time
.
Second
)
var
cliKey
=
"clients"
...
...
pool/publicApi.go
View file @
e415f474
...
...
@@ -495,10 +495,11 @@ func SetEnd() {
UnserislizeJson
([]
byte
(
vClients
),
conversationData
)
if
conversationData
.
StartReceiveDate
<
time
.
Now
()
.
Add
(
-
endDate
)
.
Format
(
"2006-01-02 15:04:05"
)
{
mqData
:=
&
SendMsg
{
ProcedureType
:
8
,
ToClientId
:
conversationData
.
Promoter
,
FromClientId
:
conversationData
.
Participant
,
SendTime
:
time
.
Now
()
.
Format
(
"2006-01-02 15:04:05"
),
ProcedureType
:
8
,
ConversationId
:
conversationData
.
ConversationId
,
ToClientId
:
conversationData
.
Promoter
,
FromClientId
:
conversationData
.
Participant
,
SendTime
:
time
.
Now
()
.
Format
(
"2006-01-02 15:04:05"
),
}
//发送结束会话给客户端
_
,
isSet
:=
wsSever
.
hub
.
clients
[
conversationData
.
Promoter
]
...
...
@@ -508,6 +509,7 @@ func SetEnd() {
toMqData
:=
&
SendMsg
{
ProcedureType
:
8
,
ConversationId
:
conversationData
.
ConversationId
,
ToClientId
:
conversationData
.
Participant
,
FromClientId
:
conversationData
.
Promoter
,
SendTime
:
time
.
Now
()
.
Format
(
"2006-01-02 15:04:05"
),
...
...
ws_server.go
View file @
e415f474
...
...
@@ -43,12 +43,12 @@ func main() {
})
//自动结束会话
ticker
:=
time
.
NewTicker
(
time
.
Second
*
10
)
go
func
()
{
for
range
ticker
.
C
{
pool
.
SetEnd
()
}
}()
//
ticker := time.NewTicker(time.Second * 10)
//
go func() {
//
for range ticker.C {
// //
pool.SetEnd()
//
}
//
}()
mux
:=
http
.
NewServeMux
()
mux
.
HandleFunc
(
"/"
,
serveHome
)
...
...
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