fedwiki / wiki-server

Federated Wiki client and server in Node.js
Other
153 stars 35 forks source link

Add server to client event forwarding #150

Closed joshuabenuck closed 4 years ago

joshuabenuck commented 5 years ago

This PR builds on https://github.com/fedwiki/wiki/pull/127. As part of the server side initialization of plugins, the server will start a socket.io listener.

Server side events are keyed by slugItem (the slug of a page + the id of an item separated by a slash).

Clients register their interest in a particular slugItem event by sending a subscribe message to the server. When a client is no longer interested in a particular slugItem, it should send an unsubscribe message. A forthcoming PR adds common logic to handle this for clients so they do not have to do this themselves.

Server side plugins should emit any event that they want forwarded by using the event emitter that is part of the params object passed to the startServer callback of their plugin.

Note: Plugins will need to use an out of band mechanism to identify the slugItems that require server side processing. This could take the form of a custom URL or a config file. The eventing system does not provide any means for a server side plugin to be notified of the existence of specific slugItems.

Changes remaining before merge:

joshuabenuck commented 5 years ago

I have cleaned up the listeners and the logging.

synopsis should reflect edit to first paragraph is the test that is failing. I have seen it randomly pass, but it mostly fails for me. Looks to be a timing issue of some sort.