diff --git a/examples/WebSocketClientStomp/WebSocketClientStomp.ino b/examples/WebSocketClientStomp/WebSocketClientStomp.ino index a0eb011..34d0e27 100644 --- a/examples/WebSocketClientStomp/WebSocketClientStomp.ino +++ b/examples/WebSocketClientStomp/WebSocketClientStomp.ino @@ -3,6 +3,8 @@ Example for connecting and maintining a connection with a STOMP websocket connection. In this example, we connect to a Spring application (see https://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html). + In particular, we use the default STOMP WebSocket example by Spring: https://github.com/spring-guides/gs-messaging-stomp-websocket + That is, we connect to the Spring server, send a "hello" and get back a "greeting". Created on: 25.09.2017 Author: Martin Becker , Contact: becker@informatik.uni-wuerzburg.de @@ -24,15 +26,16 @@ // SETTINGS -const char* wlan_ssid = "yourssid"; -const char* wlan_password = "somepassword"; +const char* wlan_ssid = ""; +const char* wlan_password = ""; -const char* ws_host = "the.host.net"; -const int ws_port = 80; +const char* ws_host = ""; +const int ws_port = 8080; // the Spring webapp runs on port 8080 by default (instead of 80 for standard HTTP) // URL for STOMP endpoint. -// For the default config of Spring's STOMP support, the default URL is "/socketentry/websocket". -const char* stompUrl = "/socketentry/websocket"; // don't forget the leading "/" !!! +// For the default config of Spring's STOMP support, the preset URL is "/socketentry/websocket". +// Here, we use the URL defined by the Spring example mentioned in the preamble. +const char* stompUrl = "/gs-guide-websocket/websocket"; // don't forget the leading "/" !!! // VARIABLES @@ -82,13 +85,13 @@ void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) { // subscribe to some channels - String msg = "SUBSCRIBE\nid:sub-0\ndestination:/user/queue/messages\n\n"; + String msg = "SUBSCRIBE\nid:sub-0\ndestination:/topic/greetings\n\n"; sendMessage(msg); delay(1000); // and send a message - msg = "SEND\ndestination:/app/message\n\n{\"user\":\"esp\",\"message\":\"Hello!\"}"; + msg = "SEND\ndestination:/app/hello\n\n{\"name\":\"blubb\"}"; sendMessage(msg); delay(1000); diff --git a/examples/WebSocketClientStompOverSockJs/WebSocketClientStompOverSockJs.ino b/examples/WebSocketClientStompOverSockJs/WebSocketClientStompOverSockJs.ino index cb0c45b..e7af840 100644 --- a/examples/WebSocketClientStompOverSockJs/WebSocketClientStompOverSockJs.ino +++ b/examples/WebSocketClientStompOverSockJs/WebSocketClientStompOverSockJs.ino @@ -3,6 +3,8 @@ Example for connecting and maintining a connection with a SockJS+STOMP websocket connection. In this example, we connect to a Spring application (see https://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html). + In particular, we use the default STOMP WebSocket example by Spring: https://github.com/spring-guides/gs-messaging-stomp-websocket + That is, we connect to the Spring server, send a "hello" and get back a "greeting". Created on: 18.07.2017 Author: Martin Becker , Contact: becker@informatik.uni-wuerzburg.de @@ -24,17 +26,20 @@ // SETTINGS -const char* wlan_ssid = "yourssid"; -const char* wlan_password = "somepassword"; +const char* wlan_ssid = ""; +const char* wlan_password = ""; -const char* ws_host = "the.host.net"; -const int ws_port = 80; +const char* ws_host = ""; +const int ws_port = 8080; // the Spring webapp runs on port 8080 by default (instead of 80 for standard HTTP) // base URL for SockJS (websocket) connection -// The complete URL will look something like this(cf. http://sockjs.github.io/sockjs-protocol/sockjs-protocol-0.3.3.html#section-36): -// ws://://<3digits>//websocket -// For the default config of Spring's SockJS/STOMP support, the default base URL is "/socketentry/". -const char* ws_baseurl = "/socketentry/"; // don't forget leading and trailing "/" !!! +// The complete URL will look something like this (cf. http://sockjs.github.io/sockjs-protocol/sockjs-protocol-0.3.3.html#section-36): +// +// ws://://<3digits>//websocket +// +// For the default config of Spring's SockJS/STOMP support, the preset base URL is "/socketentry/". +// Here, we use the URL defined by the Spring example mentioned in the preamble. +const char* ws_baseurl = "/gs-guide-websocket/"; // don't forget leading and trailing "/" !!! // VARIABLES @@ -79,13 +84,13 @@ void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) { // subscribe to some channels - char *msg = "[\"SUBSCRIBE\\nid:sub-0\\ndestination:/user/queue/messages\\n\\n\\u0000\"]"; + char *msg = "[\"SUBSCRIBE\\nid:sub-0\\ndestination:/topic/greetings\\n\\n\\u0000\"]"; webSocket.sendTXT(msg); delay(1000); // and send a message - msg = "[\"SEND\\ndestination:/app/message\\n\\n{\\\"user\\\":\\\"esp\\\",\\\"message\\\":\\\"Hello!\\\"}\\u0000\"]"; + msg = "[\"SEND\\ndestination:/app/hello\\n\\n{\\\"name\\\":\\\"blubb\\\"}\\u0000\"]"; webSocket.sendTXT(msg); delay(1000); }