Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
messenger
Commits
8abb9799
Commit
8abb9799
authored
Jan 22, 2021
by
우지원
Browse files
Merge remote-tracking branch 'origin/young' into jiweon827
parents
70f71d05
98350914
Changes
2
Show whitespace changes
Inline
Side-by-side
client/src/Components/EnterRoom.js
View file @
8abb9799
...
@@ -24,6 +24,7 @@ function EnterRoom(props) {
...
@@ -24,6 +24,7 @@ function EnterRoom(props) {
let
res
=
await
axios
.
post
(
'
/room/enterRoom
'
,
{
enterCode
})
let
res
=
await
axios
.
post
(
'
/room/enterRoom
'
,
{
enterCode
})
await
axios
.
put
(
'
/room/member
'
,
{
userId
:
userId
,
roomId
:
enterCode
})
await
axios
.
put
(
'
/room/member
'
,
{
userId
:
userId
,
roomId
:
enterCode
})
props
.
setRoomName
(
res
.
data
)
props
.
setRoomName
(
res
.
data
)
props
.
setRoomCode
(
enterCode
)
props
.
enterChatRoom
(
enterCode
)
props
.
enterChatRoom
(
enterCode
)
props
.
handleCloseEnter
()
props
.
handleCloseEnter
()
props
.
handleChato
()
props
.
handleChato
()
...
...
client/src/Pages/HomePage.js
View file @
8abb9799
...
@@ -28,7 +28,7 @@ function Home() {
...
@@ -28,7 +28,7 @@ function Home() {
const
[
chat
,
setChat
]
=
useState
(
false
);
const
[
chat
,
setChat
]
=
useState
(
false
);
const
[
open
,
setOpen
]
=
useState
(
false
);
const
[
open
,
setOpen
]
=
useState
(
false
);
const
[
room
,
setRoom
]
=
useState
(
INIT_ROOM
)
const
[
room
,
setRoom
]
=
useState
(
INIT_ROOM
)
const
[
show
,
setShow
]
=
useState
(
tru
e
)
const
[
show
,
setShow
]
=
useState
(
fals
e
)
//소켓
//소켓
const
[
singleChat
,
setSingleChat
]
=
useState
(
''
)
const
[
singleChat
,
setSingleChat
]
=
useState
(
''
)
...
@@ -56,7 +56,7 @@ function Home() {
...
@@ -56,7 +56,7 @@ function Home() {
const
handleCloseEnter
=
()
=>
setShowEnter
(
false
);
const
handleCloseEnter
=
()
=>
setShowEnter
(
false
);
const
handleShowEnter
=
()
=>
setShowEnter
(
true
);
const
handleShowEnter
=
()
=>
setShowEnter
(
true
);
const
handleChato
=
()
=>
setChat
(
true
);
const
handleChato
=
()
=>
setChat
(
true
);
const
handleChatc
=
()
=>
set
Open
(
tru
e
);
const
handleChatc
=
()
=>
set
Chat
(
fals
e
);
socket
.
on
(
"
sendUser
"
,
(
data
)
=>
{
socket
.
on
(
"
sendUser
"
,
(
data
)
=>
{
setNewUser
(
data
)
setNewUser
(
data
)
...
@@ -74,6 +74,8 @@ function Home() {
...
@@ -74,6 +74,8 @@ function Home() {
setShow
(
false
)
setShow
(
false
)
}
}
async
function
attendListRoom
()
{
async
function
attendListRoom
()
{
const
userId
=
sessionStorage
.
getItem
(
'
userId
'
);
//sessionStorage에 저장된 userId가져옴
const
userId
=
sessionStorage
.
getItem
(
'
userId
'
);
//sessionStorage에 저장된 userId가져옴
const
roomId
=
room
.
roomId
const
roomId
=
room
.
roomId
...
@@ -92,22 +94,6 @@ function Home() {
...
@@ -92,22 +94,6 @@ function Home() {
e
.
preventDefault
()
e
.
preventDefault
()
}
}
useEffect
(()
=>
{
if
(
!
(
singleChat
==
''
))
{
socket
.
emit
(
"
chat
"
,
{
roomInfo
:
roomCode
,
sendInfo
:
{
msg
:
singleChat
,
sender
:
singleUser
,
img
:
singleImg
}
})
setSingleChat
([
''
])
}
},
[
singleChat
])
useEffect
(()
=>
{
useEffect
(()
=>
{
socket
.
on
(
"
sendedMSG
"
,
(
sendInfo
)
=>
{
socket
.
on
(
"
sendedMSG
"
,
(
sendInfo
)
=>
{
setRecievedImg
(
sendInfo
.
img
)
setRecievedImg
(
sendInfo
.
img
)
...
@@ -125,8 +111,8 @@ function Home() {
...
@@ -125,8 +111,8 @@ function Home() {
<
Tab
eventKey
=
"
closed
"
title
=
"
내 채팅
"
onClick
=
{
handleChato
}
>
<
Tab
eventKey
=
"
closed
"
title
=
"
내 채팅
"
onClick
=
{
handleChato
}
>
<
ClosedList
enterChatRoom
=
{
enterChatRoom
}
setRoomCode
=
{
setRoomCode
}
setRoomName
=
{
setRoomName
}
roomCode
=
{
roomCode
}
/
>
<
ClosedList
enterChatRoom
=
{
enterChatRoom
}
setRoomCode
=
{
setRoomCode
}
setRoomName
=
{
setRoomName
}
roomCode
=
{
roomCode
}
/
>
<
/Tab
>
<
/Tab
>
<
Tab
eventKey
=
"
open
"
title
=
"
공개방
"
onClick
=
{
handleChat
c
}
>
<
Tab
eventKey
=
"
open
"
title
=
"
공개방
"
onClick
=
{
handleChat
o
}
>
<
OpenList
openListroom
=
{
openListroom
}
setRoomCode
=
{
setRoomCode
}
setRoomName
=
{
setRoomName
}
roomCode
=
{
roomCode
}
/
>
<
OpenList
enterChatRoom
=
{
enterChatRoom
}
openListroom
=
{
openListroom
}
setRoomCode
=
{
setRoomCode
}
setRoomName
=
{
setRoomName
}
roomCode
=
{
roomCode
}
/
>
<
/Tab
>
<
/Tab
>
<
/Tabs
>
<
/Tabs
>
<
/Col
>
<
/Col
>
...
@@ -142,12 +128,8 @@ function Home() {
...
@@ -142,12 +128,8 @@ function Home() {
{
chat
?
{
chat
?
<
Chat
handleChatc
=
{
handleChatc
}
sendMsg
=
{
sendMsg
}
singleChat
=
{
singleChat
}
recievedMsg
=
{
recievedMsg
}
setSingleChat
=
{
setSingleChat
}
roomCode
=
{
roomCode
}
roomName
=
{
roomName
}
/
>
<
Chat
handleChatc
=
{
handleChatc
}
sendMsg
=
{
sendMsg
}
singleChat
=
{
singleChat
}
recievedMsg
=
{
recievedMsg
}
setSingleChat
=
{
setSingleChat
}
roomCode
=
{
roomCode
}
roomName
=
{
roomName
}
/
>
:
null
}
:
null
}
{(
!
show
&&
open
)
?
null
:
<
div
style
=
{{
position
:
"
fixed
"
,
bottom
:
"
20px
"
,
right
:
"
30px
"
}}
>
{
open
?
<
Button
variant
=
"
primary
"
onClick
=
{
handleShowModal
}
size
=
"
lg
"
block
>
생성
<
/Button
>
<
div
className
=
"
vh-90 flex-column align-items-center justify-content-center mt-2
"
variant
=
"
dark
"
>
<
Button
variant
=
"
secondary
"
onClick
=
{
handleShowEnter
}
size
=
"
lg
"
block
>
참가
<
/Button
>
<
/div>
}
<
/
>
{
open
?
<
div
className
=
"
vh-90 flex-column align-items-center justify-content-center mt-2
"
variant
=
"
dark
"
>
<
div
className
=
"
d-flex justify-content-center
"
>
<
div
className
=
"
d-flex justify-content-center
"
>
<
div
className
=
"
mt-5 p-5 shadow w-75
"
>
<
div
className
=
"
mt-5 p-5 shadow w-75
"
>
<
h2
className
=
"
d-flex justify-content-center mb-3
"
>
현재
{
room
.
roomName
}
방
입니다
.
<
/h2
>
<
h2
className
=
"
d-flex justify-content-center mb-3
"
>
현재
{
room
.
roomName
}
방
입니다
.
<
/h2
>
...
@@ -160,7 +142,9 @@ function Home() {
...
@@ -160,7 +142,9 @@ function Home() {
<
/Row
>
<
/Row
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div> : null
}
<
/div
>
:
null
}
<
/
>
<
/Col
>
<
/Col
>
<
/Row
>
<
/Row
>
<
RoomMake
showModal
=
{
showModal
}
handleCloseModal
=
{
handleCloseModal
}
/
>
<
RoomMake
showModal
=
{
showModal
}
handleCloseModal
=
{
handleCloseModal
}
/
>
...
@@ -169,4 +153,4 @@ function Home() {
...
@@ -169,4 +153,4 @@ function Home() {
);
);
}
}
export
default
Home
;
export
default
Home
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment