Code for my wrapped class application constructor (the rest of the class is effectively the TwoPartyServer code):
template <typename T>
Publisher<T>::Publisher(const std::string& connection_address, kj::AsyncIoContext& io_context)
: tasks_(*this), connection_address_(connection_address), io_context_(io_context) {
auto listener = io_context_.provider->getNetwork().parseAddress(connection_address);
auto addr = listener.wait(io_context.waitScope);
auto addrListen = addr->listen();
addTask(listen(*addrListen));
}
```
This builds fine but I get an exception when I run the server.
```
error: exception = kj/async.c++:2714: failed: PromiseFulfiller was destroyed without fulfilling the promise.
```
I'm assuming the normal main application works because the `listen()` promise remains in scope but when I attempt to add the `kj::Promise<void>` to the member variable kj::TaskSet something isn't quite right.
My ideal situation would be this.
```
int main(int argc, const char** argv) {
// setup event loop etc.
auto io_context = kj::setupAsyncIO();
// Instantiate a publisher that accepts incoming connections asynchronously.
auto pub = Publisher<capnp::Text>("unix:/tmp/capnp-server-example", io_context);
// Start publishing at a specific frequency. Implementation involves a kj::Timer with afterDelay().
pub.publishAtFrequency("Hello Subscribers", 1);
// Spin on this publisher. It should continue to accept new subscribers whilst publishing.
pub.spin()
}
```
I hope I've given enough context and information. Please let me know if you need more information and thank you for this awesome library!
Dan