Remove redundant method header and fix indent

This commit is contained in:
Martin Becker
2017-07-20 08:21:29 +02:00
parent fcb623ce91
commit d0ab6c4fd1
2 changed files with 47 additions and 48 deletions

View File

@ -1,12 +1,12 @@
/*
* WebSocketClientSockJsAndStomp.ino
*
* 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).
*
* Created on: 18.07.2017
* Author: Martin Becker <mgbckr>, Contact: becker@informatik.uni-wuerzburg.de
*/
WebSocketClientSockJsAndStomp.ino
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).
Created on: 18.07.2017
Author: Martin Becker <mgbckr>, Contact: becker@informatik.uni-wuerzburg.de
*/
// PRE
@ -43,7 +43,7 @@ WebSocketsClient webSocket;
void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
switch(type) {
switch (type) {
case WStype_DISCONNECTED:
USE_SERIAL.printf("[WSc] Disconnected!\n");
break;
@ -52,8 +52,8 @@ void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
USE_SERIAL.printf("[WSc] Connected to url: %s\n", payload);
}
break;
case WStype_TEXT: {
case WStype_TEXT:
{
// #####################
// handle STOMP protocol
// #####################
@ -107,7 +107,7 @@ void setup() {
// USE_SERIAL.begin(921600);
USE_SERIAL.begin(115200);
// USE_SERIAL.setDebugOutput(true);
// USE_SERIAL.setDebugOutput(true);
USE_SERIAL.println();
@ -130,15 +130,15 @@ void setup() {
// create socket url according to SockJS protocol (cf. http://sockjs.github.io/sockjs-protocol/sockjs-protocol-0.3.3.html#section-36)
// #####################
String socketUrl = ws_baseurl;
socketUrl += random(0,999);
socketUrl += random(0, 999);
socketUrl += "/";
socketUrl += random(0,999999); // should be a random string, but this works (see )
socketUrl += random(0, 999999); // should be a random string, but this works (see )
socketUrl += "/websocket";
// connect to websocket
webSocket.begin(ws_host, ws_port, socketUrl);
webSocket.setExtraHeaders(); // remove "Origin: file://" header because it breaks the connection with Spring's default websocket config
// webSocket.setExtraHeaders("foo: I am so funny\r\nbar: not"); // some headers, in case you feel funny
// webSocket.setExtraHeaders("foo: I am so funny\r\nbar: not"); // some headers, in case you feel funny
webSocket.onEvent(webSocketEvent);
}

View File

@ -82,7 +82,6 @@ class WebSocketsClient: private WebSockets {
void setAuthorization(const char * auth);
void setExtraHeaders(const char * extraHeaders = NULL);
void setExtraHeaders(char * extraHeaders);
protected:
String _host;