48 | Direct link to source code 52 |
53 | 54 |3 | 👆Snap the the QR code or 4 | 11 | click here 13 | to open an 14 | other window from where you will control the counters on 15 | this page (like with a remote). 16 |
17 | 18 | 19 | 26 | -------------------------------------------------------------------------------- /packages/react/src/hooks.d.ts: -------------------------------------------------------------------------------- 1 | import { 2 | MasterBindConnectionApiResolved, 3 | RemoteBindConnectionApiResolved, 4 | HumanizeErrorType, 5 | IsConnectionFromRemoteType, 6 | } from "@webrtc-remote-control/core"; 7 | 8 | export function usePeer3 | Direct link to source code: 4 | 7 | {{ target }}.vue 8 | 9 | / 10 | 13 | App.vue 14 | 15 |
16 | 17 | 18 | 30 | -------------------------------------------------------------------------------- /demo/shared/js/common-peerjs.js: -------------------------------------------------------------------------------- 1 | export function getPeerjsConfig() { 2 | // when using the local signaling server 3 | if (import.meta.env.VITE_USE_LOCAL_PEER_SERVER) { 4 | return { 5 | host: "localhost", 6 | port: 9000, 7 | path: "/myapp", 8 | }; 9 | } 10 | // default case, we use the alternate server since on some mobile carriers (orange - France) 11 | // the default host 0.peerjs.com hangs on forever - see https://github.com/peers/peerjs/issues/948#issuecomment-1107437915 12 | // todo what if this fix triggers the same kind of problem on other carriers ? implement some kind of balancing ? 13 | return { 14 | host: "0.peerjs.com", 15 | port: 443, 16 | path: "/", 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /demo/counter-vue/js/RemoteCountControl.vue: -------------------------------------------------------------------------------- 1 | 2 |7 | 👆Snap the the QR code or{" "} 8 | 17 | click here 18 | {" "} 19 | to open an{" "} 20 | other window from where you will control this page (like 21 | with a remote). 22 |
23 | ); 24 | } 25 | 26 | OpenRemote.propTypes = { 27 | peerId: PropTypes.string, 28 | }; 29 | -------------------------------------------------------------------------------- /demo/counter-react/js/DirectLinkToSource.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import PropTypes from "prop-types"; 3 | 4 | export default function DirectLinkToSourceCode({ mode }) { 5 | const target = mode.at(0).toUpperCase() + mode.slice(1); 6 | return ( 7 |8 | Direct link to source code:{" "} 9 | 12 | {target}.jsx 13 | 14 | {" / "} 15 | 16 | App.jsx 17 | 18 |
19 | ); 20 | } 21 | 22 | DirectLinkToSourceCode.propTypes = { 23 | mode: PropTypes.oneOf(["master", "remote"]), 24 | }; 25 | -------------------------------------------------------------------------------- /demo/accelerometer-3d/js/DirectLinkToSource.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import PropTypes from "prop-types"; 3 | 4 | export default function DirectLinkToSourceCode({ mode }) { 5 | const target = mode.at(0).toUpperCase() + mode.slice(1); 6 | return ( 7 |8 | Direct link to source code:{" "} 9 | 12 | {target}.jsx 13 | 14 | {" / "} 15 | 16 | App.jsx 17 | 18 |
19 | ); 20 | } 21 | 22 | DirectLinkToSourceCode.propTypes = { 23 | mode: PropTypes.oneOf(["master", "remote"]), 24 | }; 25 | -------------------------------------------------------------------------------- /demo/counter-react/js/OpenRemote.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import PropTypes from "prop-types"; 3 | 4 | export default function OpenRemote({ peerId }) { 5 | return ( 6 |7 | 👆Snap the the QR code or{" "} 8 | 17 | click here 18 | {" "} 19 | to open an{" "} 20 | other window from where you will control the counters on{" "} 21 | this page (like with a remote). 22 |
23 | ); 24 | } 25 | 26 | OpenRemote.propTypes = { 27 | peerId: PropTypes.string, 28 | }; 29 | -------------------------------------------------------------------------------- /demo/shared/js/counter.master.persistance.js: -------------------------------------------------------------------------------- 1 | const MASTER_PERSISTANCE_COUNTERS_SESSION_STORAGE_KEY = 2 | "master-persist-counters"; 3 | 4 | export function persistCountersToStorage(counters) { 5 | let payload; 6 | try { 7 | payload = JSON.stringify( 8 | counters.reduce((acc, cur) => { 9 | acc[cur.peerId] = cur.counter; 10 | return acc; 11 | }, {}) 12 | ); 13 | } catch { 14 | payload = JSON.stringify({}); 15 | } 16 | sessionStorage.setItem( 17 | MASTER_PERSISTANCE_COUNTERS_SESSION_STORAGE_KEY, 18 | payload 19 | ); 20 | } 21 | 22 | export function getCountersFromStorage() { 23 | try { 24 | return JSON.parse( 25 | sessionStorage.getItem(MASTER_PERSISTANCE_COUNTERS_SESSION_STORAGE_KEY) 26 | ); 27 | } catch { 28 | return {}; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/core/remote/src/core.remote.d.ts: -------------------------------------------------------------------------------- 1 | import EventEmitter from "eventemitter3"; 2 | 3 | import { 4 | HumanizeErrorType, 5 | GetPeerIdType, 6 | SetPeerIdToSessionStorageType, 7 | } from "../../shared/common"; 8 | 9 | export { prepareUtils } from "../../shared/common"; 10 | 11 | export default function ({ 12 | humanizeError, 13 | getPeerId, 14 | setPeerIdToSessionStorage, 15 | }: { 16 | humanizeError: HumanizeErrorType; 17 | getPeerId: GetPeerIdType; 18 | setPeerIdToSessionStorage: SetPeerIdToSessionStorageType; 19 | }): { 20 | humanizeError: HumanizeErrorType; 21 | getPeerId: GetPeerIdType; 22 | bindConnection(peer: any): Promise<{ 23 | send(payload: any): any; 24 | on: InstanceType43 | ©${fromTo} - labs.topheman.com - Christophe Rosset 44 |
45 |
46 |

48 | Direct link to source code 52 |
53 | 54 |73 | Check the counter updating in real-time on the original page, thanks to 74 | WebRTC. 75 |
76 |111 | Check the counter updating in real-time on the original page, thanks to 112 | WebRTC. 113 |
114 |
110 | Global counter:
16 | Check the counter updating in real-time on the original page, thanks to 17 | WebRTC. 18 |
19 |No connected remotes
"; 82 | } else { 83 | const div = document.createElement("div"); // used for remote.name sanitizing 84 | content = `${this._data.length} connected remote${ 85 | this._data.length > 1 ? "s" : "" 86 | }
128 | 134 |
135 | ) : null} 136 | {permissionState === "denied" ? ( 137 |138 | Request to access the device orientation was rejected, please grant it 139 | by clicking yes on the prompt. 140 |
141 | ) : null} 142 | {orientation ? ( 143 |105 | Direct link to source code 109 |
110 | 111 |120 | 👆Snap the the QR code or 121 | click here to open an 122 | other window from where you will control the counters 123 | on this page (like with a remote). 124 |
125 |
126 | Global counter:
127 |
12 | Global counter:
13 |