New to Storyboard 4.0, we've added the GREIO plugin to iOS and improved custom plugin support on mobile platforms. Attached are two sample applications that demonstrate the Storyboard IO TCP/IP functionality talked about in this post
for Android and iOS. Review that post to understand the purpose of the TCP/IP connection and look at the C code involved.
As a brief overview, the tcp_client application has a simple button that, when touched, will execute the send_event_outbound
Lua function and send a custom 'HelloOutThere' event to the channel 'outbound', which the client is listening on. The client will take that event and pass it on to the server, who will in turn pass it to the channel it is listening on, which should be the tcp_server application channel. The tcp_server application is listening for the 'HelloOutThere' event, and will call the Lua function received_event
which will display the event data on the screen.
To have the samples run properly, there are a few things to make sure to do when exporting the application to iOS/Android. Under 'Storyboard Runtime Options' in the export dialog, make sure to set the channel name for the server application (-ogreio,channel=<name>). This should be the same name sent into the call to init_server
. When exporting to Android, you need to add the 'android.permission.INTERNET' permission in order to successfully set up the connection, which you can do under 'Advanced Options'. You also need to set the 'Shared Object List Location' to be the path to user_libs.txt, found at the root of the project. This informs the exporter that there are custom libraries to load and tells it where they are. Once the applications are exported properly, make sure to run the server application first or the client won't have anything to connect to.
The samples can be adapted to work on other operating systems as well. For that you will need to re-compile sbio_tcprelay.c into a shared object for whatever environment you are in. I've attached a sample Makefile which you can change to build for your environment. You will need to change the SB_ROOT variable to contain the absolute path to the runtime you want to use. You may also need to change the CC variable to the appropriate compiler, as well as add any OS specific CFLAGS or LDFLAGS necessary.