Add support for libwebsockets 1.6.

pull/145/head
Roger A. Light 10 years ago
parent c5a376489e
commit 7aa653c42f

@ -1,6 +1,9 @@
1.4.6 -
================
Broker:
- Add support for libwebsockets 1.6.
Client library:
- Fix _mosquitto_socketpair() on Windows, reducing the chance of delays when
publishing. Closes #483979.
@ -9,6 +12,7 @@ Clients:
- Fix "mosquitto_pub -l" stripping the final character on a line. Closes
#483981.
1.4.5 - 20151108
================

@ -207,9 +207,13 @@ struct mosquitto {
int sub_count;
int pollfd_index;
# ifdef WITH_WEBSOCKETS
# if defined(LWS_LIBRARY_VERSION_NUMBER)
struct lws *wsi;
# else
struct libwebsocket_context *ws_context;
struct libwebsocket *wsi;
# endif
# endif
#else
# ifdef WITH_SOCKS
char *socks5_host;

@ -68,6 +68,7 @@ Contributors:
extern unsigned long g_pub_msgs_sent;
# endif
# ifdef WITH_WEBSOCKETS
# include <lws_config.h>
# include <libwebsockets.h>
# endif
#else

@ -37,6 +37,7 @@ Contributors:
#include <time.h>
#ifdef WITH_WEBSOCKETS
# include <lws_config.h>
# include <libwebsockets.h>
#endif

@ -43,6 +43,7 @@ Contributors:
#include <tcpd.h>
#endif
#ifdef WITH_WEBSOCKETS
# include <lws_config.h>
# include <libwebsockets.h>
#endif

@ -20,6 +20,26 @@ Contributors:
#include <config.h>
#include <stdio.h>
#ifdef WITH_WEBSOCKETS
# include <lws_config.h>
# include <libwebsockets.h>
# if defined(LWS_LIBRARY_VERSION_NUMBER)
# define libwebsocket_callback_on_writable(A, B) lws_callback_on_writable((B))
# define libwebsocket_service(A, B) lws_service((A), (B))
# define libwebsocket_create_context(A) lws_create_context((A))
# define libwebsocket_context_destroy(A) lws_context_destroy((A))
# define libwebsocket_write(A, B, C, D) lws_write((A), (B), (C), (D))
# define libwebsocket_get_socket_fd(A) lws_get_socket_fd((A))
# define libwebsockets_return_http_status(A, B, C, D) lws_return_http_status((B), (C), (D))
# define libwebsocket_context lws_context
# define libwebsocket_protocols lws_protocols
# define libwebsocket_callback_reasons lws_callback_reasons
# define libwebsocket lws
# endif
#endif
#include <mosquitto_internal.h>
#include <mosquitto_plugin.h>
#include <mosquitto.h>
@ -482,7 +502,11 @@ void service_run(void);
* Websockets related functions
* ============================================================ */
#ifdef WITH_WEBSOCKETS
# if defined(LWS_LIBRARY_VERSION_NUMBER)
struct lws_context *mosq_websockets_init(struct _mqtt3_listener *listener, int log_level);
# else
struct libwebsocket_context *mosq_websockets_init(struct _mqtt3_listener *listener, int log_level);
# endif
#endif
void do_disconnect(struct mosquitto_db *db, struct mosquitto *context);

@ -32,7 +32,8 @@ Contributors:
#endif
#ifdef WITH_WEBSOCKETS
#include <libwebsockets.h>
# include <lws_config.h>
# include <libwebsockets.h>
#endif
#ifdef WITH_SYS_TREE

@ -29,6 +29,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifdef WITH_WEBSOCKETS
#include <lws_config.h>
#include <libwebsockets.h>
#include "mosquitto_internal.h"
#include "mosquitto_broker.h"
@ -49,13 +50,22 @@ extern unsigned long g_pub_msgs_sent;
#endif
extern struct mosquitto_db int_db;
#if defined(LWS_LIBRARY_VERSION_NUMBER)
static int callback_mqtt(
#else
static int callback_mqtt(struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
void *user,
void *in,
size_t len);
#if defined(LWS_LIBRARY_VERSION_NUMBER)
static int callback_http(
#else
static int callback_http(struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
void *user,
@ -95,7 +105,9 @@ static struct libwebsocket_protocols protocols[] = {
0,
#endif
NULL,
#if !defined(LWS_LIBRARY_VERSION_NUMBER)
0
#endif
},
{
"mqtt",
@ -106,7 +118,9 @@ static struct libwebsocket_protocols protocols[] = {
1,
#endif
NULL,
#if !defined(LWS_LIBRARY_VERSION_NUMBER)
0
#endif
},
{
"mqttv3.1",
@ -117,10 +131,16 @@ static struct libwebsocket_protocols protocols[] = {
1,
#endif
NULL,
#if !defined(LWS_LIBRARY_VERSION_NUMBER)
0
#endif
},
#ifdef LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD
# if defined(LWS_LIBRARY_VERSION_NUMBER)
{ NULL, NULL, 0, 0, 0, NULL}
# else
{ NULL, NULL, 0, 0, 0, NULL, 0}
# endif
#else
{ NULL, NULL, 0, 0, NULL, 0}
#endif
@ -135,7 +155,11 @@ static void easy_address(int sock, struct mosquitto *mosq)
}
}
#if defined(LWS_LIBRARY_VERSION_NUMBER)
static int callback_mqtt(
#else
static int callback_mqtt(struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
void *user,
@ -158,7 +182,9 @@ static int callback_mqtt(struct libwebsocket_context *context,
case LWS_CALLBACK_ESTABLISHED:
mosq = mqtt3_context_init(db, WEBSOCKET_CLIENT);
if(mosq){
#if !defined(LWS_LIBRARY_VERSION_NUMBER)
mosq->ws_context = context;
#endif
mosq->wsi = wsi;
u->mosq = mosq;
}else{
@ -342,7 +368,11 @@ static int callback_mqtt(struct libwebsocket_context *context,
}
#if defined(LWS_LIBRARY_VERSION_NUMBER)
static int callback_http(
#else
static int callback_http(struct libwebsocket_context *context,
#endif
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
void *user,
@ -368,7 +398,11 @@ static int callback_http(struct libwebsocket_context *context,
return -1;
}
#if defined(LWS_LIBRARY_VERSION_NUMBER)
hack = (struct libws_mqtt_hack *)lws_context_user(lws_get_context(wsi));
#else
hack = (struct libws_mqtt_hack *)libwebsocket_context_user(context);
#endif
if(!hack){
return -1;
}

Loading…
Cancel
Save