apricot-webrtc-client
v1.0.0
Published
## Commands
Downloads
3
Readme
apricot-webrtc-client
Commands
Install
npm install apricot-webrtc-client
Usage
// rtc client
var client = new WebRTCClient("ws://192.168.20.75:8810", "202407191016");
// message handler
client.messageHandler = (event) => {
console.log("messageHandler:", event.data);
};
// start
await client.startAsync();
Sample
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>webrtc-client</title>
</head>
<script src="index.js"></script>
<body>
<input name="content" />
<input type="button" onclick="send()" value="send" />
</body>
</html>
<script>
// rtc client
var client = new WebRTCClient("ws://192.168.20.75:8013", "202407191016", () => {
return new RTCPeerConnection(
{
"iceServers": [
{
"urls": ["stun:stun.sipsorcery.com"],
}
]
});
});
// message handler
client.messageHandler = (event) => {
console.log("messageHandler:", event.data);
};
// start
client.startAsync();
// send data
function send() {
var content = document.getElementsByName("content")[0].value;
client.send(content);
}
</script>