Skip to content

Instantly share code, notes, and snippets.

@nicoruti
Created April 8, 2014 08:18
Show Gist options
  • Save nicoruti/10101395 to your computer and use it in GitHub Desktop.
Save nicoruti/10101395 to your computer and use it in GitHub Desktop.
import java.io.File;
import org.hive2hive.core.api.H2HNode;
import org.hive2hive.core.api.configs.FileConfiguration;
import org.hive2hive.core.api.configs.NetworkConfiguration;
import org.hive2hive.core.api.interfaces.IH2HNode;
import org.hive2hive.core.api.interfaces.INetworkConfiguration;
import org.hive2hive.core.security.UserCredentials;
public class DemoCode {
public static void main(String[] args) throws Exception {
new DemoCode().useHive2Hive();
}
public void useHive2Hive() throws Exception {
// configuration of the "initial" peer
INetworkConfiguration initialConfig = NetworkConfiguration.create();
// create the first peer
IH2HNode peer1 = H2HNode.createNode(initialConfig, FileConfiguration.createDefault());
// create a new network
peer1.connect();
UserCredentials user = new UserCredentials("Name", "Password", "PIN");
// register the user
peer1.getUserManager().register(user).await();
// login the user
peer1.getUserManager().login(user, new File("...").toPath()).await();
// do any file operation
peer1.getFileManager().add(new File("...")).await();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment