mirror of
https://github.com/lammertb/libhttp.git
synced 2025-07-31 08:24:23 +03:00
Fixed the copyright, changed mg_client_websocket_connect to mg_websocket_client_connect
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2013 No Face Press, LLC
|
# Copyright (c) 2014 Jordan Shelley
|
||||||
|
# https://github.com/jshelley
|
||||||
# License http://opensource.org/licenses/mit-license.php MIT License
|
# License http://opensource.org/licenses/mit-license.php MIT License
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013 No Face Press, LLC
|
* Copyright (c) 2014 Jordan Shelley
|
||||||
|
* https://github.com/jshelley
|
||||||
* License http://opensource.org/licenses/mit-license.php MIT License
|
* License http://opensource.org/licenses/mit-license.php MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Simple example program on how to use Embedded C interface.
|
// Simple example program on how to use websocket client embedded C interface.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#else
|
#else
|
||||||
@ -38,7 +39,7 @@ int main(int argc, char *argv[])
|
|||||||
ctx = mg_start(&callbacks, 0, options);
|
ctx = mg_start(&callbacks, 0, options);
|
||||||
|
|
||||||
char ebuf[100];
|
char ebuf[100];
|
||||||
struct mg_connection* newconn = mg_client_websocket_connect("echo.websocket.org", 443, 1,
|
struct mg_connection* newconn = mg_websocket_client_connect("echo.websocket.org", 443, 1,
|
||||||
ebuf, sizeof(ebuf),
|
ebuf, sizeof(ebuf),
|
||||||
"/", "http://websocket.org",websocket_data_handler);
|
"/", "http://websocket.org",websocket_data_handler);
|
||||||
|
|
||||||
|
@ -589,7 +589,7 @@ CIVETWEB_API int mg_strncasecmp(const char *s1, const char *s2, size_t len);
|
|||||||
|
|
||||||
typedef int (*websocket_data_func)(struct mg_connection *, int bits,
|
typedef int (*websocket_data_func)(struct mg_connection *, int bits,
|
||||||
char *data, size_t data_len);
|
char *data, size_t data_len);
|
||||||
CIVETWEB_API struct mg_connection *mg_client_websocket_connect(const char *host, int port, int use_ssl,
|
CIVETWEB_API struct mg_connection *mg_websocket_client_connect(const char *host, int port, int use_ssl,
|
||||||
char *error_buffer, size_t error_buffer_size,
|
char *error_buffer, size_t error_buffer_size,
|
||||||
const char *path, const char *origin, websocket_data_func data_func);
|
const char *path, const char *origin, websocket_data_func data_func);
|
||||||
|
|
||||||
|
@ -6596,7 +6596,7 @@ static void* websocket_client_thread(void *data)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mg_connection *mg_client_websocket_connect(const char *host, int port, int use_ssl,
|
struct mg_connection *mg_websocket_client_connect(const char *host, int port, int use_ssl,
|
||||||
char *error_buffer, size_t error_buffer_size,
|
char *error_buffer, size_t error_buffer_size,
|
||||||
const char *path, const char *origin, websocket_data_func data_func)
|
const char *path, const char *origin, websocket_data_func data_func)
|
||||||
{
|
{
|
||||||
|
@ -530,7 +530,7 @@ static int websocket_data_handler(struct mg_connection *conn, int flags, char *d
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_mg_client_websocket_connect(int use_ssl) {
|
static void test_mg_websocket_client_connect(int use_ssl) {
|
||||||
struct mg_connection* conn;
|
struct mg_connection* conn;
|
||||||
char ebuf[100];
|
char ebuf[100];
|
||||||
int port = HTTP_PORT;
|
int port = HTTP_PORT;
|
||||||
@ -558,19 +558,19 @@ static void test_mg_client_websocket_connect(int use_ssl) {
|
|||||||
if(use_ssl) { port = 443; }
|
if(use_ssl) { port = 443; }
|
||||||
|
|
||||||
//Not a websocket server path
|
//Not a websocket server path
|
||||||
conn = mg_client_websocket_connect("websocket.org", port, use_ssl,
|
conn = mg_websocket_client_connect("websocket.org", port, use_ssl,
|
||||||
ebuf, sizeof(ebuf),
|
ebuf, sizeof(ebuf),
|
||||||
"/", "http://websocket.org",websocket_data_handler);
|
"/", "http://websocket.org",websocket_data_handler);
|
||||||
ASSERT(conn == NULL);
|
ASSERT(conn == NULL);
|
||||||
|
|
||||||
//Invalid port test
|
//Invalid port test
|
||||||
conn = mg_client_websocket_connect("echo.websocket.org", 0, use_ssl,
|
conn = mg_websocket_client_connect("echo.websocket.org", 0, use_ssl,
|
||||||
ebuf, sizeof(ebuf),
|
ebuf, sizeof(ebuf),
|
||||||
"/", "http://websocket.org",websocket_data_handler);
|
"/", "http://websocket.org",websocket_data_handler);
|
||||||
ASSERT(conn == NULL);
|
ASSERT(conn == NULL);
|
||||||
|
|
||||||
//Should succeed, echo.websocket.org echos the data back
|
//Should succeed, echo.websocket.org echos the data back
|
||||||
conn = mg_client_websocket_connect("echo.websocket.org", port, use_ssl,
|
conn = mg_websocket_client_connect("echo.websocket.org", port, use_ssl,
|
||||||
ebuf, sizeof(ebuf),
|
ebuf, sizeof(ebuf),
|
||||||
"/", "http://websocket.org",websocket_data_handler);
|
"/", "http://websocket.org",websocket_data_handler);
|
||||||
ASSERT(conn != NULL);
|
ASSERT(conn != NULL);
|
||||||
@ -1068,9 +1068,9 @@ int __cdecl main(void) {
|
|||||||
test_mg_download(1);
|
test_mg_download(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
test_mg_client_websocket_connect(0);
|
test_mg_websocket_client_connect(0);
|
||||||
#ifndef NO_SSL
|
#ifndef NO_SSL
|
||||||
test_mg_client_websocket_connect(1);
|
test_mg_websocket_client_connect(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
test_mg_upload();
|
test_mg_upload();
|
||||||
|
Reference in New Issue
Block a user