Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
Koishi Nestjs
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 Nestjs
Commits
c1dd9e0c
Commit
c1dd9e0c
authored
Oct 27, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support regex ws path match
parent
abf80b39
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
README.md
README.md
+8
-0
src/koishi.ws-adapter.ts
src/koishi.ws-adapter.ts
+12
-2
No files found.
README.md
View file @
c1dd9e0c
...
...
@@ -494,6 +494,14 @@ export class AppModule {}
## 更新历史
### 1.4.2
*
`KoishiWsAdapter`
: 支持正则表达式路径。
### 1.4
*
适配最新的 Koishi 版本的 Websocket 变动。
**使用涉及 Websocket 的 Koishi 插件需要使用附带的 `KoishiWsAdapter`。**
### 1.3.3
*
移除了
`http-proxy-middleware`
。
...
...
src/koishi.ws-adapter.ts
View file @
c1dd9e0c
...
...
@@ -7,7 +7,17 @@ export class KoishiWsAdapter extends WsAdapter {
super
(
appOrHttpServer
);
}
override
ensureHttpServerExists
(
protected
override
addWsServerToRegistry
<
T
extends
Record
<
'
path
'
,
string
>
=
any
,
>
(
wsServer
:
T
,
port
:
number
,
path
:
string
)
{
super
.
addWsServerToRegistry
(
wsServer
,
port
,
path
);
const
{
options
}
=
wsServer
as
any
;
if
(
options
&&
typeof
options
===
'
object
'
)
{
options
.
path
=
undefined
;
}
}
protected
override
ensureHttpServerExists
(
port
:
number
,
httpServer
=
http
.
createServer
(),
)
{
...
...
@@ -24,7 +34,7 @@ export class KoishiWsAdapter extends WsAdapter {
let
isRequestDelegated
=
false
;
let
fallbackWsServer
:
any
;
for
(
const
wsServer
of
wsServersCollection
)
{
if
(
pathname
===
wsServer
.
path
)
{
if
(
pathname
?.
match
(
wsServer
.
path
)
)
{
wsServer
.
handleUpgrade
(
request
,
socket
,
head
,
(
ws
:
unknown
)
=>
{
wsServer
.
emit
(
'
connection
'
,
ws
,
request
);
});
...
...
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