Skip to content

Commit

Permalink
Add viewer.close() (#142)
Browse files Browse the repository at this point in the history
* Add viewer.close()

* Release 1.14.0
  • Loading branch information
Karang authored Feb 22, 2021
1 parent 9c53fc0 commit 438264a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 1.14.0

* Add viewer.close()
* Use real entity height and width
* Add points primitive

### 1.13.0

* make init and updatePosition not blocking for a faster apparent rendering
Expand Down
7 changes: 7 additions & 0 deletions lib/mineflayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,11 @@ module.exports = (bot, { viewDistance = 6, firstPerson = false, port = 3000, pre
http.listen(port, () => {
console.log(`Prismarine viewer web server running on *:${port}`)
})

bot.viewer.close = () => {
http.close()
for (const socket of sockets) {
socket.disconnect()
}
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prismarine-viewer",
"version": "1.13.3",
"version": "1.14.0",
"description": "Web based viewer",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -43,8 +43,8 @@
"jest": "^26.6.3",
"jest-puppeteer": "^4.4.0",
"minecraft-wrap": "^1.3.0",
"mineflayer": "^3.0.0",
"mineflayer-pathfinder": "^1.4.0",
"mineflayer": "^3.2.0",
"mineflayer-pathfinder": "^1.6.1",
"prismarine-schematic": "^1.2.0",
"prismarine-viewer": "file:./",
"puppeteer": "^7.0.4",
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ Draw a line passing through all the `points`.

Remove the primitive with the given id from the display.

#### bot.viewer.close ()

Stop the server and disconnect users.

## Tests

`node_modules/.bin/jest --verbose --runInBand --forceExit -t "1.16.4"`

0 comments on commit 438264a

Please sign in to comment.