ADD: current dev version simple entity control input

This commit is contained in:
Henry Winkel
2023-09-28 17:00:42 +02:00
parent 7a2a472e5a
commit a34ea5ab04
11 changed files with 236 additions and 80 deletions

View File

@@ -12,13 +12,18 @@ import {w3cwebsocket as W3CWebSocket} from "websocket"
const config = {
// apiUrl: process.env.REACT_APP_WEBAPP_WS_URL,
apiUrl: "10.110.242.105",
apiProt: 9999
apiUrl: "192.168.3.13",
apiProt: 30747
}
const client = new WebSocket("ws://10.110.242.105:9999/");
// const config = {
// // apiUrl: process.env.REACT_APP_WEBAPP_WS_URL,
// apiUrl: "localhost",
// apiProt: 9999
// }
// const client = new W3CWebSocket("ws://"+config.apiUrl+":"+config.apiProt+"/");
const client = new W3CWebSocket("ws://"+config.apiUrl+":"+config.apiProt+"/");
class App extends Component {
@@ -38,8 +43,9 @@ class App extends Component {
const dataFromServer = JSON.parse(message.data);
console.log('reply: ', dataFromServer);
if(dataFromServer.Type === "COP")
if(dataFromServer.Data === "COP")
{
this.setState((state) => ({
Entities: dataFromServer.Entities
})
@@ -49,26 +55,26 @@ class App extends Component {
}
// connect((msg) => {
// console.log("New Message")
// connect((msg) => {
// console.log("New Message")
// var jsonMSG;
// try {
// jsonMSG = JSON.parse(msg.data);
// } catch (error) {
// console.log(error);
// }
// var jsonMSG;
// try {
// jsonMSG = JSON.parse(msg.data);
// } catch (error) {
// console.log(error);
// }
// if(jsonMSG["Type"] == "COP"){
// console.log(msg.data)
// var Entities = Array.from(jsonMSG["Entities"])
// if(Array.isArray(Entities))
// {
// this.setState({
// Entities:Entities
// });
// }
// }
// if(jsonMSG["Type"] == "COP"){
// console.log(msg.data)
// var Entities = Array.from(jsonMSG["Entities"])
// if(Array.isArray(Entities))
// {
// this.setState({
// Entities:Entities
// });
// }
// }
@@ -107,15 +113,10 @@ class App extends Component {
<div className="Content">
<Controls Entities= {this.state.Entities} updateEntities = {this.updateEntities} EntityOnFocus = {this.state.EntityOnFocus} />
{/* <ChatHistory History={this.state.History} /> */}
{/* <div>
{name}
</div> */}
<OpenSeaMap Entities= {this.state.Entities} updateEntities = {this.updateEntities} setEntityOnFocus = {this.setEntityOnFocus.bind(this)}/>
</div>
{/* <button onClick={this.send}>Hit</button> */}
</div>
);