Use plain WebSockets, not SockJS

This commit is contained in:
Charles Gould 2017-10-14 17:01:09 -04:00
parent 0da01c32d2
commit e667be1bab
3 changed files with 14 additions and 3 deletions

View File

@ -32,7 +32,8 @@ public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override @Override
public void registerStompEndpoints(StompEndpointRegistry registry) { public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/stomp").withSockJS(); registry.addEndpoint("/sockjs").withSockJS();
registry.addEndpoint("/stomp");
} }
} }

View File

@ -274,7 +274,12 @@ function afterConnected(stompConnectedFrame) {
function main() { function main() {
client = Stomp.over(new SockJS('/stomp')); let webSocketProtocol = 'ws';
if (location.protocol.startsWith('https')) {
webSocketProtocol = 'wss';
}
client = Stomp.client(`${webSocketProtocol}://${location.host}/stomp`);
client.connect({}, afterConnected, function(errorMessage) { client.connect({}, afterConnected, function(errorMessage) {
addChatAnnouncement(errorMessage); addChatAnnouncement(errorMessage);
addChatAnnouncement('Please reload the page!'); addChatAnnouncement('Please reload the page!');

View File

@ -32,7 +32,12 @@ function start() {
reset(); reset();
repaint(); repaint();
client = Stomp.over(new SockJS('/stomp')); let webSocketProtocol = 'ws';
if (location.protocol.startsWith('https')) {
webSocketProtocol = 'wss';
}
client = Stomp.client(`${webSocketProtocol}://${location.host}/stomp`);
client.connect({}, function(frame) { client.connect({}, function(frame) {
subscribeToPracticeGame(); subscribeToPracticeGame();