-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix : fix working module version 0.0.4
- Loading branch information
Showing
12 changed files
with
44,381 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
WebpeerJS enables browser to browser connectivity without a central server. | ||
|
||
[Demo](https://nuzulul.github.io/webpeerjs/demo/) | ||
|
||
## Example | ||
|
||
``` | ||
|
@@ -16,25 +18,32 @@ void async function main() { | |
const [send,listen,members] = node.joinRoom('myroom') | ||
send('hello') | ||
listen((message,id) => { | ||
console.log(`Message from ${id} : ${message}`) | ||
}) | ||
members((data) => { | ||
console.log(`Members : ${data}`) | ||
send('hello') | ||
}) | ||
}() | ||
``` | ||
|
||
## Install | ||
|
||
NPM : | ||
|
||
``` | ||
npm i webpeerjs | ||
``` | ||
|
||
CDN : | ||
|
||
``` | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/webpeerjs.min.js"></script> | ||
``` | ||
|
||
## API | ||
|
||
- `createWebpeer()` Create a new local node. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>WebpeerJS</title> | ||
</head> | ||
<body> | ||
<div id="app"><ul id="myList"></ul></div> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/webpeerjs.min.js"></script> | ||
<script type="module"> | ||
void async function main() { | ||
|
||
function write(input){ | ||
const node = document.createElement("li") | ||
const textnode = document.createTextNode(input) | ||
node.appendChild(textnode) | ||
document.getElementById("myList").appendChild(node) | ||
} | ||
|
||
const node = await webpeerjs.createWebpeer() | ||
|
||
write(`My node id : ${node.id}`) | ||
|
||
const room = 'myroom' | ||
|
||
write(`joinRoom : ${room}`) | ||
|
||
const [send,listen,members] = node.joinRoom(room) | ||
|
||
listen((message,id) => { | ||
write(`Message from ${id} : ${message}`) | ||
}) | ||
|
||
members((data) => { | ||
write(`Members update : ${data}`) | ||
send('hello') | ||
}) | ||
|
||
}() | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.