Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WebFront
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
websystem
WebFront
Commits
529a4ff6
Commit
529a4ff6
authored
9 months ago
by
심재엽
Browse files
Options
Downloads
Patches
Plain Diff
refactor: 웹소켓 연결 경로 env 처리
parent
1863b0d5
Branches
Branches containing commit
No related tags found
1 merge request
!39
[refactor] 웹소켓 연결 경로 env 처리
Pipeline
#10979
passed
9 months ago
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/ChattingDetail.jsx
+4
-1
4 additions, 1 deletion
src/components/ChattingDetail.jsx
src/components/ChattingList.jsx
+4
-1
4 additions, 1 deletion
src/components/ChattingList.jsx
with
8 additions
and
2 deletions
src/components/ChattingDetail.jsx
+
4
−
1
View file @
529a4ff6
...
...
@@ -7,6 +7,9 @@ import Button from "../components/Button";
import
ChattingNoticeDetailModal
from
'
../components/ChattingNoticeDetailModal
'
;
import
ChattingNoticeListModal
from
'
../components/ChattingNoticeListModal
'
;
// 웹소켓 서버 연결 URL
const
WS_URL
=
process
.
env
.
REACT_APP_WS_URL
;
// 흔들리는 애니메이션을 위한 keyframes 정의
const
shakeAnimation
=
keyframes
`
0% { transform: translateY(0); }
...
...
@@ -435,7 +438,7 @@ function ChattingDetail() {
ws
.
current
.
close
();
// 기존 WebSocket 연결 종료
}
ws
.
current
=
new
WebSocket
(
'
ws://localhost:8081
'
);
ws
.
current
=
new
WebSocket
(
WS_URL
);
ws
.
current
.
onopen
=
()
=>
{
if
(
ws
.
current
.
isTimedOut
)
{
console
.
log
(
`타임아웃된 클라이언트의 재연결을 차단:
${
nickname
}
`
);
...
...
This diff is collapsed.
Click to expand it.
src/components/ChattingList.jsx
+
4
−
1
View file @
529a4ff6
...
...
@@ -2,6 +2,9 @@ import React, { useState, useEffect, useRef, useCallback } from "react";
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
useAuthStore
from
"
../store/authStore
"
;
// 웹소켓 서버 연결 URL
const
WS_URL
=
process
.
env
.
REACT_APP_WS_URL
;
function
ChattingList
()
{
const
[
rooms
,
setRooms
]
=
useState
([]);
const
[
joinedRooms
,
setJoinedRooms
]
=
useState
([]);
...
...
@@ -13,7 +16,7 @@ function ChattingList() {
// WebSocket 연결 및 실시간 업데이트
const
setupWebSocket
=
()
=>
{
ws
.
current
=
new
WebSocket
(
'
ws://localhost:8081
'
);
// WebSocket 연결
ws
.
current
=
new
WebSocket
(
WS_URL
);
// WebSocket 연결
ws
.
current
.
onopen
=
()
=>
{
console
.
log
(
'
WebSocket 연결 성공
'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment