diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..13566b81
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/c_sharp.iml b/.idea/c_sharp.iml
new file mode 100644
index 00000000..d6ebd480
--- /dev/null
+++ b/.idea/c_sharp.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 00000000..03d9549e
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..639900d1
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..6af55c46
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/.DS_Store b/src/.DS_Store
new file mode 100644
index 00000000..b74adc47
Binary files /dev/null and b/src/.DS_Store differ
diff --git a/src/backend/.DS_Store b/src/backend/.DS_Store
new file mode 100644
index 00000000..c0876389
Binary files /dev/null and b/src/backend/.DS_Store differ
diff --git a/src/backend/.idea/compiler.xml b/src/backend/.idea/compiler.xml
index bcba8915..12e0270d 100644
--- a/src/backend/.idea/compiler.xml
+++ b/src/backend/.idea/compiler.xml
@@ -6,9 +6,8 @@
-
-
+
diff --git a/src/backend/.idea/gradle.xml b/src/backend/.idea/gradle.xml
index 43ba7ce9..c026657e 100644
--- a/src/backend/.idea/gradle.xml
+++ b/src/backend/.idea/gradle.xml
@@ -11,6 +11,14 @@
+
+
+
+
diff --git a/src/backend/.idea/misc.xml b/src/backend/.idea/misc.xml
index d696a87d..84852a65 100644
--- a/src/backend/.idea/misc.xml
+++ b/src/backend/.idea/misc.xml
@@ -1,6 +1,9 @@
+
+
+
diff --git a/src/backend/.idea/modules.xml b/src/backend/.idea/modules.xml
index e066844e..92628c2e 100644
--- a/src/backend/.idea/modules.xml
+++ b/src/backend/.idea/modules.xml
@@ -2,7 +2,15 @@
-
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/backend/.idea/modules/common_module.iml b/src/backend/.idea/modules/common_module.iml
new file mode 100644
index 00000000..e44cb71b
--- /dev/null
+++ b/src/backend/.idea/modules/common_module.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/backend/.idea/modules/common_module.main.iml b/src/backend/.idea/modules/common_module.main.iml
new file mode 100644
index 00000000..4b775d40
--- /dev/null
+++ b/src/backend/.idea/modules/common_module.main.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/backend/.idea/modules/common_module.test.iml b/src/backend/.idea/modules/common_module.test.iml
new file mode 100644
index 00000000..e7d93c56
--- /dev/null
+++ b/src/backend/.idea/modules/common_module.test.iml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/backend/.idea/modules/signaling_server.main.iml b/src/backend/.idea/modules/signaling_server.main.iml
new file mode 100644
index 00000000..5587070e
--- /dev/null
+++ b/src/backend/.idea/modules/signaling_server.main.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/backend/.idea/modules/stock_server.iml b/src/backend/.idea/modules/stock_server.iml
new file mode 100644
index 00000000..d2822dc5
--- /dev/null
+++ b/src/backend/.idea/modules/stock_server.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/backend/.idea/modules/stock_server.main.iml b/src/backend/.idea/modules/stock_server.main.iml
new file mode 100644
index 00000000..807ddc5b
--- /dev/null
+++ b/src/backend/.idea/modules/stock_server.main.iml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/backend/.idea/modules/stock_server.test.iml b/src/backend/.idea/modules/stock_server.test.iml
new file mode 100644
index 00000000..1718923d
--- /dev/null
+++ b/src/backend/.idea/modules/stock_server.test.iml
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/backend/.idea/modules/workspace_server.iml b/src/backend/.idea/modules/workspace_server.iml
new file mode 100644
index 00000000..0918f592
--- /dev/null
+++ b/src/backend/.idea/modules/workspace_server.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/backend/.idea/modules/workspace_server.main.iml b/src/backend/.idea/modules/workspace_server.main.iml
new file mode 100644
index 00000000..71503cb9
--- /dev/null
+++ b/src/backend/.idea/modules/workspace_server.main.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/backend/.idea/modules/workspace_server.test.iml b/src/backend/.idea/modules/workspace_server.test.iml
new file mode 100644
index 00000000..1b40bf12
--- /dev/null
+++ b/src/backend/.idea/modules/workspace_server.test.iml
@@ -0,0 +1,171 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/backend/signaling_server/.DS_Store b/src/backend/signaling_server/.DS_Store
new file mode 100644
index 00000000..cc883214
Binary files /dev/null and b/src/backend/signaling_server/.DS_Store differ
diff --git a/src/backend/signaling_server/.gitattributes b/src/backend/signaling_server/.gitattributes
new file mode 100644
index 00000000..8af972cd
--- /dev/null
+++ b/src/backend/signaling_server/.gitattributes
@@ -0,0 +1,3 @@
+/gradlew text eol=lf
+*.bat text eol=crlf
+*.jar binary
diff --git a/src/backend/signaling_server/.gitignore b/src/backend/signaling_server/.gitignore
new file mode 100644
index 00000000..1f21df6a
--- /dev/null
+++ b/src/backend/signaling_server/.gitignore
@@ -0,0 +1,38 @@
+HELP.md
+.gradle
+local.env
+build/
+!gradle/wrapper/gradle-wrapper.jar
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
diff --git a/src/backend/signaling_server/Dockerfile b/src/backend/signaling_server/Dockerfile
new file mode 100644
index 00000000..a64cac30
--- /dev/null
+++ b/src/backend/signaling_server/Dockerfile
@@ -0,0 +1,142 @@
+# Ubuntu Bionic 기반
+FROM ubuntu:bionic
+
+# 기본 패키지 설치
+RUN set -x \
+ && apt-get update \
+ && apt-get install -y --no-install-recommends \
+ build-essential git wget golang \
+ python3 python3-pip python3-setuptools python3-wheel ninja-build \
+ libgstreamer1.0-dev libgirepository1.0-dev libunwind-dev apt-utils libsrtp-dev \
+ gdb libmicrohttpd-dev libjansson-dev libnice-dev \
+ libssl-dev libsofia-sip-ua-dev libglib2.0-dev libopus-dev libogg-dev \
+ libconfig-dev libavutil-dev libavcodec-dev libavformat-dev libnanomsg-dev \
+ libcurl4-openssl-dev liblua5.3-dev pkg-config gengetopt libtool automake \
+ curl jq httpie vim screen doxygen graphviz \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/*
+
+# Node.js 16 및 npm 설치
+RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
+ && apt-get install -y nodejs \
+ && npm install -g wscat
+
+# CMake 설치
+RUN set -x \
+ && wget https://cmake.org/files/v3.16/cmake-3.16.2.tar.gz \
+ && tar -xvzf cmake-3.16.2.tar.gz \
+ && cd cmake-3.16.2 \
+ && ./bootstrap --prefix=/usr/local \
+ && make -j$(nproc) && make install \
+ && cd .. && rm -rf cmake-3.16.2 cmake-3.16.2.tar.gz
+
+# Clang 10 설치 및 설정
+RUN set -x \
+ && apt-get update \
+ && apt-get install -y clang-10 \
+ && update-alternatives --install /usr/bin/clang clang /usr/bin/clang-10 100 \
+ && update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-10 100
+
+# boringssl 설치
+RUN set -x \
+ && git clone https://boringssl.googlesource.com/boringssl \
+ && cd boringssl \
+ && mkdir build \
+ && cd build \
+ && cmake -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="-Wno-error" .. \
+ && ninja \
+ && mkdir -p /opt/boringssl/lib \
+ && cp ssl/libssl.a /opt/boringssl/lib/ \
+ && cp crypto/libcrypto.a /opt/boringssl/lib/ \
+ && cp -r ../include /opt/boringssl/ \
+ && cd ../.. \
+ && rm -rf boringssl
+
+# Python 패키지 설치
+RUN set -x \
+ && python3 -m pip install --upgrade pip \
+ && python3 -m pip install scikit-build \
+ && python3 -m pip install meson ninja
+
+# libsrtp 설치
+RUN set -x \
+ && wget https://github.com/cisco/libsrtp/archive/v2.2.0.tar.gz \
+ && tar xfv v2.2.0.tar.gz \
+ && cd libsrtp-2.2.0/ \
+ && ./configure --prefix=/usr --enable-openssl \
+ && make shared_library && make install \
+ && cd .. && rm -rf libsrtp-2.2.0 v2.2.0.tar.gz
+
+# libwebsockets 설치
+RUN set -x \
+ && git clone https://github.com/warmcat/libwebsockets.git \
+ && cd libwebsockets \
+ && mkdir build \
+ && cd build \
+ && cmake -DLWS_MAX_SMP=1 -DLWS_WITHOUT_EXTENSIONS=0 -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" .. \
+ && make -j$(nproc) && make install \
+ && cd ../.. && rm -rf libwebsockets
+
+# libnice 설치
+RUN set -x \
+ && git clone https://gitlab.freedesktop.org/libnice/libnice \
+ && cd libnice \
+ && meson --prefix=/usr build && ninja -C build && ninja -C build install \
+ && cd .. && rm -rf libnice
+
+# Janus 빌드 및 설치
+RUN export JANUS_WITH_POSTPROCESSING
+RUN set -x \
+ && git clone https://github.com/meetecho/janus-gateway.git \
+ && cd janus-gateway \
+ && sh autogen.sh \
+ && ./configure --prefix=/opt/janus \
+ && make -j$(nproc) \
+ && make install \
+ && make configs \
+ && cd .. && rm -rf janus-gateway
+
+# WebSockets 및 TURN/STUN 서버 설정 추가
+RUN echo ' \
+general: { \
+ ws = true \n\
+ ws_port = 8188 \n\
+ ws_interface = "0.0.0.0" \n\
+ secure = false \n\
+ ws_pingpong_interval = 50 \n\
+ ws_pingpong_timeout = 500 \n\
+} \
+' > /opt/janus/etc/janus/janus.transport.websockets.jcfg
+
+# TURN/STUN 설정 추가
+RUN echo ' \
+nat: { \n\
+ stun_server = "stun.l.google.com" \n\
+ stun_port = 19302 \n\
+ turn_server = "turn:coturn-container" \n\
+ turn_port = 3478 \n\
+ turn_type = "udp" \n\
+ turn_user = "jootalkpia" \n\
+ turn_pwd = "1234" \n\
+} \n\
+' >> /opt/janus/etc/janus/janus.jcfg
+
+# WebSockets transport 활성화
+RUN echo 'include = janus.transport.websockets.jcfg' >> /opt/janus/etc/janus/janus.jcfg
+
+# 불필요한 소스 삭제
+RUN set -x \
+ && rm -rf /libwebsockets \
+ && rm -rf /janus-gateway \
+ && rm -rf /boringssl
+
+# janus 사용자 추가 및 권한 설정
+RUN adduser --disabled-password --gecos '' janus
+RUN chown -R janus:janus /opt/janus
+RUN chmod -R 755 /opt/janus
+USER janus
+
+EXPOSE 8188 3478/udp 5349/tcp 5349/udp
+
+# 컨테이너 실행 시 Janus 실행
+CMD ["/opt/janus/bin/janus"]
\ No newline at end of file
diff --git a/src/backend/signaling_server/build.gradle b/src/backend/signaling_server/build.gradle
new file mode 100644
index 00000000..641230ab
--- /dev/null
+++ b/src/backend/signaling_server/build.gradle
@@ -0,0 +1,55 @@
+plugins {
+ id 'java'
+ id 'org.springframework.boot' version '3.4.2'
+ id 'io.spring.dependency-management' version '1.1.7'
+}
+
+group = 'com.jootalkpia'
+version = '0.0.1-SNAPSHOT'
+
+java {
+ toolchain {
+ languageVersion = JavaLanguageVersion.of(17)
+ }
+}
+
+configurations {
+ compileOnly {
+ extendsFrom annotationProcessor
+ }
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ implementation 'org.springframework.boot:spring-boot-starter-web'
+ implementation 'org.springframework.boot:spring-boot-starter-webflux'
+ implementation 'org.springframework.boot:spring-boot-starter-websocket'
+ implementation 'org.springframework.boot:spring-boot-starter-data-redis'
+
+ implementation 'com.fasterxml.jackson.core:jackson-databind'
+
+ // WebSocket API
+ implementation 'jakarta.websocket:jakarta.websocket-api:2.1.0'
+
+ // Lombok
+ compileOnly 'org.projectlombok:lombok'
+ annotationProcessor 'org.projectlombok:lombok'
+
+ // DNS 해석기 라이브러리
+ implementation 'io.netty:netty-resolver-dns-native-macos:4.1.68.Final:osx-aarch_64'
+
+ implementation 'org.springframework.boot:spring-boot-starter-websocket'
+ implementation 'org.kurento:kurento-client:7.0.0'
+
+ implementation 'org.json:json:20210307'
+
+ testImplementation 'org.springframework.boot:spring-boot-starter-test'
+ testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
+}
+
+tasks.named('test') {
+ useJUnitPlatform()
+}
diff --git a/src/backend/signaling_server/gradle/wrapper/gradle-wrapper.jar b/src/backend/signaling_server/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..a4b76b95
Binary files /dev/null and b/src/backend/signaling_server/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/src/backend/signaling_server/gradle/wrapper/gradle-wrapper.properties b/src/backend/signaling_server/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..e2847c82
--- /dev/null
+++ b/src/backend/signaling_server/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/src/backend/signaling_server/gradlew b/src/backend/signaling_server/gradlew
new file mode 100755
index 00000000..f5feea6d
--- /dev/null
+++ b/src/backend/signaling_server/gradlew
@@ -0,0 +1,252 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/src/backend/signaling_server/gradlew.bat b/src/backend/signaling_server/gradlew.bat
new file mode 100644
index 00000000..9d21a218
--- /dev/null
+++ b/src/backend/signaling_server/gradlew.bat
@@ -0,0 +1,94 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/src/backend/signaling_server/settings.gradle b/src/backend/signaling_server/settings.gradle
new file mode 100644
index 00000000..37b0d2fb
--- /dev/null
+++ b/src/backend/signaling_server/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'signaling_server'
diff --git a/src/backend/signaling_server/src/.DS_Store b/src/backend/signaling_server/src/.DS_Store
new file mode 100644
index 00000000..1b5b1a09
Binary files /dev/null and b/src/backend/signaling_server/src/.DS_Store differ
diff --git a/src/backend/signaling_server/src/main/.DS_Store b/src/backend/signaling_server/src/main/.DS_Store
new file mode 100644
index 00000000..634c67f0
Binary files /dev/null and b/src/backend/signaling_server/src/main/.DS_Store differ
diff --git a/src/backend/signaling_server/src/main/java/.DS_Store b/src/backend/signaling_server/src/main/java/.DS_Store
new file mode 100644
index 00000000..6dddd857
Binary files /dev/null and b/src/backend/signaling_server/src/main/java/.DS_Store differ
diff --git a/src/backend/signaling_server/src/main/java/com/.DS_Store b/src/backend/signaling_server/src/main/java/com/.DS_Store
new file mode 100644
index 00000000..a7b6b68c
Binary files /dev/null and b/src/backend/signaling_server/src/main/java/com/.DS_Store differ
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/.DS_Store b/src/backend/signaling_server/src/main/java/com/jootalkpia/.DS_Store
new file mode 100644
index 00000000..ec840aa5
Binary files /dev/null and b/src/backend/signaling_server/src/main/java/com/jootalkpia/.DS_Store differ
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/.DS_Store b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/.DS_Store
new file mode 100644
index 00000000..042f4b35
Binary files /dev/null and b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/.DS_Store differ
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/SignalingServerApplication.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/SignalingServerApplication.java
new file mode 100644
index 00000000..a9218e9c
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/SignalingServerApplication.java
@@ -0,0 +1,13 @@
+package com.jootalkpia.signaling_server;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SignalingServerApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SignalingServerApplication.class, args);
+ }
+
+}
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/config/KurentoClientConfig.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/config/KurentoClientConfig.java
new file mode 100644
index 00000000..9fd46434
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/config/KurentoClientConfig.java
@@ -0,0 +1,21 @@
+package com.jootalkpia.signaling_server.config;
+
+import org.kurento.client.KurentoClient;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@Configuration
+public class KurentoClientConfig {
+
+ @Value("${kurento.ws.url}")
+ private String kurentoWsUrl;
+
+ @Bean
+ public KurentoClient kurentoClient() {
+ log.info("Initializing KurentoClient with URL: {}", kurentoWsUrl);
+ return KurentoClient.create(kurentoWsUrl);
+ }
+}
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/config/WebRtcConfig.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/config/WebRtcConfig.java
new file mode 100644
index 00000000..0c5426ae
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/config/WebRtcConfig.java
@@ -0,0 +1,26 @@
+package com.jootalkpia.signaling_server.config;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.kurento.client.KurentoClient;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.config.annotation.EnableWebSocket;
+import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
+import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
+import com.jootalkpia.signaling_server.rtc.KurentoHandler;
+
+@Configuration
+@EnableWebSocket
+@RequiredArgsConstructor
+@Slf4j
+public class WebRtcConfig implements WebSocketConfigurer {
+
+ private final KurentoHandler kurentoHandler;
+
+ @Override
+ public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
+ registry.addHandler(kurentoHandler, "/signal").setAllowedOrigins("*");
+ }
+}
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/controller/HuddleController.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/controller/HuddleController.java
new file mode 100644
index 00000000..a5a51882
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/controller/HuddleController.java
@@ -0,0 +1,30 @@
+//// 허들(화상채팅방) 컨트롤러
+//package com.jootalkpia.signaling_server.controller;
+//
+//import com.jootalkpia.signaling_server.dto.HuddleDto;
+//import com.jootalkpia.signaling_server.service.HuddleService;
+//import lombok.RequiredArgsConstructor;
+//import org.springframework.web.bind.annotation.*;
+//
+//@RestController
+//@RequestMapping("/api/huddle")
+//@RequiredArgsConstructor
+//public class HuddleController {
+//
+// private final HuddleService huddleService;
+//
+// @PostMapping("/create")
+// public HuddleDto createHuddle(@RequestParam String channelId, @RequestParam String userId) {
+// return huddleService.createHuddle(channelId, userId);
+// }
+//
+// @PostMapping("/join/{huddleId}")
+// public HuddleDto joinHuddle(@PathVariable String huddleId, @RequestParam String userId) {
+// return huddleService.joinHuddle(huddleId, userId);
+// }
+//
+// @GetMapping("/status/{channelId}")
+// public HuddleDto getHuddleByChannel(@PathVariable String channelId) {
+// return huddleService.getHuddleByChannel(channelId);
+// }
+//}
\ No newline at end of file
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/controller/WebRtcController.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/controller/WebRtcController.java
new file mode 100644
index 00000000..ca1899d6
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/controller/WebRtcController.java
@@ -0,0 +1,45 @@
+//package com.jootalkpia.signaling_server.controller;
+//
+//import com.jootalkpia.signaling_server.dto.WebRtcSignalDto;
+//import com.jootalkpia.signaling_server.service.UserSessionService;
+//import com.jootalkpia.signaling_server.service.KurentoManager;
+//import org.kurento.client.MediaPipeline;
+//import org.kurento.client.WebRtcEndpoint;
+//import org.springframework.web.bind.annotation.*;
+//
+//import java.util.HashMap;
+//import java.util.Map;
+//
+//@RestController
+//@RequestMapping("/api/webrtc")
+//public class WebRtcController {
+//
+// private final UserSessionService userSessionService;
+// private final KurentoManager kurentoManager;
+// private final Map pipelines = new HashMap<>();
+//
+// public WebRtcController(UserSessionService userSessionService, KurentoManager kurentoManager) {
+// this.userSessionService = userSessionService;
+// this.kurentoManager = kurentoManager;
+// }
+//
+// @PostMapping("/offer")
+// public WebRtcSignalDto handleOffer(@RequestBody WebRtcSignalDto signalDto) {
+// String userId = signalDto.getId();
+// MediaPipeline pipeline = pipelines.computeIfAbsent(userId, k -> kurentoManager.createPipeline());
+// WebRtcEndpoint webRtcEndpoint = new WebRtcEndpoint.Builder(pipeline).build();
+//
+// String sdpAnswer = webRtcEndpoint.processOffer(signalDto.getSdpOffer());
+// webRtcEndpoint.gatherCandidates();
+//
+// return new WebRtcSignalDto(userId, signalDto.getSdpOffer(), sdpAnswer, null);
+// }
+//
+// @PostMapping("/ice")
+// public void handleIceCandidate(@RequestBody WebRtcSignalDto signalDto) {
+// String userId = signalDto.getId();
+// userSessionService.getSession(userId).getWebRtcEndpoint().addIceCandidate(
+// new org.kurento.client.IceCandidate(signalDto.getCandidate(), "", 0)
+// );
+// }
+//}
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/dto/HuddleDto.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/dto/HuddleDto.java
new file mode 100644
index 00000000..2fc35418
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/dto/HuddleDto.java
@@ -0,0 +1,20 @@
+//package com.jootalkpia.signaling_server.dto;
+//
+//import java.util.HashSet;
+//import lombok.AllArgsConstructor;
+//import lombok.Data;
+//import lombok.NoArgsConstructor;
+//import java.time.LocalDateTime;
+//import java.util.Set;
+//
+//@Data
+//@NoArgsConstructor
+//@AllArgsConstructor
+//public class HuddleDto {
+// private String huddleId;
+// private Long channelId;
+// private Long createdByUserId;
+// private LocalDateTime createdAt;
+// private LocalDateTime updatedAt;
+// private Set participants;
+//}
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/dto/WebRtcSignalDto.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/dto/WebRtcSignalDto.java
new file mode 100644
index 00000000..ec2a4879
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/dto/WebRtcSignalDto.java
@@ -0,0 +1,15 @@
+//package com.jootalkpia.signaling_server.dto;
+//
+//import lombok.AllArgsConstructor;
+//import lombok.Data;
+//import lombok.NoArgsConstructor;
+//
+//@Data
+//@NoArgsConstructor
+//@AllArgsConstructor
+//public class WebRtcSignalDto {
+// private String id;
+// private String sdpOffer;
+// private String sdpAnswer;
+// private String candidate;
+//}
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/model/Huddle.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/model/Huddle.java
new file mode 100644
index 00000000..91c9d3ac
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/model/Huddle.java
@@ -0,0 +1,24 @@
+package com.jootalkpia.signaling_server.model;
+
+import java.time.LocalDateTime;
+import java.util.Collections;
+import java.util.Set;
+
+public record Huddle(
+ String huddleId,
+ Long channelId,
+ Long createdByUserId,
+ LocalDateTime createdAt,
+ LocalDateTime updatedAt,
+ Set participants
+) {
+ public Huddle {
+ if (participants == null) {
+ participants = Collections.emptySet();
+ }
+ }
+
+ public Huddle updateParticipants(Set newParticipants) {
+ return new Huddle(this.huddleId, this.channelId, this.createdByUserId, this.createdAt, LocalDateTime.now(), newParticipants);
+ }
+}
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/repository/HuddleCacheRepository.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/repository/HuddleCacheRepository.java
new file mode 100644
index 00000000..d984d6c7
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/repository/HuddleCacheRepository.java
@@ -0,0 +1,33 @@
+package com.jootalkpia.signaling_server.repository;
+
+import com.jootalkpia.signaling_server.model.Huddle;
+import org.springframework.stereotype.Repository;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+@Repository
+public class HuddleCacheRepository {
+ private final Map huddlesById = new ConcurrentHashMap<>();
+ private final Map channelToHuddleMap = new ConcurrentHashMap<>();
+
+ public void saveHuddle(Huddle huddle) {
+ huddlesById.put(huddle.huddleId(), huddle);
+ channelToHuddleMap.put(huddle.channelId(), huddle.huddleId());
+ }
+
+ public Huddle getHuddleById(String huddleId) {
+ return huddlesById.get(huddleId);
+ }
+
+ public Huddle getHuddleByChannel(Long channelId) {
+ String huddleId = channelToHuddleMap.get(channelId);
+ return huddleId != null ? huddlesById.get(huddleId) : null;
+ }
+
+ public void deleteHuddle(String huddleId) {
+ Huddle huddle = huddlesById.remove(huddleId);
+ if (huddle != null) {
+ channelToHuddleMap.remove(huddle.channelId());
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/rtc/KurentoHandler.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/rtc/KurentoHandler.java
new file mode 100644
index 00000000..b6e71277
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/rtc/KurentoHandler.java
@@ -0,0 +1,200 @@
+package com.jootalkpia.signaling_server.rtc;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.ToNumberPolicy;
+import com.jootalkpia.signaling_server.model.Huddle;
+import com.jootalkpia.signaling_server.service.HuddleService;
+import com.jootalkpia.signaling_server.service.KurentoManager;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.kurento.client.IceCandidate;
+import org.kurento.client.WebRtcEndpoint;
+import org.springframework.stereotype.Component;
+import org.springframework.web.socket.*;
+import org.springframework.web.socket.handler.TextWebSocketHandler;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+@Slf4j
+@Component
+@RequiredArgsConstructor
+public class KurentoHandler extends TextWebSocketHandler {
+
+ private final Map userSessions = new ConcurrentHashMap<>();
+ private final Gson gson = new GsonBuilder().setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE).create();
+ private final HuddleService huddleService;
+ private final KurentoManager kurentoManager;
+
+ @Override
+ public void handleTextMessage(WebSocketSession session, TextMessage message) throws IOException {
+ Map json = gson.fromJson(message.getPayload(), Map.class);
+ String id = (String) json.get("id");
+
+ switch (id) {
+ case "createRoom" -> handleCreateRoom(session, json);
+ case "joinRoom" -> handleJoinRoom(session, json);
+ case "leaveRoom" -> handleLeaveRoom(session, json);
+ case "offer" -> handleOffer(session, json);
+ case "iceCandidate" -> handleIceCandidate(session, json);
+ default -> log.warn("Unknown message type received: {}", id);
+ }
+ }
+
+ private Long getLongValueFromJson(Map json, String key) {
+ Object value = json.get(key);
+ if (value == null) {
+ log.error("Missing required parameter: {}", key);
+ throw new IllegalArgumentException("Missing required parameter: " + key);
+ }
+ return (value instanceof Number) ? ((Number) value).longValue() : Long.parseLong(value.toString());
+ }
+
+ // 허들 생성
+ private void handleCreateRoom(WebSocketSession session, Map json) throws IOException {
+ try {
+ Long channelId = getLongValueFromJson(json, "channelId");
+ Long userId = getLongValueFromJson(json, "userId");
+
+ // 허들 생성, 저장
+ Huddle newHuddle = huddleService.createHuddle(channelId, userId);
+ kurentoManager.createRoom(newHuddle.huddleId(), channelId);
+
+ // 자동으로 허들 입장도 처리
+ Map joinJson = Map.of(
+ "id", "joinRoom",
+ "huddleId", newHuddle.huddleId(),
+ "userId", userId,
+ "channelId", channelId
+ );
+ handleJoinRoom(session, joinJson);
+
+ session.sendMessage(new TextMessage(gson.toJson(Map.of("id", "roomCreated", "huddleId", newHuddle.huddleId()))));
+ } catch (Exception e) {
+ log.error("Error creating room", e);
+ session.sendMessage(new TextMessage(gson.toJson(Map.of("id", "error", "message", "Failed to create room"))));
+ }
+ }
+
+ // 허들 입장
+ private void handleJoinRoom(WebSocketSession session, Map json) throws IOException {
+ try {
+ Long channelId = getLongValueFromJson(json, "channelId");
+ Long userId = getLongValueFromJson(json, "userId");
+ String huddleId = (String) json.get("huddleId");
+
+ huddleService.joinHuddle(huddleId, userId, channelId);
+ WebRtcEndpoint webRtcEndpoint = kurentoManager.addParticipantToRoom(huddleId, userId, channelId);
+ userSessions.put(userId, new KurentoUserSession(userId, huddleId, session, webRtcEndpoint));
+
+ session.sendMessage(new TextMessage(gson.toJson(Map.of("id", "joinedRoom", "huddleId", huddleId))));
+ } catch (Exception e) {
+ log.error("Error joining room", e);
+ session.sendMessage(new TextMessage(gson.toJson(Map.of("id", "error", "message", "Failed to join room"))));
+ }
+ }
+
+ // 허들 나감
+ private void handleLeaveRoom(WebSocketSession session, Map json) throws IOException {
+ try {
+ Long channelId = getLongValueFromJson(json, "channelId");
+ Long userId = getLongValueFromJson(json, "userId");
+ String huddleId = (String) json.get("huddleId");
+
+ huddleService.exitHuddle(huddleId, userId, channelId);
+ KurentoUserSession userSession = userSessions.remove(userId);
+
+ if (userSession == null) {
+ log.warn("User session not found for userId: {}", userId);
+ return;
+ }
+
+ kurentoManager.removeParticipantFromRoom(huddleId, userId, channelId);
+ session.sendMessage(new TextMessage(gson.toJson(Map.of("id", "leftRoom", "huddleId", huddleId))));
+ } catch (Exception e) {
+ log.error("Error leaving room", e);
+ }
+ }
+
+ // SDP Offer 처리
+ private void handleOffer(WebSocketSession session, Map json) throws IOException {
+ try {
+ Long userId = getLongValueFromJson(json, "userId");
+ String sdpOffer = (String) json.get("sdpOffer");
+
+ KurentoUserSession kUserSession = userSessions.get(userId);
+ if (kUserSession == null) {
+ log.warn("User session not found for userId: {}", userId);
+ return;
+ }
+
+ WebRtcEndpoint webRtcEndpoint = kUserSession.getWebRtcEndpoint();
+
+ // ICE Candidate 이벤트 리스너 추가 (null 값 검사)
+ webRtcEndpoint.addIceCandidateFoundListener(event -> {
+ IceCandidate candidate = event.getCandidate();
+ if (candidate.getSdpMid() == null || candidate.getSdpMLineIndex() < 0) {
+ log.warn("Invalid ICE Candidate received from Kurento: {}", candidate);
+ return; // 잘못된 데이터는 전송하지 않음
+ }
+ sendIceCandidate(session, candidate);
+ });
+
+ String sdpAnswer = webRtcEndpoint.processOffer(sdpOffer);
+ webRtcEndpoint.gatherCandidates();
+ session.sendMessage(new TextMessage(gson.toJson(Map.of("id", "answer", "sdpAnswer", sdpAnswer))));
+ } catch (Exception e) {
+ log.error("Error handling offer", e);
+ }
+ }
+
+ // ICE Candidate 처리
+ private void handleIceCandidate(WebSocketSession session, Map json) {
+ try {
+ Long userId = getLongValueFromJson(json, "userId");
+ String candidate = (String) json.get("candidate");
+
+ KurentoUserSession userSession = userSessions.get(userId);
+ if (userSession != null) {
+ userSession.getWebRtcEndpoint().addIceCandidate(new IceCandidate(candidate, "", 0));
+ }
+ } catch (Exception e) {
+ log.error("Error handling ICE candidate", e);
+ }
+ }
+
+ // ICE Candidate 전송 공통 메서드
+ private final Object webSocketLock = new Object(); // 동기화용 Lock 객체
+
+ private void sendIceCandidate(WebSocketSession session, IceCandidate candidate) {
+ synchronized (webSocketLock) { // 동기화 블록 사용
+ try {
+ // 웹소켓이 닫혀 있으면 전송 안 하도록 처리
+ if (!session.isOpen()) {
+ log.warn("WebSocket session is closed. Cannot send ICE candidate.");
+ return;
+ }
+
+ // ICE Candidate JSON 변환
+ Map candidateJson = Map.of(
+ "id", "iceCandidate",
+ "candidate", Map.of(
+ "candidate", candidate.getCandidate(),
+ "sdpMid", candidate.getSdpMid(),
+ "sdpMLineIndex", candidate.getSdpMLineIndex()
+ )
+ );
+
+ session.sendMessage(new TextMessage(gson.toJson(candidateJson))); // 동기화된 WebSocket 메시지 전송
+ log.info("Sent ICE candidate: {}", candidateJson);
+
+ } catch (IllegalStateException e) {
+ log.error("Cannot send ICE candidate. WebSocket is in an invalid state: {}", e.getMessage());
+ } catch (IOException e) {
+ log.error("Failed to send ICE candidate", e);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/rtc/KurentoRoom.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/rtc/KurentoRoom.java
new file mode 100644
index 00000000..7632cad0
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/rtc/KurentoRoom.java
@@ -0,0 +1,51 @@
+package com.jootalkpia.signaling_server.rtc;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.kurento.client.MediaPipeline;
+import org.kurento.client.WebRtcEndpoint;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+@RequiredArgsConstructor
+@Getter
+public class KurentoRoom {
+ private final String huddleId;
+ private final MediaPipeline pipeline;
+ private final Map participants = new ConcurrentHashMap<>();
+
+ // 참가자가 이미 존재하는지 확인! ❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️ 다 넣기
+ public boolean hasParticipant(String userId) {
+ return participants.containsKey(userId);
+ }
+
+ // 이미 있는 WebRtcEndpoint 반환 or 새로운 WebRtcEndpoint 생성
+ public WebRtcEndpoint addParticipant(Long userId) {
+ if (participants.containsKey(userId)) {
+ // ❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️❗️
+ return participants.get(userId);
+ }
+
+ WebRtcEndpoint webRtcEndpoint = new WebRtcEndpoint.Builder(pipeline).build();
+ participants.put(userId, webRtcEndpoint);
+ return webRtcEndpoint;
+ }
+
+ // 참가자 제거
+ public void removeParticipant(Long userId) {
+ WebRtcEndpoint endpoint = participants.remove(userId);
+ if (endpoint != null) {
+ endpoint.release();
+ }
+ }
+
+ // 방 닫기 (모든 참가자 해제)
+ public void closeRoom() {
+ for (WebRtcEndpoint endpoint : participants.values()) {
+ endpoint.release();
+ }
+ participants.clear();
+ pipeline.release();
+ }
+}
\ No newline at end of file
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/rtc/KurentoUserSession.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/rtc/KurentoUserSession.java
new file mode 100644
index 00000000..ca2dd558
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/rtc/KurentoUserSession.java
@@ -0,0 +1,20 @@
+package com.jootalkpia.signaling_server.rtc;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.kurento.client.IceCandidate;
+import org.kurento.client.WebRtcEndpoint;
+import org.springframework.web.socket.WebSocketSession;
+
+@RequiredArgsConstructor
+@Getter
+public class KurentoUserSession {
+ private final Long userId;
+ private final String huddleId;
+ private final WebSocketSession session;
+ private final WebRtcEndpoint webRtcEndpoint;
+
+ public void addIceCandidate(IceCandidate candidate) {
+ webRtcEndpoint.addIceCandidate(candidate);
+ }
+}
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/service/HuddleService.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/service/HuddleService.java
new file mode 100644
index 00000000..83d9e3e6
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/service/HuddleService.java
@@ -0,0 +1,76 @@
+package com.jootalkpia.signaling_server.service;
+
+import com.jootalkpia.signaling_server.model.Huddle;
+import com.jootalkpia.signaling_server.repository.HuddleCacheRepository;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import java.time.LocalDateTime;
+import java.util.HashSet;
+import java.util.Set;
+
+@Service
+@RequiredArgsConstructor
+public class HuddleService {
+
+ private final HuddleCacheRepository huddleCacheRepository;
+
+ public Huddle createHuddle(Long channelId, Long userId) {
+ if (huddleCacheRepository.getHuddleByChannel(channelId) != null) {
+ throw new IllegalStateException("이미 해당 채널에 허들이 존재합니다.");
+ }
+
+ Set initialParticipants = new HashSet<>();
+// initialParticipants.add(userId);
+
+ Huddle huddle = new Huddle(
+ "huddle-" + System.currentTimeMillis(),
+ channelId,
+ userId,
+ LocalDateTime.now(),
+ LocalDateTime.now(),
+ initialParticipants
+ );
+
+ huddleCacheRepository.saveHuddle(huddle);
+ return huddle;
+ }
+
+ public Huddle joinHuddle(String huddleId, Long userId, Long channelId) {
+ Huddle huddle = huddleCacheRepository.getHuddleById(huddleId);
+ if (huddle == null) throw new IllegalStateException("허들이 존재하지 않습니다.");
+
+ Huddle updatedHuddle = new Huddle(
+ huddle.huddleId(),
+ huddle.channelId(),
+ huddle.createdByUserId(),
+ huddle.createdAt(),
+ LocalDateTime.now(),
+ addParticipant(huddle.participants(), userId) // 참가자 추가
+ );
+
+ huddleCacheRepository.saveHuddle(updatedHuddle);
+ return updatedHuddle;
+ }
+
+ // 참가자 추가
+ private Set addParticipant(Set participants, Long userId) {
+ Set updatedParticipants = new HashSet<>(participants);
+ updatedParticipants.add(userId);
+ return updatedParticipants;
+ }
+
+ public void exitHuddle(String huddleId, Long userId, Long channelId) {
+ Huddle huddle = huddleCacheRepository.getHuddleById(huddleId);
+ if (huddle == null) throw new IllegalStateException("허들이 존재하지 않습니다.");
+
+ Set updatedParticipants = new HashSet<>(huddle.participants());
+ updatedParticipants.remove(userId);
+
+ Huddle updatedHuddle = huddle.updateParticipants(updatedParticipants);
+ huddleCacheRepository.saveHuddle(updatedHuddle);
+ }
+
+ public Huddle getHuddleByChannel(Long channelId) {
+ return huddleCacheRepository.getHuddleByChannel(channelId);
+ }
+}
\ No newline at end of file
diff --git a/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/service/KurentoManager.java b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/service/KurentoManager.java
new file mode 100644
index 00000000..17daf9a8
--- /dev/null
+++ b/src/backend/signaling_server/src/main/java/com/jootalkpia/signaling_server/service/KurentoManager.java
@@ -0,0 +1,65 @@
+package com.jootalkpia.signaling_server.service;
+
+import com.jootalkpia.signaling_server.rtc.KurentoRoom;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.kurento.client.KurentoClient;
+import org.kurento.client.MediaPipeline;
+import org.kurento.client.WebRtcEndpoint;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+@Service
+@RequiredArgsConstructor
+@Slf4j
+public class KurentoManager {
+
+ private final KurentoClient kurentoClient;
+ private final Map rooms = new ConcurrentHashMap<>();
+
+ // KurentoRoom도 함께 생성
+ public void createRoom(String huddleId, Long channelId) {
+ if (rooms.containsKey(channelId)) {
+ throw new IllegalStateException("이미 존재하는 KurentoRoom입니다.");
+ }
+
+ MediaPipeline pipeline = kurentoClient.createMediaPipeline();
+ KurentoRoom room = new KurentoRoom(huddleId, pipeline);
+ rooms.put(channelId, room);
+ }
+
+ public KurentoRoom getRoom(String huddleId, Long channelId) {
+ return rooms.get(channelId);
+ }
+
+ public void removeRoom(String huddleId, Long channelId) {
+ KurentoRoom room = rooms.remove(channelId);
+ if (room != null) {
+ room.closeRoom();
+ }
+ }
+
+ public WebRtcEndpoint addParticipantToRoom(String huddleId, Long userId, Long channelId) {
+ KurentoRoom room = rooms.get(channelId);
+ if (room == null) {
+ throw new IllegalStateException("존재하지 않는 KurentoRoom입니다.");
+ }
+
+ return room.addParticipant(userId);
+ }
+
+ public void removeParticipantFromRoom(String huddleId, Long userId, Long channelId) {
+ if (huddleId == null || userId == null) {
+ log.error("removeParticipantFromRoom() - roomId or userId is null");
+ return;
+ }
+ KurentoRoom room = rooms.get(channelId);
+ if (room != null) {
+ room.removeParticipant(userId);
+ }
+ }
+}
diff --git a/src/backend/signaling_server/src/main/resources/application.yml b/src/backend/signaling_server/src/main/resources/application.yml
new file mode 100644
index 00000000..937aa85c
--- /dev/null
+++ b/src/backend/signaling_server/src/main/resources/application.yml
@@ -0,0 +1,6 @@
+server:
+ port: 8080
+
+kurento:
+ ws:
+ url: "ws://192.168.0.14:8888/kurento"
diff --git a/src/backend/signaling_server/src/test/java/com/jootalkpia/signaling_server/SignalingServerApplicationTests.java b/src/backend/signaling_server/src/test/java/com/jootalkpia/signaling_server/SignalingServerApplicationTests.java
new file mode 100644
index 00000000..c3fb9ba5
--- /dev/null
+++ b/src/backend/signaling_server/src/test/java/com/jootalkpia/signaling_server/SignalingServerApplicationTests.java
@@ -0,0 +1,13 @@
+package com.jootalkpia.signaling_server;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class SignalingServerApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/src/backend/workspace_server/.DS_Store b/src/backend/workspace_server/.DS_Store
new file mode 100644
index 00000000..d6aff34a
Binary files /dev/null and b/src/backend/workspace_server/.DS_Store differ
diff --git a/src/backend/workspace_server/src/.DS_Store b/src/backend/workspace_server/src/.DS_Store
new file mode 100644
index 00000000..3ec1d1ed
Binary files /dev/null and b/src/backend/workspace_server/src/.DS_Store differ