0.0.10 • Published 3 years ago

cyberdeck v0.0.10

Weekly downloads
13
License
MIT OR Apache-2.0
Repository
github
Last release
3 years ago

cyberdeck

A library for ephemeral data channel connections in the virtual web. This library is intented to use webrtc and distributed storage technologies for signalling. The basic idea is to give the the tools to get two browsers talking with as few servers as possible.

Supported tech:

  • gunDB
  • STUN
  • xirsys
  • ethereum

How to Use

Here's an extremely minimal scenario using STUN only

<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
<script type="module">
  import {CyberDeck} from "https://cdn.jsdelivr.net/npm/cyberdeck/cyberdeck.js"

(async function () {
    const isServer = getParameterByName("join") === null;
    if (isServer) {
        let [local_uuid, remote_uuid, dataChannel] = CyberDeck.createInvite({
            gundb: "gunjs.herokuapp.com",
            stun: "stun.l.my_stun_server.com:19302",
            name: "my room"
        });
        let url = window.origin + window.location.pathname + `?gundb=${gundb}&stun=${stun}&join=gun&local=${remote_uuid}&remote=${local_uuid}`;
        document.body.innerHTML = "Send this url to the other person: " + url;
        for await ( const ev in dataChannel){
            if(ev.open) dataChannel.send("Hello World!");
        }
    } else {
        let dataChannel = await CyberDeck.joinInvite({
            gundb: "gunjs.herokuapp.com",
            stun: "stun.l.my_stun_server.com:19302",
            local: getQueryString("local"),
            remote: getQueryString("remote")
        });
        for await ( const ev in dataChannel){
            if(ev.message) dataChannel.send(ev.message.data);
        }
    }
})()
  
var getQueryString = function (field, url) {
	var href = url ? url : window.location.href;
	var reg = new RegExp('[?&]' + field + '=([^&#]*)', 'i');
	var string = reg.exec(href);
	return string ? string[1] : null;
};
</script>
0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago