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.
Dependents: NerfUS_cmake_add_library_from_mbed NerfUS NerfUSGameCoordinator
WSRequest.cpp
00001 /** 00002 @file WSRequest.cpp 00003 00004 @brief Allow communication with a server using a specific websocket. 00005 00006 @poject NerfUS, Team P5 00007 */ 00008 #include "WSRequest.hpp" 00009 00010 00011 WSRequest::WSRequest(char *url) : ws(url) 00012 { 00013 eth.init(); //Use DHCP 00014 eth.connect(); 00015 printf("IP Address is %s\n\r", eth.getIPAddress()); 00016 00017 ws.connect(); 00018 } 00019 00020 int WSRequest::send(char *buffer) 00021 { 00022 return ws.send(buffer); 00023 } 00024 00025 bool WSRequest::onMessage(char *buffer) 00026 { 00027 while (!ws.read(buffer)) 00028 { 00029 wait(0.1); 00030 } 00031 return true; 00032 } 00033 00034 WSRequest::~WSRequest() 00035 { 00036 ws.close(); 00037 eth.disconnect(); 00038 }
Generated on Thu Jul 14 2022 23:27:13 by
1.7.2