2016-10-01 21:49:15 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
import GridControl from './grid/grid-control';
|
|
|
|
|
|
|
|
|
|
class MineSeeker extends React.Component {
|
2016-10-18 15:58:53 +02:00
|
|
|
/** after rendering */
|
|
|
|
|
componentDidMount() {
|
2016-10-21 17:55:19 +02:00
|
|
|
var websocket = WS.connect("ws://mine.dev:6450");
|
2016-10-18 15:58:53 +02:00
|
|
|
|
|
|
|
|
/** session is an Autobahn JS WAMP session. */
|
|
|
|
|
websocket.on("socket/connect", function (session) {
|
|
|
|
|
console.info("Successfully Connected!");
|
|
|
|
|
|
|
|
|
|
session.subscribe("acme/channel", function(uri, payload){
|
|
|
|
|
console.log("Received message", payload.msg);
|
|
|
|
|
});
|
|
|
|
|
|
2016-10-21 17:55:19 +02:00
|
|
|
session.call("sample/sum", [2, 5]).then(
|
|
|
|
|
function (result) {
|
|
|
|
|
console.log("RPC Valid!", result);
|
|
|
|
|
},
|
|
|
|
|
function (error, desc) {
|
|
|
|
|
console.log("RPC Error", error, desc);
|
|
|
|
|
}
|
|
|
|
|
);
|
2016-10-18 15:58:53 +02:00
|
|
|
|
|
|
|
|
session.publish("acme/channel", {msg: "This is a message!"});
|
|
|
|
|
|
|
|
|
|
// session.publish("acme/channel", {msg: "I'm leaving, I will not see the next message"});
|
|
|
|
|
//
|
|
|
|
|
// session.unsubscribe("acme/channel");
|
|
|
|
|
//
|
|
|
|
|
// session.publish("acme/channel", {msg: "I won't see this"});
|
|
|
|
|
//
|
|
|
|
|
// session.subscribe("acme/channel", function (uri, payload) {
|
|
|
|
|
// console.log("Received message", payload.msg);
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// session.publish("acme/channel", {msg: "I'm back!"});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/** error provides us with some insight into the disconnection: error.reason and error.code */
|
|
|
|
|
websocket.on("socket/disconnect", function (error) {
|
|
|
|
|
console.info("Disconnected for " + error.reason + " with code " + error.code);
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-10-01 21:49:15 +02:00
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
return (
|
2016-10-19 13:27:55 +02:00
|
|
|
<div></div>
|
|
|
|
|
// <GridControl ref="gridControl"/>
|
2016-10-01 21:49:15 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default MineSeeker;
|