Websockets and JSON format

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Websockets and JSON format

Post by jekyllandhyde » Thu Dec 17, 2015 7:18 am

Ok my subject title sounds like I know what I'm talking about but truthfully I don't have a clue about networking or parsing streams of data. I'm sort of an advanced livecode beginner with a few apps under my belt but thought I'd stretch myself with a new hobby project. I'm pretty clear about building the front end of the App but the backend stuff is scary so I'm looking for a bit of guidance....

Here's the concept: IOS App (client) that subscribes to JSON formatted data (from local server) and updates the screen with values that change approximately once per second. Will be read only for now.

Here's the data subscription protocol: http://signalk.org/developers/subscript ... tocol.html
My understanding is that 7.1.1 of livecode now supports web sockets for mobile so that's my starting point.

I guess what I need to figure out is:

1) Is JSON possible with livecode?
2) How to open the connection to the server?
3) How to subscribe to the data values I want?
4) How to parse out those values and then update the screen with those values?

For the first phase I won't store any data, just use it and lose it.

Bonus points if you know how to code Bonjour discovery! :)

I found this lesson http://lessons.livecode.com/m/4071/l/12 ... ng-sockets but the whole JSON thing confuses me.

Thanks in advance if you can help, Adam

peter-b
Posts: 182
Joined: Thu Nov 20, 2014 2:14 pm

Re: Websockets and JSON format

Post by peter-b » Sun Dec 20, 2015 2:12 pm

I'm afraid no version of LiveCode currently supports websockets directly. However, you could probably implement them using "raw" sockets without too much difficulty.
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com

jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Re: Websockets and JSON format

Post by jekyllandhyde » Sun Dec 27, 2015 9:28 pm

You've lost me at this point :)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10044
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Websockets and JSON format

Post by FourthWorld » Mon Dec 28, 2015 5:05 am

If raw sockets are problematic you may not need web sockets.

There are at least three JSON libraries available for LiveCode.

Can you tell us more about what you need from web sockets in your LC project?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Re: Websockets and JSON format

Post by jekyllandhyde » Thu Jan 07, 2016 7:19 am

Richard,

Thanks for the response. I'll try to be more specific. Essentially I want the mobile client to connect to a java server that serves up the data stream.

Here's the API and conventions used: http://signalk.org/developers/apis_and_conventions.html

Here's the subscription protocol: http://signalk.org/developers/subscript ... tocol.html

example web socket URL: http://demo.signalk.org/signalk/stream/v1

Here's an example of an HTML 5 based consumer connected to a web socket receiving a json based data stream: http://signalk.org/demo.html

I believe you issue commands using either JSON messages or Rest API Calls.

If this can't be done in an IOS or Android App, perhaps it would be easier to create an HTML 5 app to run in a browser similar to the consumer example above. Could this be done in livecode?

Sorry to be a bit vague, this backend stuff is not my forte. I need a bit of guidance to know what's technically possible and the best way of leveraging Livecode to do it.

thx, Adam

Post Reply