Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:c10e8dc4cffd, committed 2016-04-03
- Comitter:
- 13075593
- Date:
- Sun Apr 03 15:44:52 2016 +0000
- Commit message:
- Websocket communication
Changed in this revision
| WebSocket_COMM.cpp | Show annotated file Show diff for this revision Revisions of this file |
| WebSocket_COMM.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r c10e8dc4cffd WebSocket_COMM.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocket_COMM.cpp Sun Apr 03 15:44:52 2016 +0000
@@ -0,0 +1,27 @@
+#include "WebSocket_COMM.h"
+
+WebSocket_Communication::WebSocket_Communication(string _url)
+{
+ url = new char[_url.length()+1];
+ strcpy(url, _url.c_str());
+
+ printf("URL : %s \n",url);
+ webSocket = new Websocket(url);
+}
+
+void WebSocket_Communication::initWebSocket()
+{
+
+ int nbTry = 0;
+ while(!webSocket->connect() && nbTry <3)
+ {
+ printf("Connot connect Websocket, retrying \n");
+ ++nbTry;
+ wait(0.75);
+ }
+}
+
+void WebSocket_Communication::sendDataWebSocket(char *data)
+{
+ webSocket->send(data);
+}
\ No newline at end of file
diff -r 000000000000 -r c10e8dc4cffd WebSocket_COMM.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocket_COMM.h Sun Apr 03 15:44:52 2016 +0000
@@ -0,0 +1,19 @@
+#ifndef WS_COMM_H
+#define WS_COMM_H
+
+#include "Websocket.h"
+#include <string>
+
+class WebSocket_Communication
+{
+ public:
+ WebSocket_Communication(string url);
+ void initWebSocket();
+ void sendDataWebSocket(char *data);
+
+ private :
+ Websocket *webSocket;
+ char *url;
+};
+
+#endif
\ No newline at end of file