Skip to content

Commit

Permalink
Merge pull request #50 from jjikky/refactor/prod-deploy
Browse files Browse the repository at this point in the history
prod 무중단 배포 스크립트 적용
  • Loading branch information
jjikky authored Sep 9, 2024
2 parents 5a6c2dd + 30feeb3 commit 06f2368
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/common/modules/socket/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const https = require('https');
// TODO : 로깅 분리 및 모니터링 달기
// TODO : 요청 분리
// TOOD : 예외처리 분리
const redisCli = require('../redis'); // Redis 클라이언트 모듈 경로
const redisCli = require('../redis');

module.exports = socketIoLoader = (io) => {
const maximum = config.maximumConnection || 9;
Expand Down Expand Up @@ -48,18 +48,12 @@ module.exports = socketIoLoader = (io) => {
const objetKey = `objet:${objet_id}`;
const socketKey = `socket:${socket_id}`;
breakLine();
console.log(`[ Join Objet ] - Request`);
console.log(
`[ Join Objet ] - Data : Objet ID: ${objet_id} / Nickname: ${nickname} / User ID: ${user_id} / Profile Image: ${profile_image}`
);

const usersInObjet = await redisCli.lRange(objetKey, 0, -1);
if (usersInObjet.length >= maximum) {
socket.emit('objet_full');
return;
}

// Add the user to the list in Redis
await redisCli.rPush(objetKey, JSON.stringify({ socket_id, nickname, user_id, profile_image }));
await redisCli.set(socketKey, objet_id);

Expand All @@ -76,39 +70,30 @@ module.exports = socketIoLoader = (io) => {
io.to(socket_id).emit('all_users', usersInThisObjet);
});

// WebRTC 연결을 시도
socket.on('offer', (data) => {
//console.log(data.sdp);
// 대상 사용자에게 연결 제안(offer)을 전송.
socket.to(data.offerReceiveID).emit('getOffer', {
sdp: data.sdp,
offerSendID: data.offerSendID,
// TODO : user_id로 변경
offerSendNickname: data.offerSendNickname,
offerSendProfileImage: data.offerSendProfileImage,
});
});

// WebRTC 연결에 대한 응답 처리
socket.on('answer', (data) => {
socket.to(data.answerReceiveID).emit('getAnswer', {
sdp: data.sdp,
answerSendID: data.answerSendID,
});
});

// ICE 후보 정보 전송
socket.on('candidate', (data) => {
//console.log(data.candidate);
socket.to(data.candidateReceiveID).emit('getCandidate', {
candidate: data.candidate,
candidateSendID: data.candidateSendID,
});
});

// 클라이언트 연결 해제 처리
socket.on('disconnect', async () => {
// TODO : SPRING SERVER에 exit objet 요청
const socketKey = `socket:${socket_id}`;
const objet_id = await redisCli.get(socketKey);

Expand Down

0 comments on commit 06f2368

Please sign in to comment.