Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
Koishi Thirdeye
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
3rdeye
Koishi Thirdeye
Commits
1b60847b
Commit
1b60847b
authored
Jan 11, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto close ws on disconnect
parent
6385bd24
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
src/register.ts
src/register.ts
+16
-3
No files found.
src/register.ts
View file @
1b60847b
import
{
Argv
,
Awaitable
,
Command
,
Context
,
Schema
,
User
}
from
'
koishi
'
;
import
{
Argv
,
Awaitable
,
Command
,
Context
,
Schema
,
User
,
WebSocketLayer
,
}
from
'
koishi
'
;
import
{
CommandPutConfig
,
DoRegisterConfig
,
...
...
@@ -78,6 +86,7 @@ export function DefinePlugin<T = any>(
__ctx
:
Context
;
__config
:
T
;
__pluginOptions
:
KoishiPluginRegistrationOptions
<
T
>
;
__wsLayers
:
WebSocketLayer
[];
_handleSystemInjections
()
{
// console.log('Handling system injection');
...
...
@@ -309,9 +318,10 @@ export function DefinePlugin<T = any>(
break
;
case
'
ws
'
:
const
{
data
:
wsPath
}
=
regData
as
DoRegisterConfig
<
'
ws
'
>
;
baseContext
.
router
.
ws
(
wsPath
,
(
socket
,
req
)
=>
const
layer
=
baseContext
.
router
.
ws
(
wsPath
,
(
socket
,
req
)
=>
this
[
methodKey
](
socket
,
req
),
);
this
.
__wsLayers
.
push
(
layer
);
break
;
default
:
throw
new
Error
(
`Unknown operation type
${
regData
.
type
}
`
);
...
...
@@ -353,7 +363,9 @@ export function DefinePlugin<T = any>(
if
(
typeof
this
.
onDisconnect
===
'
function
'
)
{
await
this
.
onDisconnect
();
}
// this._handleServiceProvide(false);
for
(
const
layer
of
this
.
__wsLayers
)
{
layer
.
close
();
}
});
}
...
...
@@ -380,6 +392,7 @@ export function DefinePlugin<T = any>(
this
.
__ctx
=
ctx
;
this
.
__config
=
config
;
this
.
__pluginOptions
=
options
;
this
.
__wsLayers
=
[];
this
.
_initializePluginClass
();
}
};
...
...
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