Compare commits
10 commits
cc597be93b
...
3acefb8675
Author | SHA1 | Date | |
---|---|---|---|
3acefb8675 | |||
12f829e1ce | |||
818140c9e4 | |||
6460662715 | |||
88baab219a | |||
4685d36f0c | |||
e3c1a742dd | |||
a60bad8f78 | |||
f100613f41 | |||
f0b929827a |
4
.dockerignore
Normal file
4
.dockerignore
Normal file
|
@ -0,0 +1,4 @@
|
|||
Dockerfile
|
||||
.dockerignore
|
||||
node_modules
|
||||
.git
|
37
Dockerfile
Normal file
37
Dockerfile
Normal file
|
@ -0,0 +1,37 @@
|
|||
FROM debian:bullseye as builder
|
||||
|
||||
ARG NODE_VERSION=19.7.0
|
||||
|
||||
RUN apt-get update; apt install -y curl
|
||||
RUN curl https://get.volta.sh | bash
|
||||
ENV VOLTA_HOME /root/.volta
|
||||
ENV PATH /root/.volta/bin:$PATH
|
||||
RUN volta install node@${NODE_VERSION}
|
||||
|
||||
#######################################################################
|
||||
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
|
||||
# NPM will not install any package listed in "devDependencies" when NODE_ENV is set to "production",
|
||||
# to install all modules: "npm install --production=false".
|
||||
# Ref: https://docs.npmjs.com/cli/v9/commands/npm-install#description
|
||||
|
||||
ENV NODE_ENV production
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm install
|
||||
FROM debian:bullseye
|
||||
|
||||
LABEL fly_launch_runtime="nodejs"
|
||||
|
||||
COPY --from=builder /root/.volta /root/.volta
|
||||
COPY --from=builder /app /app
|
||||
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV production
|
||||
ENV PATH /root/.volta/bin:$PATH
|
||||
ENV PORT 8080
|
||||
|
||||
CMD [ "npm", "run", "start" ]
|
|
@ -43,6 +43,8 @@ Peers using the same signaling server will find each other. You can specify seve
|
|||
const provider = new WebrtcProvider('your-room-name', ydoc, { signaling: ['wss://y-webrtc-ckynwnzncc.now.sh', 'ws://localhost:4444'] })
|
||||
```
|
||||
|
||||
There is also an interesting article about setting up a scalable "serverless" signaling server by Ronny Roeller: https://medium.com/collaborne-engineering/serverless-yjs-72d0a84326a2
|
||||
|
||||
### Communication Restrictions
|
||||
|
||||
y-webrtc is restricted by the number of peers that the web browser can create. By default, every client is connected to every other client up until the maximum number of conns is reached. The clients will still sync if every client is connected at least indirectly to every other client. Theoretically, y-webrtc allows an unlimited number of users, but at some point it can't be guaranteed anymore that the clients sync any longer**. Because we don't want to be greedy,
|
||||
|
|
|
@ -4,7 +4,7 @@ import * as Y from 'yjs'
|
|||
import { WebrtcProvider } from '../src/y-webrtc.js'
|
||||
|
||||
const ydoc = new Y.Doc()
|
||||
const provider = new WebrtcProvider('webrtc-test', ydoc, { signaling: ['ws://localhost:4444'] })
|
||||
const provider = new WebrtcProvider('webrtc-test', ydoc, { signaling: ['ws://localhost:8080'] })
|
||||
const yarray = ydoc.getArray()
|
||||
|
||||
provider.on('synced', synced => {
|
||||
|
|
37
fly.toml
Normal file
37
fly.toml
Normal file
|
@ -0,0 +1,37 @@
|
|||
# fly.toml file generated for y-webrtc-eu on 2023-03-16T15:02:47+01:00
|
||||
|
||||
app = "y-webrtc-eu"
|
||||
kill_signal = "SIGINT"
|
||||
kill_timeout = 5
|
||||
processes = []
|
||||
|
||||
[env]
|
||||
|
||||
[experimental]
|
||||
auto_rollback = true
|
||||
|
||||
[[services]]
|
||||
http_checks = []
|
||||
internal_port = 8080
|
||||
processes = ["app"]
|
||||
protocol = "tcp"
|
||||
script_checks = []
|
||||
[services.concurrency]
|
||||
hard_limit = 25
|
||||
soft_limit = 20
|
||||
type = "connections"
|
||||
|
||||
[[services.ports]]
|
||||
force_https = true
|
||||
handlers = ["http"]
|
||||
port = 80
|
||||
|
||||
[[services.ports]]
|
||||
handlers = ["tls", "http"]
|
||||
port = 443
|
||||
|
||||
[[services.tcp_checks]]
|
||||
grace_period = "1s"
|
||||
interval = "15s"
|
||||
restart_limit = 0
|
||||
timeout = "2s"
|
1272
package-lock.json
generated
1272
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "y-webrtc",
|
||||
"version": "10.2.2",
|
||||
"version": "10.2.5",
|
||||
"description": "WebRTC provider for Yjs",
|
||||
"type": "module",
|
||||
"main": "./dist/y-webrtc.cjs",
|
||||
|
@ -13,6 +13,7 @@
|
|||
"url": "https://github.com/sponsors/dmonad"
|
||||
},
|
||||
"exports": {
|
||||
"module": "./src/y-webrtc.js",
|
||||
"import": "./src/y-webrtc.js",
|
||||
"require": "./dist/y-webrtc.cjs"
|
||||
},
|
||||
|
@ -70,7 +71,7 @@
|
|||
"rollup-cli": "^1.0.9",
|
||||
"rollup-plugin-terser": "^5.3.1",
|
||||
"standard": "^14.3.4",
|
||||
"typescript": "^3.9.10",
|
||||
"typescript": "^4.4.4",
|
||||
"yjs": "^13.5.20"
|
||||
},
|
||||
"peerDependenies": {
|
||||
|
|
|
@ -536,6 +536,16 @@ export class SignalingConn extends ws.WebsocketClient {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} ProviderOptions
|
||||
* @property {Array<string>} [signaling]
|
||||
* @property {string} [password]
|
||||
* @property {awarenessProtocol.Awareness} [awareness]
|
||||
* @property {number} [maxConns]
|
||||
* @property {boolean} [filterBcConns]
|
||||
* @property {any} [peerOpts]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @extends Observable<string>
|
||||
*/
|
||||
|
@ -543,19 +553,13 @@ export class WebrtcProvider extends Observable {
|
|||
/**
|
||||
* @param {string} roomName
|
||||
* @param {Y.Doc} doc
|
||||
* @param {Object} [opts]
|
||||
* @param {Array<string>?} [opts.signaling]
|
||||
* @param {string?} [opts.password]
|
||||
* @param {awarenessProtocol.Awareness?} [opts.awareness]
|
||||
* @param {number?} [opts.maxConns]
|
||||
* @param {boolean?} [opts.filterBcConns]
|
||||
* @param {any?} [opts.peerOpts]
|
||||
* @param {ProviderOptions?} opts
|
||||
*/
|
||||
constructor (
|
||||
roomName,
|
||||
doc,
|
||||
{
|
||||
signaling = ['wss://signaling.yjs.dev', 'wss://y-webrtc-signaling-eu.herokuapp.com', 'wss://y-webrtc-signaling-us.herokuapp.com'],
|
||||
signaling = ['wss://y-webrtc-eu.fly.dev'],
|
||||
password = null,
|
||||
awareness = new awarenessProtocol.Awareness(doc),
|
||||
maxConns = 20 + math.floor(random.rand() * 15), // the random factor reduces the chance that n clients form a cluster
|
||||
|
|
Loading…
Reference in a new issue