Skip to content
Snippets Groups Projects
service.c 28.2 KiB
Newer Older
  • Learn to ignore specific revisions
  • 					wsi->parent->user_space,
    
    Andy Green's avatar
    Andy Green committed
    					(void *)&args, 0))
    				return 1;
    
    			break;
    		}
    #endif
    
    	default:
    #ifdef LWS_NO_CLIENT
    		break;
    #else
    		n = lws_client_socket_service(context, wsi, pollfd);
    
    		goto handled;
    #endif
    	}
    
    	n = 0;
    	goto handled;
    
    close_and_handled:
    
    	lwsl_debug("Close and handled\n");
    
    	lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS);
    
    Andy Green's avatar
    Andy Green committed
    	 * pollfd may point to something else after the close
    	 * due to pollfd swapping scheme on delete on some platforms
    	 * we can't clear revents now because it'd be the wrong guy's revents
    	 */
    
    Andy Green's avatar
    Andy Green committed
    LWS_VISIBLE int
    lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd)
    {
    	return lws_service_fd_tsi(context, pollfd, 0);
    }
    
    
     * lws_service() - Service any pending websocket activity
    
     * @context:	Websocket context
     * @timeout_ms:	Timeout for poll; 0 means return immediately if nothing needed
     *		service otherwise block and service immediately, returning
     *		after the timeout if nothing needed service.
     *
     *	This function deals with any pending websocket traffic, for three
     *	kinds of event.  It handles these events on both server and client
     *	types of connection the same.
     *
     *	1) Accept new connections to our context's server
     *
     *	2) Call the receive callback for incoming frame data received by
     *	    server or client connections.
     *
     *	You need to call this service function periodically to all the above
     *	functions to happen; if your application is single-threaded you can
     *	just call it in your main event loop.
     *
     *	Alternatively you can fork a new process that asynchronously handles
     *	calling this service in a loop.  In that case you are happy if this
     *	call blocks your thread until it needs to take care of something and
     *	would call it with a large nonzero timeout.  Your loop then takes no
     *	CPU while there is nothing happening.
     *
     *	If you are calling it in a single-threaded app, you don't want it to
     *	wait around blocking other things in your loop from happening, so you
     *	would call it with a timeout_ms of 0, so it returns immediately if
     *	nothing is pending, or as soon as it services whatever was pending.
     */
    
    LWS_VISIBLE int
    
    lws_service(struct lws_context *context, int timeout_ms)
    
    {
    	return lws_plat_service(context, timeout_ms);
    }
    
    
    Andy Green's avatar
    Andy Green committed
    LWS_VISIBLE int
    lws_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
    {
    	return lws_plat_service_tsi(context, timeout_ms, tsi);
    }