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

병합에러수정

parent e9b2bd86
......@@ -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>
......
......@@ -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)
......
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)
})
......@@ -46,14 +45,14 @@ io.on("connection", (socket) => { // 기본 연결
message: data.sendInfo.msg
}).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', () => {
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