Replaced libwebsockets apis to check last fragment 16/105516/1
authorkmook <kmook.choi@samsung.com>
Mon, 19 Dec 2016 01:28:47 +0000 (10:28 +0900)
committerkmook <kmook.choi@samsung.com>
Mon, 19 Dec 2016 01:28:47 +0000 (10:28 +0900)
Change-Id: I8417c54f063f34ae748f9f7882131ecbfec516bf
Signed-off-by: kmook <kmook.choi@samsung.com>
msf_tizen_client/src/Channel.cpp

index 286afbc..644568b 100755 (executable)
@@ -920,7 +920,7 @@ int Channel::callback_lws_mirror(struct lws *wsi,
 
                                MSF_DBG("type:%s", this_ptr->eventType.c_str());
 
-                               if (lws_remaining_packet_payload(wsi) == 0) {
+                               if (lws_is_final_fragment(wsi)) {
                                        MSF_DBG("there's no remaining packet");
                                        if (this_ptr->eventType == CONNECT_EVENT) {
                                                MSF_DBG("handle connect message");
@@ -948,7 +948,7 @@ int Channel::callback_lws_mirror(struct lws *wsi,
 
                                this_ptr->connectionHandler->resetLastPingReceived();
 
-                               if (lws_remaining_packet_payload(wsi) == 0) {
+                               if (lws_is_final_fragment(wsi)) {
                                        MSF_DBG("there's no remaining packet");
                                        if (this_ptr->eventType == CONNECT_EVENT) {
                                                MSF_DBG("handle connect message");
@@ -983,7 +983,7 @@ int Channel::callback_lws_mirror(struct lws *wsi,
                                this_ptr->connectionHandler->resetLastPingReceived();
                        }
 
-                       if (lws_remaining_packet_payload(wsi) == 0) {
+                       if (lws_is_final_fragment(wsi)) {
                                if (this_ptr->cl_data) {
                                        this_ptr->json_parse((char*)this_ptr->cl_data);
                                }
@@ -1342,7 +1342,7 @@ void *Channel::pt_startConnect(void *att) {
 
 void Channel::create_websocket(void *att) {
        struct lws_protocols protocols[] = {
-               {NULL, Channel::callback_lws_mirror, sizeof(int), 0, 0,
+               {NULL, Channel::callback_lws_mirror, sizeof(int), 512000, 0,
                 NULL},
 
                // libwebsockets 1.7 has a bug.
@@ -1374,7 +1374,7 @@ void Channel::create_websocket(void *att) {
        }
        info.gid = -1;
        info.uid = -1;
-       info.options = 0;
+       info.options = (1 << 12);
        info.user = this;
 
 #ifndef LWS_NO_EXTENSIONS
@@ -1728,7 +1728,7 @@ void Channel::handleWsiDestroy()
 
                MSF_ERR("wsi destroyed with no communication");
                if (onErrorListener) {
-                       onErrorListener->onError();
+                       onErrorListener->onError(Error::create("Closed"));
                }
        }
 }