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
54789675
Commit
54789675
authored
Jan 22, 2021
by
Choi Ga Young
Browse files
병합에러수정
parent
e9b2bd86
Changes
3
Show whitespace changes
Inline
Side-by-side
client/src/Components/Chat.js
View file @
54789675
...
...
@@ -40,7 +40,6 @@ function Chat(props) {
props
.
setSingleImg
(
user
.
profileimg
)
props
.
setSingleUser
(
user
.
nickname
)
// props.setSingleUser(sessionStorage.getItem('name'))
props
.
setSingleChat
(
inner
)
props
.
sendMsg
(
e
)
...
...
@@ -48,7 +47,7 @@ function Chat(props) {
setDisabled
(
true
)
}
function
handleClick
(
e
)
{
function
handleClick
()
{
setChat
([])
props
.
handleChatc
()
}
...
...
@@ -108,8 +107,7 @@ function Chat(props) {
})
}
<
Button
variant
=
"
light
"
onClick
=
{
props
.
handleChatc
}
>
{
`<`
}
<
/Button
>
<
Button
variant
=
"
light
"
onClick
=
{
handleClick
}
>
{
`<`
}
<
/Button
>
<
/Container
>
<
Form
onSubmit
=
{
sendMsgCH
}
fluid
>
...
...
client/src/Pages/HomePage.js
View file @
54789675
...
...
@@ -51,6 +51,11 @@ function Home() {
setNewUser
(
data
)
})
const
sendMsg
=
(
e
)
=>
{
e
.
preventDefault
()
}
useEffect
(()
=>
{
if
(
!
(
singleChat
==
''
))
{
socket
.
emit
(
"
chat
"
,
{
...
...
@@ -67,7 +72,7 @@ function Home() {
useEffect
(()
=>
{
socket
.
on
(
"
sendedMSG
"
,
(
msg
)
=>
{
socket
.
on
(
"
sendedMSG
"
,
(
sendInfo
)
=>
{
setRecievedImg
(
sendInfo
.
img
)
setRecievedUser
(
sendInfo
.
sender
)
setRecievedMsg
(
sendInfo
.
msg
)
...
...
server/server.js
View file @
54789675
import
express
,
{
response
}
from
'
express
'
import
express
from
'
express
'
import
connectDb
from
'
./utils/connectDb.js
'
import
userRouter
from
'
./routes/user.routes.js
'
import
authRouter
from
'
./routes/auth.routes.js
'
...
...
@@ -9,7 +9,6 @@ import http from "http";
import
{
Server
}
from
'
socket.io
'
;
import
cors
from
"
cors
"
import
Room
from
'
./models/Room.js
'
import
{
nextTick
}
from
'
process
'
import
Chat
from
"
./models/Chat.js
"
connectDb
()
...
...
@@ -29,8 +28,8 @@ io.on("connection", (socket) => { // 기본 연결
socket
.
join
(
roomInfo
);
//클라이언트에서 data에 적힌 room으로 참여시킴
});
socket
.
on
(
'
newUser
'
,
(
data
)
=>
{
console
.
log
(
'
newUser
'
,
data
)
socket
.
on
(
'
newUser
'
,
(
data
)
=>
{
console
.
log
(
'
newUser
'
,
data
)
let
userInfo
=
data
.
userInfo
;
io
.
to
(
data
.
rmIf
).
emit
(
'
sendUser
'
,
userInfo
)
})
...
...
@@ -47,13 +46,13 @@ io.on("connection", (socket) => { // 기본 연결
}).
save
()
console
.
log
(
'
resChat확인
'
,
chat
)
socket
.
broadcast
.
to
(
data
.
roomInfo
).
emit
(
'
sendedMSG
'
,
data
.
msg
);
// sender 제외 특정 방으로
socket
.
broadcast
.
to
(
data
.
roomInfo
).
emit
(
'
sendedMSG
'
,
data
.
sendInfo
);
// sender 제외 특정 방으로
});
});
socket
.
on
(
'
disconnect
'
,
()
=>
{
socket
.
on
(
'
disconnect
'
,
()
=>
{
console
.
log
(
'
disconnected from server id=
'
,
socket
.
id
)
})
})
});
...
...
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