Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qiuxu_code
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
邱旭
qiuxu_code
Commits
938ee7fc
Commit
938ee7fc
authored
Jun 21, 2021
by
邱旭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
默认变更列表
parent
833de141
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
02.井子棋对战版-联机功能.md
doc/02.井子棋对战版-联机功能.md
+27
-0
No files found.
doc/02.井子棋对战版-联机功能.md
View file @
938ee7fc
...
...
@@ -47,3 +47,30 @@ server.listen(3001, "0.0.0.0", () => {
console
.
log
(
"服务启动完毕"
);
});
```
## 在井字棋中连接我们的服务
```
javascript
const
ws
=
new
WebSocket
(
"ws://0.0.0.0:3001"
);
ws
.
onopen
=
(
event
)
=>
{
}
ws
.
onmessage
=
(
event
)
=>
{
console
.
log
(
event
.
data
);
}
ws
.
onclose
=
(
event
)
=>
{
console
.
log
(
event
);
}
ws
.
onerror
=
(
event
)
=>
{
console
.
log
(
event
);
}
```
WebSocket 基本事件:
| 事件名 | 意义 |
| :----: | :----: |
| open | 连接 |
| message | 收到消息 |
| close | 关闭 |
| error | 异常关闭 |
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