alert('got connection');
}
- function connectErrorCallback(jsonConnectErrorAsString) {
+ function connectErrorCallback(error) {
// display the error's message header:
- alert('error call back: \n' + jsonConnectErrorAsString);
+ alert('error call back: \n' + JSON.stringify(error, null, 4));
}
- function subscribeCallback(jsonMessageAsString) {
+ function subscribeCallback(message) {
// called when the client receives a STOMP message from the server
- alert('subscribe message: \n' + jsonMessageAsString);
+ alert('subscribe message: \n' + JSON.stringify(message, null, 4));
}
function disconnectCallback() {
_connectSuccessCallback = connectSuccessCallback;
_connectErrorCallback = connectErrorCallback;
- _messagePort.postMessage(message);
+ doPostMessage(message);
}
function subscribe(clientDestination, subscribeCallback, subscribeHeaders) {
};
_subscribeCallback = subscribeCallback;
- _messagePort.postMessage(message);
+ doPostMessage(message);
}
function unSubscribe() {
command: 'unSubscribe'
};
- _messagePort.postMessage(message);
+ doPostMessage(message);
}
function send(serverDestination, sendHeaders, payload) {
payload: payload
};
- _messagePort.postMessage(message);
+ doPostMessage(message);
}
function disconnect(disconnectCallback) {
};
_disconnectCallback = disconnectCallback;
- _messagePort.postMessage(message);
+ doPostMessage(message);
}
+ function doPostMessage(message) {
+ _messagePort.postMessage(JSON.stringify(message, null, 4));
+ }
function onMessage(event) {
if (event.data.error) {
// Error
} else {
- callBack(event.data);
+ callBack(JSON.parse(event.data));
}
}
// var send {
// }
// var result {
// command:
- // connectError:
+ // error:
// message:
// };
function callBack(data) {
-
switch(data.command) {
case 'connectSuccessCallback':
_connectSuccessCallback();
break;
case 'connectErrorCallback':
- _connectErrorCallback(data.jsonConnectErrorAsString);
+ _connectErrorCallback(data.error);
break;
case 'subscribeCallback':
- _subscribeCallback(data.jsonMessageAsString);
+ _subscribeCallback(data.message);
break;
case 'disconnectCallback':
_disconnectCallback();
<!-- Custom JavaScript -->
<!-- build:js(.) js/app.min.js -->
<!-- inject:js -->
+ <script src="/src/stomp/app/widgets/widgets.module.js"></script>
+ <script src="/src/stomp/app/widgets/auto-height.directive.js"></script>
<script src="/src/stomp/app/shared-stomp/shared-stomp.module.js"></script>
<script src="/src/stomp/app/shared-stomp/shared-worker.service.js"></script>
<script src="/src/stomp/app/shared-stomp/shared-stomp.route.js"></script>
<script src="/src/stomp/app/shared-stomp/shared-stomp.controller.js"></script>
- <script src="/src/stomp/app/widgets/widgets.module.js"></script>
- <script src="/src/stomp/app/widgets/auto-height.directive.js"></script>
<script src="/src/stomp/app/example/example.module.js"></script>
<script src="/src/stomp/app/example/example.route.js"></script>
<script src="/src/stomp/app/example/example.controller.js"></script>
};
function onMessage(event) {
- callCommand(event.data);
+ callCommand(JSON.parse(event.data));
}
function postMessage(message) {
+ var jsonMessageAsString = JSON.stringify(message, null, 4);
messagePorts.forEach(function (messagePort) {
- messagePort.postMessage(message);
+ messagePort.postMessage(jsonMessageAsString);
});
}
function connectErrorCallback(error) {
isConnected = false;
- var jsonConnectErrorAsString = JSON.stringify(error, null, 4);
postMessage({
command: 'connectErrorCallback',
- jsonConnectErrorAsString: jsonConnectErrorAsString
+ error: error
});
}
function subscribeCallback(message) {
- var jsonMessageAsString = JSON.stringify(message, null, 4);
postMessage({
command: 'subscribeCallback',
- jsonMessageAsString: jsonMessageAsString
+ message: message
});
}