Created
April 8, 2014 08:18
-
-
Save nicoruti/10101395 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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