Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
go-cqhttp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
go-cqhttp
Commits
d309a10f
Commit
d309a10f
authored
Sep 02, 2020
by
Mrs4s
Committed by
GitHub
Sep 02, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #229 from rMuchan/master
反向WS连接时发送connect元事件
parents
7f103a7f
755949fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
server/websocket.go
server/websocket.go
+16
-0
No files found.
server/websocket.go
View file @
d309a10f
...
@@ -123,6 +123,14 @@ func (c *websocketClient) connectEvent() {
...
@@ -123,6 +123,14 @@ func (c *websocketClient) connectEvent() {
}
}
return
return
}
}
handshake
:=
fmt
.
Sprintf
(
`{"meta_event_type":"lifecycle","post_type":"meta_event","self_id":%d,"sub_type":"connect","time":%d}`
,
c
.
bot
.
Client
.
Uin
,
time
.
Now
()
.
Unix
())
err
=
conn
.
WriteMessage
(
websocket
.
TextMessage
,
[]
byte
(
handshake
))
if
err
!=
nil
{
log
.
Warnf
(
"反向Websocket 握手时出现错误: %v"
,
err
)
}
log
.
Infof
(
"已连接到反向Websocket Event服务器 %v"
,
c
.
conf
.
ReverseEventUrl
)
log
.
Infof
(
"已连接到反向Websocket Event服务器 %v"
,
c
.
conf
.
ReverseEventUrl
)
c
.
eventConn
=
&
websocketConn
{
Conn
:
conn
}
c
.
eventConn
=
&
websocketConn
{
Conn
:
conn
}
}
}
...
@@ -146,6 +154,14 @@ func (c *websocketClient) connectUniversal() {
...
@@ -146,6 +154,14 @@ func (c *websocketClient) connectUniversal() {
}
}
return
return
}
}
handshake
:=
fmt
.
Sprintf
(
`{"meta_event_type":"lifecycle","post_type":"meta_event","self_id":%d,"sub_type":"connect","time":%d}`
,
c
.
bot
.
Client
.
Uin
,
time
.
Now
()
.
Unix
())
err
=
conn
.
WriteMessage
(
websocket
.
TextMessage
,
[]
byte
(
handshake
))
if
err
!=
nil
{
log
.
Warnf
(
"反向Websocket 握手时出现错误: %v"
,
err
)
}
wrappedConn
:=
&
websocketConn
{
Conn
:
conn
}
wrappedConn
:=
&
websocketConn
{
Conn
:
conn
}
go
c
.
listenApi
(
wrappedConn
,
true
)
go
c
.
listenApi
(
wrappedConn
,
true
)
c
.
universalConn
=
wrappedConn
c
.
universalConn
=
wrappedConn
...
...
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