Scala language binding lightly-tested and works
This commit is contained in:
11
examples/bindings/scala/ExampleApp.scala
Normal file
11
examples/bindings/scala/ExampleApp.scala
Normal file
@@ -0,0 +1,11 @@
|
||||
import zerotier.ZeroTier
|
||||
|
||||
object ExampleApp extends App {
|
||||
|
||||
System.loadLibrary("zt")
|
||||
|
||||
val libzt = new ZeroTier
|
||||
libzt.ztjni_startjoin("/Users/joseph/op/zt/libzt/ztjni", "1212121212121212")
|
||||
val fd = libzt.ztjni_socket(2, 1, 0)
|
||||
println(s"zts_socket(): $fd")
|
||||
}
|
||||
@@ -6,7 +6,7 @@ To get this example project to work, do the following:
|
||||
- From libzt main directory, build shared library: `make shared_jni_lib`
|
||||
- Copy the resultant dynamic library (`*.so` or `*.dylib`) from `build/` to this current directory
|
||||
- Change to this directory and `make example_scala_app`
|
||||
- Run: `scala -cp "." ExampleApp`
|
||||
- Run: `scala -Djava.library.path=$(pwd) -cp "." ExampleApp`
|
||||
|
||||
|
||||
Notes:
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
package zerotier;
|
||||
|
||||
class ZeroTier {
|
||||
@native def ztjni_socket(socket_family: Int, socket_type: Int, protocol: Int): Int
|
||||
@native def ztjni_startjoin(path: String, nwid: String): Int
|
||||
}
|
||||
|
||||
object ZeroTier extends App {
|
||||
|
||||
System.loadLibrary("zt")
|
||||
|
||||
val libzt = new ZeroTier
|
||||
val fd = libzt.ztjni_socket(2, 1, 0)
|
||||
println(s"zts_socket(): $fd")
|
||||
}
|
||||
Reference in New Issue
Block a user