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
e2bdbc19
Commit
e2bdbc19
authored
Jan 18, 2021
by
Choi Ga Young
Browse files
에러
parent
b9c8ba1f
Changes
5
Hide whitespace changes
Inline
Side-by-side
client/src/Components/ClosedList.js
View file @
e2bdbc19
...
...
@@ -24,9 +24,9 @@ function ClosedList(props) {
console
.
log
(
e
.
target
.
name
)
console
.
log
(
e
.
target
)
const
roomName
=
e
.
target
.
name
props
.
enterChat
R
oom
(
roomName
)
// 각각의 room으로 들어가도록 설정해야 함
props
.
enterChat
r
oom
(
roomName
)
// 각각의 room으로 들어가도록 설정해야 함
props
.
setRoomName
(
roomName
)
// props.clearChat()
}
//user.hasOwnProperty('이름');
...
...
@@ -35,7 +35,7 @@ function ClosedList(props) {
<
div
>
{
list
.
map
((
item
,
index
)
=>
<
ListGroup
key
=
{
index
}
>
<
ListGroup
.
Item
action
onClick
=
{
enterChat
r
oomCH
}
name
=
{
item
.
roomName
}
>
<
ListGroup
.
Item
action
onClick
=
{
enterChat
R
oomCH
}
name
=
{
item
.
roomName
}
>
{
item
.
roomName
}
<
/ListGroup.Item
>
<
/ListGroup
>
...
...
client/src/Components/OpenList.js
View file @
e2bdbc19
...
...
@@ -18,7 +18,7 @@ function OpenList(props) {
function
enterChatRoomCH
(
e
)
{
const
roomName
=
e
.
target
.
name
props
.
enterChat
R
oom
(
roomName
)
// 각각의 room으로 들어가도록 설정해야 함
props
.
enterChat
r
oom
(
roomName
)
// 각각의 room으로 들어가도록 설정해야 함
props
.
setRoomName
(
roomName
)
// props.clearChat()
}
...
...
@@ -27,7 +27,7 @@ function OpenList(props) {
<
div
>
{
openlist
.
map
((
item
,
index
)
=>
<
ListGroup
key
=
{
index
}
>
<
ListGroup
.
Item
action
onClick
=
{
enterChat
r
oomCH
}
name
=
{
item
.
roomName
}
>
<
ListGroup
.
Item
action
onClick
=
{
enterChat
R
oomCH
}
name
=
{
item
.
roomName
}
>
{
item
.
roomName
}
<
/ListGroup.Item
>
<
/ListGroup
>
...
...
client/src/Components/RoomMake.js
View file @
e2bdbc19
...
...
@@ -19,9 +19,10 @@ function RoomMake(props) {
isRoom
?
setDisabled
(
false
)
:
setDisabled
(
true
)
},
[
room
])
const
member
=
sessionStorage
.
getItem
(
'
userId
'
);
function
handleChange
(
event
)
{
const
{
name
,
value
}
=
event
.
target
setRoom
({
...
room
,
[
name
]:
value
})
setRoom
({
...
room
,
[
name
]:
value
,
member
})
console
.
log
(
room
)
}
...
...
@@ -29,12 +30,12 @@ function RoomMake(props) {
event
.
preventDefault
()
try
{
setError
(
''
)
await
axios
.
post
(
'
/room/makeRoom
'
,
room
)
let
res
=
await
axios
.
post
(
'
/room/makeRoom
'
,
room
)
const
Id
=
res
.
data
.
roomId
alert
(
`방암호는
${
Id
}
입니다`
)
props
.
handleCloseModal
()
setRoom
(
INIT_ROOM
)
}
catch
(
error
){
}
catch
(
error
){
catchErrors
(
error
,
setError
)
}
}
...
...
client/src/Pages/HomePage.js
View file @
e2bdbc19
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
axios
from
'
axios
'
;
import
{
Row
,
Col
,
Modal
,
Button
,
Form
,
Alert
}
from
'
react-bootstrap
'
;
import
{
Row
,
Col
,
Button
}
from
'
react-bootstrap
'
;
import
Tabs
from
'
react-bootstrap/Tabs
'
;
import
Tab
from
'
react-bootstrap/Tab
'
;
import
ClosedList
from
'
../Components/ClosedList
'
;
import
OpenList
from
'
../Components/OpenList
'
;
import
Menu
from
'
../Components/Menu
'
;
import
catchErrors
from
'
../utils/catchErrors
'
;
import
{
io
}
from
"
socket.io-client
"
;
//모듈 가져오기
import
Chat
from
"
../Components/Chat
"
;
import
RoomMake
from
"
../Components/RoomMake
"
...
...
@@ -35,17 +33,7 @@ function Home() {
const
handleChato
=
()
=>
setChat
(
true
);
const
handleChatc
=
()
=>
setChat
(
false
);
const
member
=
sessionStorage
.
getItem
(
'
userId
'
);
useEffect
(()
=>
{
const
isRoom
=
Object
.
values
(
room
).
every
(
el
=>
Boolean
(
el
))
isRoom
?
setDisabled
(
false
)
:
setDisabled
(
true
)
},
[
room
])
function
handleChange
(
event
)
{
const
{
name
,
value
}
=
event
.
target
setRoom
({
...
room
,
[
name
]:
value
,
member
})
}
//SOCKET 관련 시작
function
enterChatroom
(
rName
)
{
//방 입장하기
...
...
@@ -63,8 +51,8 @@ function Home() {
msg
:
singleChat
})
},
[
singleChat
])
useEffect
(()
=>
{
socket
.
on
(
"
sendedMSG
"
,
(
msg
)
=>
{
console
.
log
(
msg
)
...
...
@@ -87,7 +75,7 @@ function Home() {
<
/Tabs
>
<
/Col
>
<
Col
style
=
{{
padding
:
"
0
"
}}
>
{
chat
?
<
Chat
handleChatc
=
{
handleChatc
}
sendMsg
=
{
sendMsg
}
singleChat
=
{
singleChat
}
recievedMsg
=
{
recievedMsg
}
setSingleChat
=
{
setSingleChat
}
roomName
=
{
roomName
}
/> : null
}
{
chat
?
<
Chat
handleChatc
=
{
handleChatc
}
sendMsg
=
{
sendMsg
}
singleChat
=
{
singleChat
}
recievedMsg
=
{
recievedMsg
}
setSingleChat
=
{
setSingleChat
}
roomName
=
{
roomName
}
/> : null
}
<
div
style
=
{{
position
:
"
fixed
"
,
bottom
:
"
20px
"
,
right
:
"
30px
"
}}
>
<
Button
variant
=
"
primary
"
onClick
=
{
handleShowModal
}
size
=
"
lg
"
block
>
...
...
@@ -101,7 +89,7 @@ function Home() {
<
/Col
>
<
/Row
>
<
RoomMake
showModal
=
{
showModal
}
handleCloseModal
=
{
handleCloseModal
}
/
>
<
EnterRoom
showEnter
=
{
showEnter
}
enterChatRoom
=
{
enterChat
R
oom
}
handleCloseEnter
=
{
handleCloseEnter
}
/
>
<
EnterRoom
showEnter
=
{
showEnter
}
enterChatRoom
=
{
enterChat
r
oom
}
handleCloseEnter
=
{
handleCloseEnter
}
/
>
<
/
>
);
}
...
...
server/controllers/room.controller.js
View file @
e2bdbc19
...
...
@@ -7,7 +7,7 @@ const nanoid = customAlphabet('1234567890abcdef', 10)
const
makeRoom
=
async
(
req
,
res
)
=>
{
console
.
log
(
req
.
body
)
const
{
roomName
,
interest
,
isOpen
,
member
}
=
req
.
body
;
console
.
log
(
roomName
,
interest
,
isOpen
,
member
)
console
.
log
(
'
콘솔확인
'
,
roomName
,
interest
,
isOpen
,
member
)
const
roomId
=
nanoid
()
const
room
=
await
Room
.
findOne
({
roomId
})
...
...
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