-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from SoopSASM/feature/add-socket
Add simple socket for react and node-red server communication
- Loading branch information
Showing
10 changed files
with
545 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
dashboard/dist |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
import React from "react"; | ||
import React, { useEffect } from "react"; | ||
|
||
export default function App() { | ||
return <div>Hello Dashboard App</div>; | ||
} | ||
import { initlaizeSocket, disconnectSocket } from "../utils/socket"; | ||
|
||
const App = () => { | ||
useEffect(() => { | ||
initlaizeSocket(); | ||
|
||
return () => { | ||
disconnectSocket(); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<div>Hello Dashboard</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { io } from "socket.io-client"; | ||
|
||
let socket; | ||
|
||
export const initlaizeSocket = () => { | ||
socket = io(); | ||
|
||
socket.on("connect", () => { | ||
console.info(`socket connected : ${socket.id}`); | ||
}); | ||
|
||
socket.on("initial-value", (state) => { | ||
console.log(state); | ||
}); | ||
|
||
socket.on("update-value", (state) => { | ||
console.log(state); | ||
}); | ||
}; | ||
|
||
export const disconnectSocket = () => { | ||
socket.disconnect(); | ||
}; |
Oops, something went wrong.