|
|
|
@ -43,13 +43,22 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
@ -77,7 +86,9 @@ static struct libwebsocket_protocols protocols[] = {
|
|
|
|
|
0,
|
|
|
|
|
#endif
|
|
|
|
|
NULL,
|
|
|
|
|
#if !defined(LWS_LIBRARY_VERSION_NUMBER)
|
|
|
|
|
0
|
|
|
|
|
#endif
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"mqtt",
|
|
|
|
@ -88,7 +99,9 @@ static struct libwebsocket_protocols protocols[] = {
|
|
|
|
|
1,
|
|
|
|
|
#endif
|
|
|
|
|
NULL,
|
|
|
|
|
#if !defined(LWS_LIBRARY_VERSION_NUMBER)
|
|
|
|
|
0
|
|
|
|
|
#endif
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"mqttv3.1",
|
|
|
|
@ -99,10 +112,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
|
|
|
|
@ -117,7 +136,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,
|
|
|
|
@ -140,7 +163,9 @@ static int callback_mqtt(struct libwebsocket_context *context,
|
|
|
|
|
case LWS_CALLBACK_ESTABLISHED:
|
|
|
|
|
mosq = 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{
|
|
|
|
@ -319,7 +344,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,
|
|
|
|
@ -343,7 +372,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;
|
|
|
|
|
}
|
|
|
|
|