Class MemoryConnector

All Implemented Interfaces:
Connector, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, Graceful, LifeCycle

public class MemoryConnector extends AbstractConnector

A server Connector that allows clients to communicate via memory.

Typical usage on the server-side:

Server server = new Server();
MemoryConnector memoryConnector = new MemoryConnector(server, new HttpConnectionFactory());
server.addConnector(memoryConnector);
server.start();

Typical usage on the client-side:

// Connect to the server and get the local, client-side, EndPoint.
EndPoint clientEndPoint = memoryConnector.connect().getLocalEndPoint();

// Be ready to read responses.
Callback readCallback = ...;
clientEndPoint.fillInterested(readCallback);

// Write a request to the server.
ByteBuffer request = StandardCharsets.UTF_8.encode("""
    GET / HTTP/1.1
    Host: localhost

    """);
Callback.Completable writeCallback = new Callback.Completable();
clientEndPoint.write(writeCallback, request);