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
34d0df05
Commit
34d0df05
authored
Jan 25, 2021
by
JeongYeonwoo
Browse files
chat 배열 변경 & 방목록 HomePage로 이동
parent
df3bd4e9
Changes
9
Show whitespace changes
Inline
Side-by-side
client/src/Components/Chat.js
View file @
34d0df05
...
@@ -12,20 +12,14 @@ const INIT_CHAT = {
...
@@ -12,20 +12,14 @@ const INIT_CHAT = {
time
:
''
time
:
''
}
}
function
Chat
(
props
)
{
function
Chat
(
props
)
{
const
[
sender
,
setSender
]
=
useState
([])
const
[
roomName
,
setRoomName
]
=
useState
(
''
)
const
[
roomName
,
setRoomName
]
=
useState
(
''
)
const
[
inner
,
setInner
]
=
useState
([
''
])
const
[
inner
,
setInner
]
=
useState
([
''
])
const
[
chat
,
setChat
]
=
useState
([
INIT_CHAT
])
//object로 key는 보낸사람 value는 메세지
const
[
chat
,
setChat
]
=
useState
([
INIT_CHAT
])
//object로 key는 보낸사람 value는 메세지
const
[
img
,
setImg
]
=
useState
([])
const
[
time
,
setTime
]
=
useState
([
''
])
const
simpleTime
=
new
Date
().
toLocaleTimeString
()
const
simpleTime
=
new
Date
().
toLocaleTimeString
()
const
usualTime
=
simpleTime
.
substring
(
0
,
simpleTime
.
length
-
3
)
const
usualTime
=
simpleTime
.
substring
(
0
,
simpleTime
.
length
-
3
)
const
realTime
=
new
Date
().
toISOString
()
const
realTime
=
new
Date
().
toISOString
()
const
[
disabled
,
setDisabled
]
=
useState
(
true
)
const
[
disabled
,
setDisabled
]
=
useState
(
true
)
const
[
user
,
setUser
]
=
useState
(
''
)
const
[
user
,
setUser
]
=
useState
(
''
)
const
[
error
,
setError
]
=
useState
(
''
);
const
[
error
,
setError
]
=
useState
(
''
);
...
@@ -75,29 +69,12 @@ function Chat(props) {
...
@@ -75,29 +69,12 @@ function Chat(props) {
props
.
setRecievedMsg
(
''
)
props
.
setRecievedMsg
(
''
)
setChat
([
''
])
setChat
([
''
])
// props.handleChatc()
props
.
handleChatc
()
// console.log("22222222222222222", props.leaveInfo)
// let find1 = props.leaveInfo.findIndex((ele) => ele.roomName === props.roomCode)
// console.log("33333333333333333", find1)
props
.
setLeaveInfo
([...
props
.
leaveInfo
,
{
roomName
:
props
.
roomCode
,
leaveTime
:
realTime
}])
// let find=0
// for(let i=0;i<=props.leaveInfo.length-1;i++){
// if(props.leaveInfo[i].roomName===props.roomCode){
// find = i
// break;
// }
// console.log('찾자',find)
// }
// if (props.leaveInfo[find1]) {
// props.setLeaveInfo(props.leaveInfo[find1] = { roomName: props.roomCode, leaveTime: realTime })
// console.log('트루')
// } else {
// props.setLeaveInfo([...props.leaveInfo, { roomName: props.roomCode, leaveTime: realTime }])
// console.log('폴스')
// }
// console.log('나간다', props.leaveInfo)
}
}
function
settingtime
(
hour
)
{
function
settingtime
(
hour
)
{
...
@@ -118,27 +95,14 @@ function Chat(props) {
...
@@ -118,27 +95,14 @@ function Chat(props) {
//이전 채팅 내용에 대한 것 불러오기
//이전 채팅 내용에 대한 것 불러오기
//프사 닉네임 메세지가 각각의 배열로 들어가서 띄워지는 방식
//프사 닉네임 메세지가 각각의 배열로 들어가서 띄워지는 방식
async
function
getPreviousChat
()
{
async
function
getPreviousChat
()
{
//메세지, 닉네임, 시간 불러오기
const
respond
=
await
axios
.
get
(
'
/room/getChatInfo
'
,
{
params
:
{
'
roomCode
'
:
props
.
roomCode
}
})
const
respond
=
await
axios
.
get
(
'
/room/getChatInfo
'
,
{
params
:
{
'
roomCode
'
:
props
.
roomCode
}
})
const
info
=
respond
.
data
const
info
=
respond
.
data
let
intochat
=
[]
let
intochat
=
[]
let
msglist
=
[]
let
userlist
=
[]
let
hourlist
=
[]
let
imglist
=
[]
for
(
let
prop
in
info
)
{
for
(
let
prop
in
info
)
{
let
hour
=
info
[
prop
].
createdAt
.
split
(
'
T
'
)[
1
].
split
(
'
:
'
)
let
hour
=
info
[
prop
].
createdAt
.
split
(
'
T
'
)[
1
].
split
(
'
:
'
)
hour
=
settingtime
(
hour
[
0
])
+
'
:
'
+
hour
[
1
]
hour
=
settingtime
(
hour
[
0
])
+
'
:
'
+
hour
[
1
]
msglist
.
push
(
info
[
prop
].
message
)
intochat
.
push
({
msg
:
info
[
prop
].
message
,
sender
:
info
[
prop
].
username
,
img
:
info
[
prop
].
profileimg
,
time
:
hour
})
userlist
.
push
(
info
[
prop
].
username
)
hourlist
.
push
(
hour
)
}
const
respond2
=
await
axios
.
get
(
'
/room/getProfileImage
'
,
{
params
:
{
'
userlist
'
:
userlist
}
})
imglist
=
respond2
.
data
console
.
log
(
'
확인해보자
'
,
imglist
)
for
(
let
i
=
0
;
i
<
msglist
.
length
;
i
++
)
{
intochat
.
push
({
msg
:
msglist
[
i
],
sender
:
userlist
[
i
],
img
:
imglist
[
i
].
profileimg
,
time
:
hourlist
[
i
]
})
}
}
setChat
(
intochat
)
setChat
(
intochat
)
}
}
...
...
client/src/Components/ClosedList.js
View file @
34d0df05
...
@@ -11,19 +11,6 @@ const INIT_LIST = [{
...
@@ -11,19 +11,6 @@ const INIT_LIST = [{
}]
}]
function
ClosedList
(
props
)
{
function
ClosedList
(
props
)
{
const
[
list
,
setList
]
=
useState
(
INIT_LIST
);
useEffect
(()
=>
{
getClosedList
();
},
[
props
.
roomCode
]);
async
function
getClosedList
()
{
const
userid
=
sessionStorage
.
getItem
(
'
userId
'
)
let
res
=
await
axios
.
get
(
'
/room/closedlist
'
,
{
params
:
{
'
_id
'
:
userid
}
})
setList
(
res
.
data
)
}
const
realTime
=
new
Date
().
toISOString
()
const
realTime
=
new
Date
().
toISOString
()
function
enterChatRoomCH
(
e
)
{
function
enterChatRoomCH
(
e
)
{
...
@@ -32,7 +19,7 @@ function ClosedList(props) {
...
@@ -32,7 +19,7 @@ function ClosedList(props) {
props
.
enterChatRoom
(
roomCode
)
props
.
enterChatRoom
(
roomCode
)
props
.
setRoomCode
(
roomCode
)
props
.
setRoomCode
(
roomCode
)
console
.
log
(
'
rrrrrrrrrrrrrrr
'
,
props
.
closedlist
)
console
.
log
(
'
1111111111111111111
'
,
props
.
leaveInfo
,
typeof
(
props
.
leaveInfo
))
console
.
log
(
'
1111111111111111111
'
,
props
.
leaveInfo
,
typeof
(
props
.
leaveInfo
))
}
}
...
@@ -41,8 +28,8 @@ console.log('1111111111111111111',props.leaveInfo, typeof(props.leaveInfo))
...
@@ -41,8 +28,8 @@ console.log('1111111111111111111',props.leaveInfo, typeof(props.leaveInfo))
const
[
checknew
,
setChecknew
]
=
useState
([])
const
[
checknew
,
setChecknew
]
=
useState
([])
const
[
unreadnumber
,
setUnreadnumber
]
=
useState
([
''
])
const
[
unreadnumber
,
setUnreadnumber
]
=
useState
([
''
])
async
function
dbChat
()
{
async
function
dbChat
()
{
for
(
let
i
=
0
;
i
<=
list
.
length
-
1
;
i
++
)
{
for
(
let
i
=
0
;
i
<=
props
.
closed
list
.
length
-
1
;
i
++
)
{
const
respond
=
await
axios
.
get
(
'
/room/dbChat
'
,
{
params
:
{
'
roomId
'
:
list
[
i
].
roomId
}
})
const
respond
=
await
axios
.
get
(
'
/room/dbChat
'
,
{
params
:
{
'
roomId
'
:
props
.
closed
list
[
i
].
roomId
}
})
setChecknew
(
respond
.
data
)
setChecknew
(
respond
.
data
)
}
}
}
}
...
@@ -62,8 +49,8 @@ console.log('1111111111111111111',props.leaveInfo, typeof(props.leaveInfo))
...
@@ -62,8 +49,8 @@ console.log('1111111111111111111',props.leaveInfo, typeof(props.leaveInfo))
setUnreadnumber
([
''
])
setUnreadnumber
([
''
])
let
arr
=
[]
let
arr
=
[]
for
(
let
i
=
0
;
i
<=
list
.
length
-
1
;
i
++
)
{
for
(
let
i
=
0
;
i
<=
props
.
closed
list
.
length
-
1
;
i
++
)
{
const
respond
=
await
axios
.
get
(
'
/room/unreadMessage
'
,
{
params
:
{
'
leaveInfo
'
:
props
.
leaveInfo
,
'
roomId
'
:
list
[
i
].
roomId
}
})
const
respond
=
await
axios
.
get
(
'
/room/unreadMessage
'
,
{
params
:
{
'
leaveInfo
'
:
props
.
leaveInfo
,
'
roomId
'
:
props
.
closed
list
[
i
].
roomId
}
})
// setUnreadnumber([...unreadnumber, respond.data])
// setUnreadnumber([...unreadnumber, respond.data])
arr
=
[...
arr
,
respond
.
data
]
arr
=
[...
arr
,
respond
.
data
]
}
}
...
@@ -75,7 +62,7 @@ console.log('1111111111111111111',props.leaveInfo, typeof(props.leaveInfo))
...
@@ -75,7 +62,7 @@ console.log('1111111111111111111',props.leaveInfo, typeof(props.leaveInfo))
return
(
return
(
<
div
>
<
div
>
{
list
.
map
((
item
,
index
)
=>
{
props
.
closed
list
.
map
((
item
,
index
)
=>
<
ListGroup
key
=
{
index
}
>
<
ListGroup
key
=
{
index
}
>
<
ListGroup
.
Item
action
onClick
=
{
enterChatRoomCH
}
name
=
{
item
.
roomId
}
value
=
{
item
.
roomName
}
>
<
ListGroup
.
Item
action
onClick
=
{
enterChatRoomCH
}
name
=
{
item
.
roomId
}
value
=
{
item
.
roomName
}
>
{
item
.
roomName
}
{
item
.
roomName
}
...
...
client/src/Components/OpenList.js
View file @
34d0df05
...
@@ -3,18 +3,6 @@ import { ListGroup } from 'react-bootstrap';
...
@@ -3,18 +3,6 @@ import { ListGroup } from 'react-bootstrap';
import
axios
from
'
axios
'
import
axios
from
'
axios
'
function
OpenList
(
props
)
{
function
OpenList
(
props
)
{
const
[
openlist
,
setOpenlist
]
=
useState
([])
useEffect
(()
=>
{
getOpenList
();
},
[
props
.
roomCode
]);
async
function
getOpenList
()
{
let
res
=
await
axios
.
get
(
'
/room/openlist
'
)
console
.
log
(
'
getOpenlist
'
,
res
.
data
)
setOpenlist
(
res
.
data
)
}
function
enterChatRoomCH
(
e
)
{
function
enterChatRoomCH
(
e
)
{
console
.
log
(
'
e확인
'
,
e
.
target
)
console
.
log
(
'
e확인
'
,
e
.
target
)
...
@@ -27,7 +15,7 @@ function OpenList(props) {
...
@@ -27,7 +15,7 @@ function OpenList(props) {
return
(
return
(
<
div
>
<
div
>
{
openlist
.
map
((
item
,
index
)
=>
{
props
.
openlist
.
map
((
item
,
index
)
=>
<
ListGroup
key
=
{
index
}
>
<
ListGroup
key
=
{
index
}
>
<
ListGroup
.
Item
action
onClick
=
{
enterChatRoomCH
}
name
=
{
item
.
roomId
}
>
<
ListGroup
.
Item
action
onClick
=
{
enterChatRoomCH
}
name
=
{
item
.
roomId
}
>
{
item
.
roomName
}
{
item
.
roomName
}
...
...
client/src/Pages/HomePage.js
View file @
34d0df05
...
@@ -19,6 +19,13 @@ const INIT_ROOM = {
...
@@ -19,6 +19,13 @@ const INIT_ROOM = {
roomId
:
''
,
roomId
:
''
,
member
:
''
,
member
:
''
,
}
}
const
INIT_LIST
=
[{
interest
:
''
,
isOpen
:
''
,
memeber
:
[],
roomId
:
''
,
roomName
:
''
,
}]
function
Home
()
{
function
Home
()
{
const
userName
=
sessionStorage
.
getItem
(
'
name
'
)
const
userName
=
sessionStorage
.
getItem
(
'
name
'
)
...
@@ -44,8 +51,10 @@ function Home() {
...
@@ -44,8 +51,10 @@ function Home() {
const
[
singleTime
,
setSingleTime
]
=
useState
(
''
)
const
[
singleTime
,
setSingleTime
]
=
useState
(
''
)
const
[
recievedTime
,
setRecievedTime
]
=
useState
(
''
)
const
[
recievedTime
,
setRecievedTime
]
=
useState
(
''
)
const
[
leaveInfo
,
setLeaveInfo
]
=
useState
([{
roomName
:
""
,
leaveTime
:
""
}])
const
[
leaveInfo
,
setLeaveInfo
]
=
useState
([{
roomName
:
""
,
leaveTime
:
""
}])
const
[
closedlist
,
setClosedList
]
=
useState
(
INIT_LIST
);
const
[
openlist
,
setOpenlist
]
=
useState
([])
//SOCKET 관련 시작
//SOCKET 관련 시작
function
enterChatRoom
(
rCode
)
{
//방 입장하기
function
enterChatRoom
(
rCode
)
{
//방 입장하기
...
@@ -68,6 +77,18 @@ function Home() {
...
@@ -68,6 +77,18 @@ function Home() {
setNewUser
(
data
)
setNewUser
(
data
)
})
})
async
function
getClosedList
()
{
const
userid
=
sessionStorage
.
getItem
(
'
userId
'
)
let
res
=
await
axios
.
get
(
'
/room/closedlist
'
,
{
params
:
{
'
_id
'
:
userid
}
})
setClosedList
(
res
.
data
)
}
async
function
getOpenList
()
{
let
res
=
await
axios
.
get
(
'
/room/openlist
'
)
console
.
log
(
'
getOpenlist
'
,
res
.
data
)
setOpenlist
(
res
.
data
)
}
//오픈채팅방에서 참가하기
//오픈채팅방에서 참가하기
async
function
openListroom
(
roomId
)
{
async
function
openListroom
(
roomId
)
{
console
.
log
(
roomId
)
console
.
log
(
roomId
)
...
@@ -98,6 +119,10 @@ function Home() {
...
@@ -98,6 +119,10 @@ function Home() {
e
.
preventDefault
()
e
.
preventDefault
()
}
}
useEffect
(()
=>
{
getClosedList
();
getOpenList
();
},
[
roomCode
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
(
singleChat
==
''
))
{
if
(
!
(
singleChat
==
''
))
{
...
@@ -114,7 +139,6 @@ function Home() {
...
@@ -114,7 +139,6 @@ function Home() {
}
}
},
[
singleChat
])
},
[
singleChat
])
useEffect
(()
=>
{
useEffect
(()
=>
{
socket
.
on
(
"
sendedMSG
"
,
(
sendInfo
)
=>
{
socket
.
on
(
"
sendedMSG
"
,
(
sendInfo
)
=>
{
setRecievedTime
(
sendInfo
.
time
)
setRecievedTime
(
sendInfo
.
time
)
...
@@ -131,10 +155,10 @@ function Home() {
...
@@ -131,10 +155,10 @@ function Home() {
<
Col
className
=
"
list
"
md
=
{
5
}
>
<
Col
className
=
"
list
"
md
=
{
5
}
>
<
Tabs
defaultActiveKey
=
"
closed
"
id
=
"
uncontrolled-tab-example
"
>
<
Tabs
defaultActiveKey
=
"
closed
"
id
=
"
uncontrolled-tab-example
"
>
<
Tab
eventKey
=
"
closed
"
title
=
"
내 채팅
"
onClick
=
{
handleChato
}
>
<
Tab
eventKey
=
"
closed
"
title
=
"
내 채팅
"
onClick
=
{
handleChato
}
>
<
ClosedList
singleChat
=
{
singleChat
}
recievedMsg
=
{
recievedMsg
}
leaveInfo
=
{
leaveInfo
}
setLeaveInfo
=
{
setLeaveInfo
}
enterChatRoom
=
{
enterChatRoom
}
setRoomCode
=
{
setRoomCode
}
setRoomName
=
{
setRoomName
}
roomCode
=
{
roomCode
}
/
>
<
ClosedList
closedlist
=
{
closedlist
}
singleChat
=
{
singleChat
}
recievedMsg
=
{
recievedMsg
}
leaveInfo
=
{
leaveInfo
}
setLeaveInfo
=
{
setLeaveInfo
}
enterChatRoom
=
{
enterChatRoom
}
setRoomCode
=
{
setRoomCode
}
setRoomName
=
{
setRoomName
}
roomCode
=
{
roomCode
}
/
>
<
/Tab
>
<
/Tab
>
<
Tab
eventKey
=
"
open
"
title
=
"
공개방
"
onClick
=
{
handleChatc
}
>
<
Tab
eventKey
=
"
open
"
title
=
"
공개방
"
onClick
=
{
handleChatc
}
>
<
OpenList
enterChatRoom
=
{
enterChatRoom
}
openListroom
=
{
openListroom
}
setRoomCode
=
{
setRoomCode
}
setRoomName
=
{
setRoomName
}
roomCode
=
{
roomCode
}
/
>
<
OpenList
openlist
=
{
openlist
}
enterChatRoom
=
{
enterChatRoom
}
openListroom
=
{
openListroom
}
setRoomCode
=
{
setRoomCode
}
setRoomName
=
{
setRoomName
}
roomCode
=
{
roomCode
}
/
>
<
/Tab
>
<
/Tab
>
<
/Tabs
>
<
/Tabs
>
<
/Col
>
<
/Col
>
...
...
server/controllers/room.controller.js
View file @
34d0df05
...
@@ -108,10 +108,12 @@ const unreadMessage = async (req, res) => {
...
@@ -108,10 +108,12 @@ const unreadMessage = async (req, res) => {
let
leaveInfo
=
req
.
query
.
leaveInfo
let
leaveInfo
=
req
.
query
.
leaveInfo
const
roomId
=
req
.
query
.
roomId
const
roomId
=
req
.
query
.
roomId
let
leaveTime
=
''
let
leaveTime
=
''
console
.
log
(
'
서버에서 초기 leaveInfo
'
,
leaveInfo
)
for
(
let
i
=
1
;
i
<
leaveInfo
.
length
;
i
++
)
{
//일단 형식좀 맞추고
for
(
let
i
=
1
;
i
<
leaveInfo
.
length
;
i
++
)
{
//일단 형식좀 맞추고
leaveInfo
[
i
]
=
JSON
.
parse
(
leaveInfo
[
i
])
leaveInfo
[
i
]
=
JSON
.
parse
(
leaveInfo
[
i
])
}
}
//findOne으로 해보자
for
(
let
i
=
1
;
i
<=
leaveInfo
.
length
-
1
;
i
++
)
{
//그 방의 id와 나간기록의 방과 일치하는지 확인하고
for
(
let
i
=
1
;
i
<=
leaveInfo
.
length
-
1
;
i
++
)
{
//그 방의 id와 나간기록의 방과 일치하는지 확인하고
if
(
leaveInfo
[
i
].
roomName
===
roomId
)
{
if
(
leaveInfo
[
i
].
roomName
===
roomId
)
{
leaveTime
=
leaveInfo
[
i
].
leaveTime
//그 방에서 나간 시간을 찾아옴
leaveTime
=
leaveInfo
[
i
].
leaveTime
//그 방에서 나간 시간을 찾아옴
...
@@ -122,6 +124,7 @@ const unreadMessage = async (req, res) => {
...
@@ -122,6 +124,7 @@ const unreadMessage = async (req, res) => {
const
room_id
=
await
Room
.
find
({
roomId
:
roomId
}).
select
(
'
_id
'
)
//id로 _id를 찾아와서
const
room_id
=
await
Room
.
find
({
roomId
:
roomId
}).
select
(
'
_id
'
)
//id로 _id를 찾아와서
let
unreadMsg
=
await
Chat
.
find
({
room
:
room_id
}).
select
(
'
createdAt
'
)
//그 방의 메세지와 전송시간을 가져옴
let
unreadMsg
=
await
Chat
.
find
({
room
:
room_id
}).
select
(
'
createdAt
'
)
//그 방의 메세지와 전송시간을 가져옴
let
count
=
0
let
count
=
0
//mongoose 시간비교 방법이 있음 (gte...)
for
(
let
i
=
0
;
i
<=
unreadMsg
.
length
-
1
;
i
++
)
{
for
(
let
i
=
0
;
i
<=
unreadMsg
.
length
-
1
;
i
++
)
{
const
dbtime
=
Date
.
parse
(
unreadMsg
[
i
].
createdAt
)
const
dbtime
=
Date
.
parse
(
unreadMsg
[
i
].
createdAt
)
const
parsedleaveTime
=
Date
.
parse
(
leaveTime
)
const
parsedleaveTime
=
Date
.
parse
(
leaveTime
)
...
...
server/controllers/roomEnter.controller.js
View file @
34d0df05
...
@@ -28,27 +28,13 @@ const getChatInfo = async (req, res) => {
...
@@ -28,27 +28,13 @@ const getChatInfo = async (req, res) => {
const
roomId
=
req
.
query
.
roomCode
const
roomId
=
req
.
query
.
roomCode
try
{
try
{
const
room_id
=
await
Room
.
find
({
roomId
:
roomId
}).
select
(
'
_id
'
)
//roomId로 해당 방의 _id를 찾아옴
const
room_id
=
await
Room
.
find
({
roomId
:
roomId
}).
select
(
'
_id
'
)
//roomId로 해당 방의 _id를 찾아옴
let
infolist
=
await
Chat
.
find
({
room
:
room_id
}).
select
(
'
message username createdAt
'
)
let
infolist
=
await
Chat
.
find
({
room
:
room_id
}).
select
(
'
message username createdAt
profileimg
'
)
res
.
json
(
infolist
)
res
.
json
(
infolist
)
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
500
).
send
(
'
이전 채팅 정보 불러오기를 실패하였습니다!
'
)
res
.
status
(
500
).
send
(
'
이전 채팅 정보 불러오기를 실패하였습니다!
'
)
}
}
}
}
const
getProfileImage
=
async
(
req
,
res
)
=>
{
const
nicknamelist
=
req
.
query
.
userlist
try
{
let
imglist
=
[]
for
(
let
prop
in
nicknamelist
)
{
const
getimg
=
await
User
.
find
({
nickname
:
nicknamelist
[
prop
]
}).
select
(
'
profileimg
'
)
const
eachimg
=
{
profileimg
:
getimg
[
0
].
profileimg
}
imglist
=
[...
imglist
,
eachimg
]
}
res
.
json
(
imglist
)
}
catch
(
error
)
{
res
.
status
(
500
).
send
(
'
프로필 사진 정보 불러오기를 실패하였습니다!
'
)
}
}
export
default
{
roomEnter
,
getChatInfo
,
getProfileImage
}
export
default
{
roomEnter
,
getChatInfo
}
\ No newline at end of file
\ No newline at end of file
server/models/Chat.js
View file @
34d0df05
...
@@ -16,6 +16,10 @@ const ChatSchema = new mongoose.Schema({
...
@@ -16,6 +16,10 @@ const ChatSchema = new mongoose.Schema({
type
:
String
,
type
:
String
,
required
:
true
required
:
true
},
},
profileimg
:{
type
:
String
,
default
:
'
3cd14b9bcb2007f324fcb82e0b566cce
'
}
},
{
},
{
timestamps
:
true
timestamps
:
true
})
})
...
...
server/routes/roomEnter.routers.js
View file @
34d0df05
...
@@ -9,7 +9,5 @@ router.route('/room/enterRoom')
...
@@ -9,7 +9,5 @@ router.route('/room/enterRoom')
router
.
route
(
'
/room/getChatInfo
'
)
router
.
route
(
'
/room/getChatInfo
'
)
.
get
(
roomEnterCtrl
.
getChatInfo
)
.
get
(
roomEnterCtrl
.
getChatInfo
)
router
.
route
(
'
/room/getProfileImage
'
)
.
get
(
roomEnterCtrl
.
getProfileImage
)
export
default
router
export
default
router
\ No newline at end of file
server/server.js
View file @
34d0df05
...
@@ -42,7 +42,8 @@ io.on("connection", (socket) => { // 기본 연결
...
@@ -42,7 +42,8 @@ io.on("connection", (socket) => { // 기본 연결
const
chat
=
await
new
Chat
({
const
chat
=
await
new
Chat
({
room
:
room
.
_id
,
room
:
room
.
_id
,
username
:
data
.
sendInfo
.
sender
,
username
:
data
.
sendInfo
.
sender
,
message
:
data
.
sendInfo
.
msg
message
:
data
.
sendInfo
.
msg
,
profileimg
:
data
.
sendInfo
.
img
}).
save
()
}).
save
()
console
.
log
(
'
resChat확인
'
,
chat
)
console
.
log
(
'
resChat확인
'
,
chat
)
...
...
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