Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 236
Expand file tree
/
Copy pathMain.java
More file actions
Latest commit
38 lines (37 loc) · 1.4 KB
/
Copy pathMain.java
File metadata and controls
38 lines (37 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// usage: when generating the binding code, do cmake -DCCAPI_ENABLE_LOG_TRACE=ON ..., see https://github.com/crypto-chassis/ccapi#non-c
importcom.cryptochassis.ccapi.Logger;
importcom.cryptochassis.ccapi.Session;
importcom.cryptochassis.ccapi.SessionConfigs;
importcom.cryptochassis.ccapi.SessionOptions;
importcom.cryptochassis.ccapi.Subscription;
importjava.util.concurrent.locks.ReentrantLock;
publicclassMain {
staticclassMyLoggerextendsLogger {
@Override
publicvoidlogMessage(Stringseverity, StringthreadId, StringtimeISO, StringfileName, StringlineNumber, Stringmessage) {
this.lock.lock();
try {
System.out.println(String.format("%s: [%s] {%s:%s} %s%s%s", threadId, timeISO, fileName, lineNumber, severity, " ".repeat(8), message));
} finally {
this.lock.unlock();
}
}
ReentrantLocklock = newReentrantLock();
}
publicstaticvoidmain(String[] args) {
System.loadLibrary("ccapi_binding_java");
varmyLogger = newMyLogger();
Logger.setLogger(myLogger);
varoption = newSessionOptions();
varconfig = newSessionConfigs();
varsession = newSession(option, config);
varsubscription = newSubscription("okx", "BTC-USDT", "MARKET_DEPTH");
session.subscribe(subscription);
try {
Thread.sleep(10000);
} catch (InterruptedExceptione) {
}
session.stop();
System.out.println("Bye");
}
}