feat: 초기설정
This commit is contained in:
parent
2d268af334
commit
80513c0146
@ -1,38 +1,31 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'org.springframework.boot' version '3.3.1'
|
id 'org.springframework.boot' version '3.2.7'
|
||||||
id 'io.spring.dependency-management' version '1.1.5'
|
id 'io.spring.dependency-management' version '1.1.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'com.edufocus'
|
group = 'io.openvidu'
|
||||||
version = '0.0.1-SNAPSHOT'
|
version = '0.0.1-SNAPSHOT'
|
||||||
|
description = 'Basic server application built for Java with Spring Boot'
|
||||||
java {
|
sourceCompatibility = '17'
|
||||||
toolchain {
|
targetCompatibility = '17'
|
||||||
languageVersion = JavaLanguageVersion.of(17)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
compileOnly {
|
|
||||||
extendsFrom annotationProcessor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
compileOnly 'org.projectlombok:lombok'
|
implementation 'org.openpnp:opencv:4.9.0-0'
|
||||||
runtimeOnly 'com.mysql:mysql-connector-j'
|
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||||
annotationProcessor 'org.projectlombok:lombok'
|
implementation 'io.livekit:livekit-server:0.5.11'
|
||||||
|
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||||
|
implementation 'mysql:mysql-connector-java:8.0.33'
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
implementation group: 'io.livekit', name: 'livekit-server', version: '0.6.1'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('test') {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.edufocus.edufocus.video.controller;
|
||||||
|
|
||||||
|
import io.livekit.server.AccessToken;
|
||||||
|
import io.livekit.server.RoomJoin;
|
||||||
|
import io.livekit.server.RoomName;
|
||||||
|
import io.livekit.server.WebhookReceiver;
|
||||||
|
import livekit.LivekitWebhook.WebhookEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
@RestController
|
||||||
|
public class Controller {
|
||||||
|
|
||||||
|
@Value("${livekit.api.key}")
|
||||||
|
private String LIVEKIT_API_KEY;
|
||||||
|
|
||||||
|
@Value("${livekit.api.secret}")
|
||||||
|
private String LIVEKIT_API_SECRET;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param params JSON object with roomName and participantName
|
||||||
|
* @return JSON object with the JWT token
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/token")
|
||||||
|
public ResponseEntity<Map<String, String>> createToken(@RequestBody Map<String, String> params) {
|
||||||
|
String roomName = params.get("roomName");
|
||||||
|
String participantName = params.get("participantName");
|
||||||
|
|
||||||
|
if (roomName == null || participantName == null) {
|
||||||
|
return ResponseEntity.badRequest().body(Map.of("errorMessage", "roomName and participantName are required"));
|
||||||
|
}
|
||||||
|
|
||||||
|
AccessToken token = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET);
|
||||||
|
|
||||||
|
|
||||||
|
token.setName(participantName);
|
||||||
|
token.setIdentity(participantName);
|
||||||
|
token.addGrants(new RoomJoin(true), new RoomName(roomName));
|
||||||
|
|
||||||
|
// 방이름으로 입장하는건데
|
||||||
|
// 만약 수강생에 DB에 신청한 강의명이 없다면 들어갈수 없음
|
||||||
|
// 검증 로직만 추가하면 될듯?
|
||||||
|
|
||||||
|
|
||||||
|
return ResponseEntity.ok(Map.of("token", token.toJwt()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/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 {
|
||||||
|
WebhookEvent event = webhookReceiver.receive(body, authHeader);
|
||||||
|
System.out.println("LiveKit Webhook: " + event.toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error validating webhook event: " + e.getMessage());
|
||||||
|
}
|
||||||
|
return ResponseEntity.ok("ok");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1 +1,17 @@
|
|||||||
spring.application.name=edufocus
|
spring.application.name=edufocus
|
||||||
|
|
||||||
|
server.port=${SERVER_PORT:6080}
|
||||||
|
server.ssl.enabled=false
|
||||||
|
|
||||||
|
# LiveKit configuration
|
||||||
|
livekit.api.key=${LIVEKIT_API_KEY:devkey}
|
||||||
|
livekit.api.secret=${LIVEKIT_API_SECRET:secret}
|
||||||
|
|
||||||
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
|
spring.datasource.url=jdbc:mysql://localhost:3306/edufocus?serverTimezone=Asia/Seoul
|
||||||
|
spring.datasource.username=root
|
||||||
|
spring.datasource.password=root
|
||||||
|
|
||||||
|
spring.jpa.database=mysql
|
||||||
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
|
spring.jpa.show-sql=true
|
||||||
|
Loading…
Reference in New Issue
Block a user