Merge branch 'dev'

This commit is contained in:
Carlos Santos 2024-07-16 18:04:17 +02:00
commit 52b8bfdea5
12 changed files with 26 additions and 10 deletions

View File

@ -7,6 +7,10 @@ const LIVEKIT_URL = "ws://localhost:7880/";
var room;
async function joinRoom() {
// Disable 'Join' button
document.getElementById("join-button").disabled = true;
document.getElementById("join-button").innerText = "Joining...";
// Initialize a new Room object
room = new Room();
@ -77,6 +81,10 @@ async function leaveRoom() {
// Back to 'Join room' page
document.getElementById("join").hidden = false;
document.getElementById("room").hidden = true;
// Enable 'Join' button
document.getElementById("join-button").disabled = false;
document.getElementById("join-button").innerText = "Join!";
}
window.onbeforeunload = () => {

View File

@ -65,7 +65,7 @@
<label for="room-name">Room</label>
<input id="room-name" class="form-control" type="text" required />
</div>
<button class="btn btn-lg btn-success" type="submit">Join!</button>
<button id="join-button" class="btn btn-lg btn-success" type="submit">Join!</button>
</form>
</div>
</div>

View File

@ -28,6 +28,10 @@ function configureUrls() {
}
async function joinRoom() {
// Disable 'Join' button
document.getElementById("join-button").disabled = true;
document.getElementById("join-button").innerText = "Joining...";
// Initialize a new Room object
room = new LivekitClient.Room();
@ -98,6 +102,10 @@ async function leaveRoom() {
// Back to 'Join room' page
document.getElementById("join").hidden = false;
document.getElementById("room").hidden = true;
// Enable 'Join' button
document.getElementById("join-button").disabled = false;
document.getElementById("join-button").innerText = "Join!";
}
window.onbeforeunload = () => {

View File

@ -67,7 +67,7 @@
<label for="room-name">Room</label>
<input id="room-name" class="form-control" type="text" required />
</div>
<button class="btn btn-lg btn-success" type="submit">Join!</button>
<button id="join-button" class="btn btn-lg btn-success" type="submit">Join!</button>
</form>
</div>
</div>

View File

@ -53,7 +53,7 @@ app.MapPost("/token", async (HttpRequest request) =>
}
});
app.MapPost("/webhook", async (HttpRequest request) =>
app.MapPost("/livekit/webhook", async (HttpRequest request) =>
{
var body = new StreamReader(request.Body);
string postData = await body.ReadToEndAsync();

View File

@ -72,6 +72,6 @@ func main() {
router := gin.Default()
router.Use(cors.Default())
router.POST("/token", createToken)
router.POST("/webhook", receiveWebhook)
router.POST("/livekit/webhook", receiveWebhook)
router.Run(":" + SERVER_PORT)
}

View File

@ -47,7 +47,7 @@ public class Controller {
return ResponseEntity.ok(Map.of("token", token.toJwt()));
}
@PostMapping(value = "/webhook", consumes = "application/webhook+json")
@PostMapping(value = "/livekit/webhook", consumes = "application/webhook+json")
public ResponseEntity<String> receiveWebhook(@RequestHeader("Authorization") String authHeader, @RequestBody String body) {
WebhookReceiver webhookReceiver = new WebhookReceiver(LIVEKIT_API_KEY, LIVEKIT_API_SECRET);
try {

View File

@ -35,7 +35,7 @@ const webhookReceiver = new WebhookReceiver(
LIVEKIT_API_SECRET
);
app.post("/webhook", async (req, res) => {
app.post("/livekit/webhook", async (req, res) => {
try {
const event = await webhookReceiver.receive(
req.body,

View File

@ -44,7 +44,7 @@ if (isset($_SERVER["REQUEST_METHOD"]) && $_SERVER["REQUEST_METHOD"] === "POST" &
$webhookReceiver = (new WebhookReceiver($LIVEKIT_API_KEY, $LIVEKIT_API_SECRET));
if (isset($_SERVER["REQUEST_METHOD"]) && $_SERVER["REQUEST_METHOD"] === "POST" && $_SERVER["PATH_INFO"] === "/webhook") {
if (isset($_SERVER["REQUEST_METHOD"]) && $_SERVER["REQUEST_METHOD"] === "POST" && $_SERVER["PATH_INFO"] === "/livekit/webhook") {
$headers = getallheaders();
$authHeader = $headers["Authorization"];
$body = file_get_contents("php://input");

View File

@ -35,7 +35,7 @@ token_verifier = TokenVerifier(LIVEKIT_API_KEY, LIVEKIT_API_SECRET)
webhook_receiver = WebhookReceiver(token_verifier)
@app.post("/webhook")
@app.post("/livekit/webhook")
def receive_webhook():
auth_token = request.headers.get("Authorization")

View File

@ -33,7 +33,7 @@ post '/token' do
return json({token: token.to_jwt})
end
post '/webhook' do
post '/livekit/webhook' do
auth_header = request.env['HTTP_AUTHORIZATION']
token_verifier = LiveKit::TokenVerifier.new(api_key: LIVEKIT_API_KEY, api_secret: LIVEKIT_API_SECRET)
begin

View File

@ -26,7 +26,7 @@ async fn main() {
let app = Router::new()
.route("/token", post(create_token))
.route("/webhook", post(receive_webhook))
.route("/livekit/webhook", post(receive_webhook))
.layer(cors);
let listener = TcpListener::bind("0.0.0.0:".to_string() + &server_port)