Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Websockets

odoodo
in Questions Posts: 13

I am currently coding flight instruments for the Stratux flight box in Codea.
The box talks on websockets via WiFi.

Is there any chance to listen to websockets (wss:/ ...) in Codea?

The last post on this topic is some years old. My hope is that something improved...
I have a solution that works in coronalabs but I prefer Codea for coding!

Tagged:

Comments

  • dave1707dave1707 Mod
    edited October 1 Posts: 7,880

    @odo Codea has socket, is that the same as websockets. Codea also has osc which I think is easier than socket. I have code that transfers files or other info between iPads on the same network using osc.

  • odoodo
    Posts: 13

    @dave1707

    Websockets is sockets plus a special protocol. There are lua websocket implementations i.e. on github. But these solutions need more required modules that I don’t find in Codea.

    OSC: yes. I really like OSC and I wrote some sample code for me. But unfortunately the hardware that I am targeting (www.stratux.me) just doesn’t use OSC in its software stack. I uses websockets,

    My goal is to read the data of the stratux box (or more precisely: react on the data that it pushes to me) and Display flight instruments in Codea. Attitude and Heading (artificial horizon) and air traffic display.

    So unfortunately I need websockets

  • odoodo
    edited October 2 Posts: 13

    Ok. Trying to help myself until there is a better solution...

    I started to port https://github.com/lipp/lua-websockets to Codea. I want to make it a Codea library.

    But I a, am stuck now, because Codea doesn’t seem to have SSL included.

    This line of code fails

    require „ssl“

    Does somebody know a solution for that problem?
    As a workaround: Can I compile in Xcode including additional modules like ssl?
    If this is the case, I would maybe not port websockets as a Codea library but link it together with ssl as Objective-C. Disadvantage would be, that I can‘t use it on the IPad in the development environment. Right? So I would have to use a mock WebSocket-client in Codea on the IPad but the AppStore Version (or the Xcode Version) would be able to use websockets including ssl. Am I right with this idea? I don‘t have so much Codea experience yet to fully understand the Xcode concept of Codea.

    Basically, the idea is: if Codea doesn’t support websockets or ssl, I would wrap an Objective-C library like this one: https://github.com/zwopple/PocketSocket within XCode.

    Does this approach make sense?

  • SimeonSimeon Admin Mod
    edited October 2 Posts: 5,054

    @odo I think iOS just added websocket support to its networking library, might be a good opportunity to include and design a Lua API around it for the runtime

    https://developer.apple.com/documentation/foundation/nsurlsessionwebsockettask?language=objc

  • odoodo
    Posts: 13

    @Simeon that would be great!

  • odoodo
    Posts: 13

    @Simeon , yes, IOS added websocket support in swift,
    I just tried some sample code. It is not the most intuitive way of implementing websockets but anyway :wink:
    Do you think that you will integrate the API in Codea?
    And do you have an idea when it could be released?
    I just started to implement my code for the flight instrument in Codea. And I really enjoy coding in Codea. But the websockets would be a dealbreaker for me because this is the only way for me to communicate with the aviation computer that sends the data to my app.

Sign In or Register to comment.