[TOC]
Java 8
<dependency>
<groupId>com.github.highras</groupId>
<artifactId>fpnn</artifactId>
<version>2.0.5-RELEASE</version>
</dependency>
import com.fpnn.sdk.*;
import com.fpnn.sdk.proto.Answer;
import com.fpnn.sdk.proto.Quest;
TCPClient client = new TCPClient(String host, int port);
TCPClient client = new TCPClient(String host, int port, boolean autoConnect);
client.setQuestProcessor(Object questProcessor, String questProcessorFullClassName);
client.setConnectedCallback(ConnectionConnectedCallback cb);
client.setWillCloseCallback(ConnectionWillCloseCallback cb);
public interface ConnectionConnectedCallback {
void connectResult(InetSocketAddress peerAddress, boolean connected);
}
public interface ConnectionWillCloseCallback {
void connectionWillClose(InetSocketAddress peerAddress, boolean causedByError);
}
public void setKeepAlive(boolean keepAlive)
Note: The default connection is not keepAlive
public boolean client.enableEncryptorByDerFile(String curve, String keyFilePath);
public boolean client.enableEncryptorByDerData(String curve, byte[] peerPublicKey);
//-- Sync method
public Answer client.sendQuest(Quest quest) throws InterruptedException;
public Answer client.sendQuest(Quest quest, int timeoutInSeconds) throws InterruptedException;
//-- Async methods
public void client.sendQuest(Quest quest, AnswerCallback callback);
public void client.sendQuest(Quest quest, AnswerCallback callback, int timeoutInSeconds);
public void client.sendQuest(Quest quest, FunctionalAnswerCallback callback);
public void client.sendQuest(Quest quest, FunctionalAnswerCallback callback, int timeoutInSeconds);
public interface FunctionalAnswerCallback {
void onAnswer(Answer answer, int errorCode);
}
client.close();
System.out.println(ClientEngine.SDKVersion);
Please refer: API docs
-
<fpnn-sdk-java>/src
Maven Project.
-
<fpnn-sdk-java>/src/main/java
Codes of SDK.
-
-
<fpnn-sdk-java>/examples
Example modules for using this SDK.
All modules are normal module with IDEA, NOT MAVEN PROJECT and NOT MAVEN MODULE.
Testing server is <fpnn>/core/test/serverTest. Refer: Cpp codes of serverTest -
<fpnn-sdk-java>/performanceTests
-
<fpnn-sdk-java>/performanceTests/asyncStressClient
Stress & Concurrent testing codes for SDK.
This is normal module with IDEA, NOT MAVEN PROJECT and NOT MAVEN MODULE.
Testing server is /core/test/serverTest. Refer: Cpp codes of serverTest -
<fpnn-sdk-java>/performanceTests/singleClientConcurrentTest
Stability testing codes for SDK.
This is normal module with IDEA, NOT MAVEN PROJECT and NOT MAVEN MODULE.
Testing server is /core/test/serverTest. Refer: Cpp codes of serverTest
-