Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ console.log(`Map tiles: http://127.0.0.1:${localPort}/maps/default/style.json`)
console.log(`P2P sharing: listening on 0.0.0.0:${remotePort} (Noise encrypted)`)
```

### Pausing while the app is suspended

iOS can reclaim the listening sockets of a suspended app, so after the app resumes the server no longer accepts connections even though the process is still running. Stop listening when the app moves to the background and start again when it returns:

```javascript
// App moved to the background
await server.pauseListening()

// App returned to the foreground
const ports = await server.resumeListening()
```

`pauseListening()` only closes the listening sockets: map shares and downloads are kept, and requests and transfers already in progress carry on (idle keep-alive connections to the local port are closed). A download that hasn't connected to the sender yet will fail while the sender is paused. `resumeListening()` listens on the same ports again, so URLs handed out earlier keep working. If a port was taken while paused it falls back to a random port and resolves with the new one. Only `resumeListening()` undoes a pause; `listen()` rejects with a `SERVER_PAUSED` error while paused, so a stray `listen()` elsewhere in the app can't quietly reopen the sockets in the background.

## Using Maps in MapLibre

Once the server is running, configure MapLibre to use it:
Expand Down
46 changes: 0 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"p-mutex": "^1.0.0",
"secret-stream-http": "^2.0.0",
"smp-noto-glyphs": "^2.0.0",
"start-stop-state-machine": "^2.0.0",
"styled-map-package-api": "^6.0.0",
"typebox": "~1.3.25",
"typed-event-target": "^4.3.3"
Expand Down
Loading
Loading