package com.zaranux.os.client.commands;
import com.zaranux.client.api.AsyncCallback;
import com.zaranux.client.java.io.PrintStream;
public class login extends Command {
@Override
protected void execute(final AsyncCallback<Boolean> callback) {
String[] args = getArgs();
if(args.length == 2)
{
String id = args[0];
String pass = args[1];
systemcall.login(id, pass, new AsyncCallback<Boolean>()
{
public void onSuccess(final Boolean result)
{
/*outPS.print("sessionToken: " + sessionToken ,new AsyncCallback<Boolean>()
{
public void onSuccess(Boolean b)
{
// outPS.flush(callback);
callback.onSuccess(true);
}
public void onFailure(Throwable t)
{
callback.onFailure(t);
}
});
*/
callback.onSuccess(true);
}
public void onFailure(Throwable T)
{
final PrintStream outPS = (PrintStream) System.out;
outPS.print("Wrong username/password!" ,new AsyncCallback<Boolean>()
{
public void onSuccess(Boolean b)
{
// outPS.flush(callback);
callback.onSuccess(true);
}
public void onFailure(Throwable t)
{
callback.onFailure(t);
}
});
}
});
}else
{
System.out.println("Wrong parameters: Usage: login <username> <pass>",callback);
}
}
}