This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const http = require("http"); | |
const socketIo = require("socket.io"); | |
const port = process.env.PORT || 4001; | |
const index = require("./routes/index"); | |
const moment = require("moment"); | |
const app = express(); | |
app.use(index); | |
const server = http.createServer(app); | |
const io = socketIo(server); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return ( | |
<div> | |
<h3 className="d-flex justify-content-center"> Connected users : {user.usersList?.length} </h3> | |
<table className="table"> | |
<thead> | |
<tr> | |
<th> User name </th> | |
<th> Connection Date </th> | |
</tr> | |
</thead> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App() { | |
const [user, setUser] = useState({ | |
usersList: null | |
}); | |
const [msg, setMsg] = useState(""); | |
const [recMsg, setRecMsg] = useState({ | |
listMsg: [] | |
}); | |
const [loggedUser, setLoggedUser] = useState(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App() { | |
const [user, setUser] = useState({ | |
usersList: null | |
}); | |
const [msg, setMsg] = useState(""); | |
const [recMsg, setRecMsg] = useState({ | |
listMsg: [] | |
}); | |
const [loggedUser, setLoggedUser] = useState(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from "react"; | |
import socketIOClient from "socket.io-client"; | |
import userGen from "username-generator" | |
import { Button, Input } from 'reactstrap'; | |
const ENDPOINT = "http://127.0.0.1:4001"; | |
const socket = socketIOClient(ENDPOINT); |