ADD: added APP-6 Symbols to the Map
This commit is contained in:
51
webapp/src/websocket.js
Normal file
51
webapp/src/websocket.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import React from 'react';
|
||||
import useWebSocket from 'react-use-websocket';
|
||||
|
||||
class Websocketclient extends React.Component
|
||||
{
|
||||
ws = new WebSocket("ws://127.0.0.1:8008");
|
||||
constructor(props) {
|
||||
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
val: null,
|
||||
};
|
||||
}
|
||||
|
||||
sendMessage(msg )
|
||||
{
|
||||
this.ws.send(msg);
|
||||
|
||||
}
|
||||
componentDidMount() {
|
||||
this.ws.onopen = () => {
|
||||
console.log("opened");
|
||||
this.ws.send("test"); // message to send on Websocket ready
|
||||
};
|
||||
|
||||
this.ws.onclose = () => {
|
||||
console.log("closed");
|
||||
};
|
||||
|
||||
this.ws.onmessage = (event) => {
|
||||
console.log("got message", event.data);
|
||||
this.setState({ val: event.data });
|
||||
};
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
}
|
||||
|
||||
close()
|
||||
{
|
||||
console.log("closing websocket...");
|
||||
this.ws.close();
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div>Value: {this.state.val}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
export default Websocketclient;
|
||||
Reference in New Issue
Block a user