Am 13.03.2013 um 03:15 schrieb Esteban A. Maringolo <[email protected]>:
> Hi,
>
> Is there a way to use the same server Seaside is using to plug a
> ZnWebSocketDelegate into it?
>
> The ZnZincServerAdaptor runs by default as the root delegator for its server
> (at whatever port it was started), but I was wondering if there is a way to
> reuse the same server Seaside (on top of Zinc) is using, to plug different
> WS handlers.
>
> By now I'm just using another server to run the WS, which is no big deal
> except to open an extra port in my server.
I had the same problem. I wanted to deliver an image without frontend server so
the extra ports can be somewhat awkward. I didn't adopt the newest changes from
Sven, yet. I do it this way
startServer
| staticFileDelegate seasideAdaptor |
seasideAdaptor := ZnZincServerAdaptor port: self port.
WAServerManager default adaptors do: [:each|
WAServerManager default unregister: each ].
staticFileDelegate := NTedStaticFileServerDelegate new directory: (
FileDirectory default containingDirectory directoryNamed:
'web').
(ZnServer startDefaultOn: self port)
debugMode: true;
delegate: (
NTedContextDispatcherDelegate new
map: 'ws' to: (ZnWebSocketDelegate map: 'ws'
to: NTedWebSocketHandler new);
map: 'css' to: staticFileDelegate;
map: 'js' to: staticFileDelegate;
map: 'img' to: staticFileDelegate;
map: 'font' to: staticFileDelegate;
map: 'csv' to: NTedCSVHandler new;
map: 'admin' to: (
NTedContextDispatcherDelegate new
map: 'css' to:
staticFileDelegate;
map: 'js' to:
staticFileDelegate;
map: 'img' to:
staticFileDelegate;
map: 'font' to:
staticFileDelegate;
defaultHandler:
(ZnSeasideServerAdaptorDelegate with: seasideAdaptor)
);
defaultHandler: staticFileDelegate ).
This way I start a one click image server that contains its static resource
within the one click distribution directory and serves WebSockets, a little CSV
http handler and seaside for the admin interface. All on the same port and
ready when the image is opened.
NTedStaticFileServerDelegate is basically a ZnStaticFileServerDelegate that
adds some cache headers for resources. NTedContextDispatcherDelegate maps
context paths to handlers. It uses a path consumer so that you can use more
levels of configuration like in the above example. That means every level takes
away the first part of the url.
Hope that helps,
Norbert