Search in sources :

Example 1 with Remoted

use of org.nustaq.kontraktor.annotations.Remoted in project kontraktor by RuedigerMoeller.

the class ReactAppSession method createTokenLink.

@Remoted
public IPromise<String> createTokenLink() {
    Promise res = new Promise();
    getSessionStorage().createToken(new ISessionStorage.Token(userKey, "hello", 60_000l)).then((s, err) -> {
        if (s != null)
            res.resolve("direct/" + s);
        else
            res.reject(err);
    });
    return res;
}
Also used : IPromise(org.nustaq.kontraktor.IPromise) Promise(org.nustaq.kontraktor.Promise) Remoted(org.nustaq.kontraktor.annotations.Remoted)

Example 2 with Remoted

use of org.nustaq.kontraktor.annotations.Remoted in project kontraktor by RuedigerMoeller.

the class ReactApp method register.

@Remoted
public IPromise register(String nick, String pwd, String text) {
    Promise p = new Promise();
    sessionStorage.putUserIfNotPresent(MapRecord.New(nick).put("pwd", pwd).put("text", text).put("verified", true)).then((r, e) -> {
        if (!r) {
            p.reject("user " + nick + " already exists");
        } else {
            p.resolve(true);
        }
    });
    return p;
}
Also used : IPromise(org.nustaq.kontraktor.IPromise) Promise(org.nustaq.kontraktor.Promise) Remoted(org.nustaq.kontraktor.annotations.Remoted)

Example 3 with Remoted

use of org.nustaq.kontraktor.annotations.Remoted in project kontraktor by RuedigerMoeller.

the class BasicWebAppActor method login.

/**
 * returns an array of [session actorproxy, userdata]
 * @param user
 * @param pw
 * @param jwt
 * @return array [session actor proxy, authenticationresult]
 */
@Remoted
public IPromise<Object[]> login(String user, String pw, String jwt) {
    Promise res = new Promise();
    ConnectionRegistry remoteConnection = connection.get();
    getCredentials(user, pw, jwt).then((authres, err) -> {
        if (err != null) {
            res.reject(err);
        } else {
            String sessionId = remoteConnection != null ? remoteConnection.getSocketRef().getConnectionIdentifier() : null;
            getSession(user, sessionId, authres).then((sess, serr) -> {
                if (sess != null) {
                    if (sessionId != null && sessionStorage != null) {
                        sessionStorage.putUserAtSessionId(sessionId, user);
                    }
                    res.resolve(new Object[] { sess, authres });
                } else
                    res.complete(sess, serr);
            });
        }
    });
    return res;
}
Also used : ConnectionRegistry(org.nustaq.kontraktor.remoting.base.ConnectionRegistry) Remoted(org.nustaq.kontraktor.annotations.Remoted)

Example 4 with Remoted

use of org.nustaq.kontraktor.annotations.Remoted in project kontraktor by RuedigerMoeller.

the class ReactAppSession method createTokenLink.

@Remoted
public IPromise<String> createTokenLink() {
    Promise res = new Promise();
    getSessionStorage().createToken(new ISessionStorage.Token(userKey, "hello", 60_000l)).then((s, err) -> {
        if (s != null)
            res.resolve("direct/" + s);
        else
            res.reject(err);
    });
    return res;
}
Also used : IPromise(org.nustaq.kontraktor.IPromise) Promise(org.nustaq.kontraktor.Promise) Remoted(org.nustaq.kontraktor.annotations.Remoted)

Example 5 with Remoted

use of org.nustaq.kontraktor.annotations.Remoted in project kontraktor by RuedigerMoeller.

the class ReactApp method register.

@Remoted
public IPromise register(String nick, String pwd, String text) {
    Promise p = new Promise();
    sessionStorage.putUserIfNotPresent(MapRecord.New(nick).put("pwd", pwd).put("text", text).put("verified", true)).then((r, e) -> {
        if (!r) {
            p.reject("user " + nick + " already exists");
        } else {
            p.resolve(true);
        }
    });
    return p;
}
Also used : IPromise(org.nustaq.kontraktor.IPromise) Promise(org.nustaq.kontraktor.Promise) Remoted(org.nustaq.kontraktor.annotations.Remoted)

Aggregations

Remoted (org.nustaq.kontraktor.annotations.Remoted)5 IPromise (org.nustaq.kontraktor.IPromise)4 Promise (org.nustaq.kontraktor.Promise)4 ConnectionRegistry (org.nustaq.kontraktor.remoting.base.ConnectionRegistry)1