[Libwebsockets] protocol plugin

Andy Green andy at warmcat.com
Thu Feb 2 07:30:19 CET 2017

On 02/02/2017 02:17 PM, Joel Winarske wrote:
> Say I want to implement a single plugin for multiple mount points.  In 
> the protocol callback, how do I get the mount point string value?  Do 
> I have to examine the header, or is it already available somewhere?

The right way to look at it is you created a plugin with a single protocol.

It happened that multiple mountpoints, usually on a different vhost each 
time, wanted to mount an instance of that protocol somewhere in their 
URL space.

As far as that goes, in itself the protocol callback is not aware of the 
mountpoint, and the mounts are all treated the same, although you can 
use per-vhost structs in the callback to mean that mounted protocol 
instances on each vhost can do things separately.

To make things more useful, you can pass in "pvo", per-vhost options 
when you enable the protocol for each vhost individually.  For example 
the server-status URL I sent before has its protocol enabled like this

        "lws-server-status": {
          "status": "ok",
          "update-ms": "5000",
          "filepath": "/sys/class/thermal/thermal_zone0/temp",
          "filepath": "/proc/version",
          "hide-vhosts": "1"

So you could just as easily enable the protocol on another vhost, but 
with different settings.

There are also "pmo", per-mount options the plugin can access.  But pvo 
are probably want you want if each mount is on a different vhost.

You can see how the server status plugin gets ahold of the pvo at init


since he stashes them in his per-vhost struct, he can act completely 
differently simultaneously depndning on the vhost you access him from.


> Thanks!
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets

More information about the Libwebsockets mailing list