WebSemaphore via Websockets

Websockets provide the simplest way to acquire a resource in situations when a public ip is not an option such as enterprise environments with firewall rules and frontend applications.

Reference implementation

A sample implementation is available at WebSemaphore examples on github.

Async wrapper

We provide a convenience async/await wrapper that reduces the effort to a simple async call. Note that this approach is only usable where the process that initiated the flow is also the one to process the task when the lock is acquired. If your flow is distributed, as in a cloud setup, use either the REST API with callbacks or a custom implementation using websockets.

How it works: the wrapper maintains an internal registry of sent messages and pending promises. The promise is resolved once the corresponding message is received signaling lock acquisition (or possibly rejection if using the sync version).

Loading...

Raw websockets

The Websockets section of the API guide describes the low-level operations that can be used directly using any websockets implementation. This is the most flexible approach but requires the developer to work at the websockets level. For a simplified integration see the previous section.

Loading...

As you can see, a naive approach will likely make it very complicated. If you use typescript/javascript, the approach in the previous section in more practical. If you need support for another stack/language contact us.