Bridge (wx v1.0.10) View Source

Bridge is a drop-in replacement for Erlangs wx modules that sends commands sent to wx modules via tcp/ip to a daemon. It's purpose is to make it possible to communicate with native parts of iOS/Android applications within the elixir-desktop framework to make apps mobile!

Protocol

Current protocol is json based.

All :wx*.new(args...) calls generate keyword lists like: [id: System.unique_integer([:positive]), type: module, args: args]

Most wx*.method(args...) calls are then forwarded via JSON to the native side with a 64-bit request id value: <<request_ref :: unsigned-size(64), json :: binary>>

The responses correspndingly return the same ref and the json response: <<response_ref :: unsigned-size(64), json :: binary>>

For receiving commands from the native side of the bridge there are three special ref values:

  • ref = 0 -> This indicates a published system event system, corresponding to :wx.subscribe_events() needed for publishing files that are shared to the app. <<0 :: unsigned-size(64), event :: binary>>
  • ref = 1 -> This indicates triggering a callback function call that was previously passed over. Internally an funs that are passed into :wx.method() calls are converted to 64-bit references, those can be used here to indicate which function to call. <<1 :: unsigned-size(64), fun :: unsigned-size(64), event :: binary>>
  • ref = 2 -> This indicates a call from the native side back into the app side. TBD <<2 :: unsigned-size(64), ...>>

# JSON Encoding of Elixir Terms

Link to this section Summary

Link to this section Functions

Link to this function

bridge_call(type, method, args)

View Source

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this macro

generate_bridge_calls(module, names)

View Source (macro)