fork of WebSocketClient with some fixes
Fork of WebSocketClient by
Diff: Websocket.h
- Revision:
- 9:efa2c147bee1
- Parent:
- 8:ccedee13be8d
diff -r ccedee13be8d -r efa2c147bee1 Websocket.h --- a/Websocket.h Wed Oct 23 09:58:39 2013 +0000 +++ b/Websocket.h Thu Mar 16 21:10:27 2017 +0000 @@ -1,25 +1,38 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/** +* @author Samuel Mokrani +* +* @section LICENSE +* +* Copyright (c) 2011 mbed +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +* +* @section DESCRIPTION +* Simple websocket client +* +*/ + #ifndef WEBSOCKET_H #define WEBSOCKET_H #include "mbed.h" -#include "TCPSocketConnection.h" - /** Websocket client Class. * * Example (ethernet network): @@ -58,7 +71,7 @@ * * @param url The Websocket url in the form "ws://ip_domain[:port]/path" (by default: port = 80) */ - Websocket(char * url); + Websocket(char * url, NetworkInterface * iface); /** * Connect to the websocket url @@ -86,13 +99,6 @@ bool read(char * message); /** - * To see if there is a websocket connection active - * - * @return true if there is a connection active - */ - bool is_connected(); - - /** * Close the websocket connection * * @return true if the connection has been closed, false otherwise @@ -107,7 +113,6 @@ char* getPath(); private: - void fillFields(char * url); int parseURL(const char* url, char* scheme, size_t maxSchemeLen, char* host, size_t maxHostLen, uint16_t* port, char* path, size_t maxPathLen); //Parse URL int sendOpcode(uint8_t opcode, char * msg); @@ -120,7 +125,7 @@ char host[32]; char path[64]; - TCPSocketConnection socket; + TCPSocket socket; int read(char * buf, int len, int min_len = -1); int write(char * buf, int len);