Pārlūkot izejas kodu

chore: add socket io and testing connection

Sergey 3 gadi atpakaļ
vecāks
revīzija
88de0fb5aa
2 mainītis faili ar 21 papildinājumiem un 20 dzēšanām
  1. 17 15
      frontend/src/App.js
  2. 4 5
      frontend/src/index.js

+ 17 - 15
frontend/src/App.js

@@ -1,23 +1,25 @@
-import logo from './logo.svg';
 import './App.css';
+import {io} from 'socket.io-client';
+
+
+
+const SERVER_URL = 'http://localhost:5000';
+
+const socket = io.connect(SERVER_URL);
+
+socket.on('connection', () => {
+  console.log('connected')
+});
+
+socket.on('conected', () => {
+  console.log('connected to server')
+});
+
 
 function App() {
   return (
     <div className="App">
-      <header className="App-header">
-        <img src={logo} className="App-logo" alt="logo" />
-        <p>
-          Edit <code>src/App.js</code> and save to reload.
-        </p>
-        <a
-          className="App-link"
-          href="https://reactjs.org"
-          target="_blank"
-          rel="noopener noreferrer"
-        >
-          Learn React
-        </a>
-      </header>
+       <h1>working ...</h1>
     </div>
   );
 }

+ 4 - 5
frontend/src/index.js

@@ -2,7 +2,10 @@ import React from 'react';
 import ReactDOM from 'react-dom';
 import './index.css';
 import App from './App';
-import reportWebVitals from './reportWebVitals';
+
+
+
+
 
 ReactDOM.render(
   <React.StrictMode>
@@ -11,7 +14,3 @@ ReactDOM.render(
   document.getElementById('root')
 );
 
-// If you want to start measuring performance in your app, pass a function
-// to log results (for example: reportWebVitals(console.log))
-// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
-reportWebVitals();