Skip to content

Commit

Permalink
make ping func to be able to call inside the C code
Browse files Browse the repository at this point in the history
  • Loading branch information
shotastage committed May 8, 2023
1 parent 432441a commit 734b22f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -24,6 +24,7 @@ tokio = { version = "1.24.0", features = ["full"] }
safer-ffi = "0.0.10"
sha1 = "0.10.5"
swift-bridge = "0.1"
libc = "0.2"


[build-dependencies]
Expand Down
2 changes: 2 additions & 0 deletions include/engine.h
Expand Up @@ -22,6 +22,8 @@ void ovry_warning(const char *msg);

void ovry_error(const char *msg);

void overlay_ping(const char *listen_on);

void c_exec_wasm_text_module(const char *wasm_text, const char *main_fn);

void c_exec_wasm_native_module(const unsigned char *data, uintptr_t data_length);
Expand Down
6 changes: 4 additions & 2 deletions src/pingpong.rs
@@ -1,3 +1,5 @@
pub fn overlay_ping(listen_on: String) {
println!("OVERLAY_PING: {}", listen_on)
#[no_mangle]
pub extern "C" fn overlay_ping(listen_on: *const libc::c_char) {
let listen_on = unsafe { std::ffi::CStr::from_ptr(listen_on).to_string_lossy().into_owned() };
println!("OVERLAY_PING: {}", listen_on);
}

0 comments on commit 734b22f

Please sign in to comment.