links-lang / links

Links: Linking Theory to Practice for the Web
http://www.links-lang.org
Other
332 stars 42 forks source link

Add missing access point functions on client #1105

Closed SimonJF closed 2 years ago

SimonJF commented 2 years ago

The Links standard library implements four functions for creating access points: new, newServerAP, newClientAP, and newAP. Of these, only new is implemented on the client.

This simple patch implements (at least stubs for) the other three. We use the same assumptions as spawn, and only support creating APs on the local client rather than the server or another client. newClientAP is simply wired to new.

This allows us to run, e.g.,

fun main() {
    var _ = spawnClient {
        var ap = newClientAP();
        var _ = spawn { var s = accept(ap); close(send((), s)) };
        var t = request(ap);
        var ((), t) = receive(t);
        close(t);
        print("done")
    };
    page <html></html>
}

serveThis(main)