Screen.js 1.52 KB
Newer Older
Kim, Chaerin's avatar
Kim, Chaerin committed
1
2
3
4
5
6
7
import React, { useState } from "react";
import io from "socket.io-client";
import { useRef } from "react";
import { useEffect } from "react";
import Video from "./Video";
import { useParams } from "react-router-dom";

Kim, Chaerin's avatar
Kim, Chaerin committed
8
const Screen = () => {
Kim, Chaerin's avatar
Kim, Chaerin committed
9
10
11
12
13
14
15
16
  const [socket, setSocket] = useState(null);
  const [users, setUsers] = useState([]);
  const { roomId, channelId } = useParams();

  const user = "00";
  let localVideoRef = useRef(null);

  useEffect(() => {
17
18
19
20
21
22
23
24
    let newSocket = io("http://localhost:8080", {
      withCredentials: true,
      extraHeaders: {
        "my-custom-header": "abcd"
      }
    });
    console.log(newSocket);

25
26
27
    newSocket.emit("connected", "채린이");
    newSocket.on("toclient", (data) => {
      console.log(data.msg);
Kim, Chaerin's avatar
Kim, Chaerin committed
28
29
    });

30
  }, []);
seoyeon's avatar
seoyeon committed
31

Kim, Chaerin's avatar
Kim, Chaerin committed
32
33
  return (
    <div className="container">
Kim, Chaerin's avatar
Kim, Chaerin committed
34
35
36
37
38
      <div className="mt-3" style={{ backgroundColor: "#FCF4FF" }}>
        <div
          className="m-2 d-flex fw-bold text-center"
          style={{ color: "#4A4251", fontSize: "20px" }}
        >
seoyeon's avatar
seoyeon committed
39
          <img
Kim, Chaerin's avatar
Kim, Chaerin committed
40
            className="rounded-circle me-2"
seoyeon's avatar
seoyeon committed
41
42
43
44
            src="/cherry.jpg"
            width="40px"
            height="40px"
          />
Kim, Chaerin's avatar
Kim, Chaerin committed
45
          {user}님이 화면공유중...
Kim, Chaerin's avatar
Kim, Chaerin committed
46
        </div>
Kim, Chaerin's avatar
Kim, Chaerin committed
47
48
49
50
51
52
53
54
55
56
57
58
        <video
          style={{
            display: "flex",
            justifyContent: "center",
            width: 375,
            height: 260,
            backgroundColor: "black",
          }}
          muted
          ref={localVideoRef}
          autoPlay
        />
Kim, Chaerin's avatar
Kim, Chaerin committed
59
60
      </div>
    </div>
Kim, Chaerin's avatar
Kim, Chaerin committed
61
62
  );
};
Kim, Chaerin's avatar
Kim, Chaerin committed
63

Kim, Chaerin's avatar
Kim, Chaerin committed
64
export default Screen;