Compare commits
No commits in common. "5108808a6c59fcccb20ebd1017711a2226cccab8" and "811e34869700b5245ff95ef41506b17b8e7d36cd" have entirely different histories.
5108808a6c
...
811e348697
11
Makefile
11
Makefile
@ -1,11 +0,0 @@
|
|||||||
build: build-server build-web-interface
|
|
||||||
echo "done"
|
|
||||||
|
|
||||||
build-server:
|
|
||||||
CGO_ENABLED=1 go build -C "./main" -o ../start
|
|
||||||
|
|
||||||
build-server-start: build-server
|
|
||||||
chmod +x ./start; ./start
|
|
||||||
|
|
||||||
build-web-interface:
|
|
||||||
cd www && npm run build
|
|
||||||
4
build.sh
Executable file
4
build.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
CGO_ENABLED=1 go build -C "$SCRIPT_DIR/main" -o ../start
|
||||||
@ -1,54 +0,0 @@
|
|||||||
import WebsocketService from "./websocket-service";
|
|
||||||
|
|
||||||
function WebRTCService() {
|
|
||||||
let videoElement;
|
|
||||||
let peerConnection;
|
|
||||||
|
|
||||||
function connect() {
|
|
||||||
let configuration = getConfiguration();
|
|
||||||
peerConnection = new RTCPeerConnection(configuration);
|
|
||||||
peerConnection.onicecandidate = (event) => {
|
|
||||||
if (event.candidate) {
|
|
||||||
console.log("New ICE candidate:", event.candidate);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
peerConnection
|
|
||||||
.createOffer({ offerToReceiveAudio: true, offerToReceiveVideo: true })
|
|
||||||
.then((offer) => {
|
|
||||||
peerConnection.setLocalDescription(offer);
|
|
||||||
console.log("Local offer:", offer);
|
|
||||||
sendOffer(offer)
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error("Error creating offer:", error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendOffer(offer) {
|
|
||||||
WebsocketService.sendJson(offer)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getConfiguration() {
|
|
||||||
return {
|
|
||||||
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function setVideoElement(element) {
|
|
||||||
videoElement = element;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getVideoElement() {
|
|
||||||
return videoElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
connect,
|
|
||||||
setVideoElement,
|
|
||||||
getVideoElement,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
WebRTCService = new WebRTCService();
|
|
||||||
|
|
||||||
export default WebRTCService;
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
function WebsocketService() {
|
|
||||||
let websocket;
|
|
||||||
|
|
||||||
initialize();
|
|
||||||
function initialize() {
|
|
||||||
let url = "ws://" + location.host + "/ws";
|
|
||||||
websocket = new WebSocket(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMessage(callback) {
|
|
||||||
if (!isWebsocketOpen()) throw new Error("Websocket is not open");
|
|
||||||
websocket.addEventListener("message", callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendMessage(message) {
|
|
||||||
if (!isWebsocketOpen()) throw new Error("Websocket is not open");
|
|
||||||
websocket.send(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendJson(jsonObject) {
|
|
||||||
let jsonString = JSON.stringify(jsonObject);
|
|
||||||
sendMessage(jsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isWebsocketOpen() {
|
|
||||||
return websocket.readyState === WebSocket.OPEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
onMessage,
|
|
||||||
sendJson,
|
|
||||||
sendMessage,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
WebsocketService = new WebsocketService();
|
|
||||||
|
|
||||||
export default WebsocketService;
|
|
||||||
@ -1,6 +1,5 @@
|
|||||||
import { createMemo, createSignal } from "solid-js";
|
import { createMemo, createSignal } from "solid-js";
|
||||||
import Integration from "../data/integration";
|
import Integration from "../data/integration";
|
||||||
import WebRTCService from "../services/webrtc-service";
|
|
||||||
|
|
||||||
const [integration, setIntegration] = createSignal(null);
|
const [integration, setIntegration] = createSignal(null);
|
||||||
|
|
||||||
@ -10,11 +9,6 @@ function IntegrationView(props) {
|
|||||||
? integration().getName()
|
? integration().getName()
|
||||||
: "Integration"
|
: "Integration"
|
||||||
);
|
);
|
||||||
|
|
||||||
function handleConnectWebRTC() {
|
|
||||||
WebRTCService.connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
class={
|
class={
|
||||||
@ -24,17 +18,6 @@ function IntegrationView(props) {
|
|||||||
>
|
>
|
||||||
<span>Integration</span>
|
<span>Integration</span>
|
||||||
<h1>{title}</h1>
|
<h1>{title}</h1>
|
||||||
<div class="d-flex flex-row">
|
|
||||||
<div class="d-flex flex-row justify-content-end flex-fill">
|
|
||||||
<button class="btn btn-dark me-2 mb-3" onClick={handleConnectWebRTC}>
|
|
||||||
<i class="bi bi-plug-fill me-2"></i>
|
|
||||||
Connect
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex-fill d-flex flex-column justify-content-center align-items-center rounded overflow-hidden">
|
|
||||||
<video class="w-100 h-100" style="background-color: #000"></video>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user