[tink_web] Hello Remoting - teething troubles

Soooo, I’m trying to get super simple remoting example code going, but I’m having compiler issues…

I have the server side like this…

package server;

import tink.http.containers.*;
import tink.http.Response;
import tink.web.routing.*;

#if(nodejs)
class Server {
    static function main() {
        var container = new NodeContainer(1982);
        var router = new Router<Root>(new Root());
        container.run(function(req) {
            return router.route(Context.ofRequest(req))
                .recover(OutgoingResponse.reportError);
        });
        trace("server started");
    }
}
#end

class Root {
    public function new() {}

    @:get('/')
    public function hello(query:{name:String}) {
        return {
            greetings: 'Hello, ${query.name}!',
        }
    }
}

and on the client I have…

package client;

import tink.http.clients.*;
import tink.http.*;
import tink.web.proxy.Remote;
import tink.url.Host;
import server.Server.Root;

class ClientSide {
    static function main() {
        var remote = new Remote<Root>(new JsClient(), new RemoteEndpoint(new Host('localhost', 1982)));
        remote.hello({name: 'Haxe'}).handle(function(o) switch o {
            case Success(result): trace($type(result));
            case Failure(e): trace(e);
        });
    }
}

Now, the server compiles, and hitting is up in the browser works like a champ. The client though borked at the node stuff in the Server class, hence the if nodejs in there. However once that is resolved I am getting Type not found JsClient. I can see it defined in tink.http.Client, I’ve imported tink-http.* in the example but explicitly importing the Client class makes no odds either. The conditional compilation in there says if js and not node, which is the case with the client but no dice.

Not sure why this is happening as the client code per remoting had new JsClient() in nd that compiled. So I’m a little confused.

the build-client.hxml to build it contains…

-cp src
-lib tink_web
-lib tink_http
-main client.ClientSide
-js bin/js/client.js

Any ideas?

Can you try separating the Root class into a separate file?

Also, using the gitter haxetink/public - Gitter generally will give you faster response :wink: