-
Notifications
You must be signed in to change notification settings - Fork 4
/
MainExample.java
42 lines (36 loc) · 1.04 KB
/
MainExample.java
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
39
40
41
42
import org.kashyoo.swigexample.*;
import java.nio.ByteBuffer;
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.charset.*;
public class MainExample {
static java.nio.ByteBuffer buf = ByteBuffer.allocateDirect(100);
public class FrameCallback extends IFrameCB {
public void newFrame() {
System.out.print("newFrmae!");
try {
Charset charset = Charset.defaultCharset();
CharsetDecoder decoder = charset.newDecoder();
CharBuffer charBuffer = decoder.decode(MainExample.buf);
System.out.print(charBuffer.toString());
MainExample.buf.clear();
} catch (java.io.IOException ex) {
}
}
}
public void do_work() throws InterruptedException {
FrameCallback cb=this.new FrameCallback();
Monitor mon=new Monitor();
mon.mon_init(MainExample.buf);
Thread.sleep(100);
mon.mon_register(cb);
while (true) {
}
}
public static void main(String argv[]) throws InterruptedException {
System.loadLibrary("example");
MainExample main = new MainExample();
main.do_work();
}
}