diff --git a/desktop/src/App.tsx b/desktop/src/App.tsx index 5aeaf9e..df7adcf 100644 --- a/desktop/src/App.tsx +++ b/desktop/src/App.tsx @@ -1,11 +1,11 @@ import { invoke } from "@tauri-apps/api/tauri"; +import { useLocalStorage } from "@uidotdev/usehooks"; import { DataConnection, Peer } from "peerjs"; import { useEffect, useRef, useState } from "react"; import { v4 as uuidv4 } from 'uuid'; import successSvg from "./assets/success.svg"; -import { BASE_URL } from "./config"; +import { BASE_URL, PEERJS_OPTIONS } from "./config"; import { createQR } from "./qr"; -import { useLocalStorage } from "@uidotdev/usehooks"; enum Action { @@ -27,7 +27,7 @@ function App() { const [id, ] = useLocalStorage('id', uuidv4()) console.log('localstorage id => ', id) const [loading, setLoading] = useState(true); - const [peer, ] = useState(new Peer(id, { pingInterval: 2000 , host: '0.peerjs.com', debug: 3})); + const [peer, ] = useState(new Peer(id, PEERJS_OPTIONS)); const [conn, setConn] = useState(null); const qrDiv = useRef(null); diff --git a/desktop/src/config.ts b/desktop/src/config.ts index 28588f3..cdd8260 100644 --- a/desktop/src/config.ts +++ b/desktop/src/config.ts @@ -1 +1,10 @@ -export const BASE_URL = 'https://thewh1teagle.github.io/mobslide/' \ No newline at end of file +import {PeerOptions} from 'peerjs' +export const BASE_URL = 'https://thewh1teagle.github.io/mobslide/' +export const PEERJS_OPTIONS: PeerOptions = { + host: 'mobslide-signaling.fly.dev', + port: 443, + path: '/', + pingInterval: 2000, + secure: true, + debug: 3 +} \ No newline at end of file diff --git a/web/.dockerignore b/web/.dockerignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/web/.dockerignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 0000000..b51edc8 --- /dev/null +++ b/web/Dockerfile @@ -0,0 +1,5 @@ +FROM peerjs/peerjs-server + +# Expose port 9000 +EXPOSE 9000 +ENTRYPOINT ["node", "peerjs.js", "--host", "0.0.0.0", "--port", "9000"] \ No newline at end of file diff --git a/web/fly.toml b/web/fly.toml new file mode 100644 index 0000000..3ca8824 --- /dev/null +++ b/web/fly.toml @@ -0,0 +1,17 @@ +# fly.toml app configuration file generated for mobslide-signaling on 2023-11-20T04:36:58+02:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = "mobslide-signaling" +primary_region = "mad" + +[build] + dockerfile = "Dockerfile" + +[http_service] + internal_port = 9000 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 diff --git a/web/src/App.tsx b/web/src/App.tsx index 2af27ac..5757eb2 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from "react"; import { useLongPress } from "use-long-press"; import Peer, { DataConnection } from "peerjs"; +import { PEERJS_OPTIONS } from "./config"; const noSleep = new NoSleep(); enum Action { @@ -68,11 +69,7 @@ function App() { async function createConnection() { return new Promise((resolve, reject) => { console.log("connecting to ", addressRef.current); - peerRef.current = new Peer({ - host: "0.peerjs.com", - debug: 3, - pingInterval: 2000, - }); + peerRef.current = new Peer(PEERJS_OPTIONS); peerRef.current.on("open", () => { if (addressRef.current) { peerRef?.current?.on("error", (error) => reject(error)); diff --git a/web/src/config.ts b/web/src/config.ts new file mode 100644 index 0000000..d0b1861 --- /dev/null +++ b/web/src/config.ts @@ -0,0 +1,10 @@ +import {PeerOptions} from 'peerjs' + +export const PEERJS_OPTIONS: PeerOptions = { + host: 'mobslide-signaling.fly.dev', + port: 443, + path: '/', + pingInterval: 2000, + secure: true, + debug: 3 +} \ No newline at end of file