Change libwebsockets APIs
[profile/ivi/automotive-message-broker.git] / plugins / websocket / websocketsource.cpp
index a52cdb1..d4e3146 100644 (file)
@@ -37,7 +37,7 @@
 #include "superptr.hpp"
 
 #define __SMALLFILE__ std::string(__FILE__).substr(std::string(__FILE__).rfind("/")+1)
-libwebsocket_context *context = NULL;
+lws_context *context = NULL;
 WebSocketSource *source;
 AbstractRoutingEngine *m_re;
 
@@ -148,20 +148,24 @@ private:
 
 UniquePropertyCache properties;
 
-static int callback_http_only(libwebsocket_context *context,struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason,void *user, void *in, size_t len);
-static struct libwebsocket_protocols protocols[] = {
-{
-       "http-only",
-       callback_http_only,
-       0,
-       128,
-},
-{  /* end of list */
-       NULL,
-       NULL,
-       0,
-       0
-}
+static int callback_http_only(struct lws *wsi,enum lws_callback_reasons reason,void *user, void *in, size_t len);
+static struct lws_protocols protocols[] = {
+       {
+               "http-only",
+               callback_http_only,
+               0,
+               128,
+               0,
+               NULL,
+       },
+       {
+               NULL,
+               NULL,
+               0,
+               0,
+               0,
+               NULL,
+       }
 };
 
 //Called when a client connects, subscribes, or unsubscribes.
@@ -232,7 +236,7 @@ void WebSocketSource::setConfiguration(map<string, string> config)
                sslval = 2;
        }
 
-       clientsocket = libwebsocket_client_connect(context, ip.c_str(), port, sslval,"/", "localhost", "websocket", protocols[0].name, -1);
+       clientsocket = lws_client_connect(context, ip.c_str(), port, sslval,"/", "localhost", "websocket", protocols[0].name, -1);
 }
 
 PropertyInfo WebSocketSource::getPropertyInfo(const VehicleProperty::Property &property)
@@ -260,7 +264,7 @@ bool gioPollingFunc(GIOChannel *source, GIOCondition condition, gpointer data)
        pollstruct.fd = newfd;
        pollstruct.events = condition;
        pollstruct.revents = condition;
-       libwebsocket_service_fd(context,&pollstruct);
+       lws_service_fd(context,&pollstruct);
        if (condition & G_IO_HUP)
        {
                //Hang up. Returning false closes out the GIOChannel.
@@ -321,7 +325,7 @@ static int checkTimeouts(gpointer data)
        return 0;
 }
 
-static int callback_http_only(libwebsocket_context *context, struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len)
+static int callback_http_only(struct lws *wsi,enum lws_callback_reasons reason, void *user, void *in, size_t len)
 {
        unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 4096 + LWS_SEND_BUFFER_POST_PADDING];
        DebugOut() << __SMALLFILE__ << ":" << __LINE__ << reason << "callback_http_only" << endl;
@@ -639,7 +643,7 @@ static int callback_http_only(libwebsocket_context *context, struct libwebsocket
                {
                        DebugOut(5) << __SMALLFILE__ << ":" << __LINE__ << "Adding poll for websocket IO channel" << endl;
                        //Add a FD to the poll list.
-                       GIOChannel *chan = g_io_channel_unix_new(libwebsocket_get_socket_fd(wsi));
+                       GIOChannel *chan = g_io_channel_unix_new(lws_get_socket_fd(wsi));
 
                        /// TODO: I changed this to be more consistent with the websocket sink end. it may not be correct. TEST
 
@@ -678,7 +682,7 @@ WebSocketSource::WebSocketSource(AbstractRoutingEngine *re, map<string, string>
 
        if(config.find("useExtensions") != config.end() && config["useExtensions"] == "true")
        {
-               info.extensions = libwebsocket_get_internal_extensions();
+               info.extensions = lws_get_internal_extensions();
        }
 
        info.gid = -1;
@@ -686,7 +690,7 @@ WebSocketSource::WebSocketSource(AbstractRoutingEngine *re, map<string, string>
        info.port = CONTEXT_PORT_NO_LISTEN;
        info.user = this;
 
-       context = libwebsocket_create_context(&info);
+       context = lws_create_context(&info);
 
        setConfiguration(config);