Commit 54789675 authored by Choi Ga Young's avatar Choi Ga Young
Browse files

병합에러수정

parent e9b2bd86
...@@ -40,7 +40,6 @@ function Chat(props) { ...@@ -40,7 +40,6 @@ function Chat(props) {
props.setSingleImg(user.profileimg) props.setSingleImg(user.profileimg)
props.setSingleUser(user.nickname) props.setSingleUser(user.nickname)
// props.setSingleUser(sessionStorage.getItem('name'))
props.setSingleChat(inner) props.setSingleChat(inner)
props.sendMsg(e) props.sendMsg(e)
...@@ -48,7 +47,7 @@ function Chat(props) { ...@@ -48,7 +47,7 @@ function Chat(props) {
setDisabled(true) setDisabled(true)
} }
function handleClick(e) { function handleClick() {
setChat([]) setChat([])
props.handleChatc() props.handleChatc()
} }
...@@ -108,8 +107,7 @@ function Chat(props) { ...@@ -108,8 +107,7 @@ function Chat(props) {
}) })
} }
<Button variant="light" onClick={props.handleChatc} >{`<`}</Button> <Button variant="light" onClick={handleClick} >{`<`}</Button>
</Container > </Container >
<Form onSubmit={sendMsgCH} fluid> <Form onSubmit={sendMsgCH} fluid>
......
...@@ -51,6 +51,11 @@ function Home() { ...@@ -51,6 +51,11 @@ function Home() {
setNewUser(data) setNewUser(data)
}) })
const sendMsg = (e) => {
e.preventDefault()
}
useEffect(() => { useEffect(() => {
if (!(singleChat == '')) { if (!(singleChat == '')) {
socket.emit("chat", { socket.emit("chat", {
...@@ -67,7 +72,7 @@ function Home() { ...@@ -67,7 +72,7 @@ function Home() {
useEffect(() => { useEffect(() => {
socket.on("sendedMSG", (msg) => { socket.on("sendedMSG", (sendInfo) => {
setRecievedImg(sendInfo.img) setRecievedImg(sendInfo.img)
setRecievedUser(sendInfo.sender) setRecievedUser(sendInfo.sender)
setRecievedMsg(sendInfo.msg) setRecievedMsg(sendInfo.msg)
......
import express, { response } from 'express' import express from 'express'
import connectDb from './utils/connectDb.js' import connectDb from './utils/connectDb.js'
import userRouter from './routes/user.routes.js' import userRouter from './routes/user.routes.js'
import authRouter from './routes/auth.routes.js' import authRouter from './routes/auth.routes.js'
...@@ -9,7 +9,6 @@ import http from "http"; ...@@ -9,7 +9,6 @@ import http from "http";
import { Server } from 'socket.io'; import { Server } from 'socket.io';
import cors from "cors" import cors from "cors"
import Room from './models/Room.js' import Room from './models/Room.js'
import { nextTick } from 'process'
import Chat from "./models/Chat.js" import Chat from "./models/Chat.js"
connectDb() connectDb()
...@@ -29,8 +28,8 @@ io.on("connection", (socket) => { // 기본 연결 ...@@ -29,8 +28,8 @@ io.on("connection", (socket) => { // 기본 연결
socket.join(roomInfo); //클라이언트에서 data에 적힌 room으로 참여시킴 socket.join(roomInfo); //클라이언트에서 data에 적힌 room으로 참여시킴
}); });
socket.on('newUser', (data)=>{ socket.on('newUser', (data) => {
console.log('newUser',data) console.log('newUser', data)
let userInfo = data.userInfo; let userInfo = data.userInfo;
io.to(data.rmIf).emit('sendUser', userInfo) io.to(data.rmIf).emit('sendUser', userInfo)
}) })
...@@ -46,14 +45,14 @@ io.on("connection", (socket) => { // 기본 연결 ...@@ -46,14 +45,14 @@ io.on("connection", (socket) => { // 기본 연결
message: data.sendInfo.msg message: data.sendInfo.msg
}).save() }).save()
console.log('resChat확인', chat) 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', () => { });
console.log('disconnected from server id=', socket.id)
}) socket.on('disconnect', () => {
console.log('disconnected from server id=', socket.id)
})
}); });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment