Does GCDWebSever support web sockets? - ios

Need to implement a self-host Web-Server running on iPad, looks like GCDWebServer is a great option.
However the author does not intend to support for WebSocket, see link here.
Question: Is there an alternative to GCDWebServer that support WebSocket?

End up with Swifter which is not as mature, but good enough.
See the project here.

Related

Can a native iOS client connect to a meteor.js server?

I'm really intrigued by the meteor.js framework. However, I'm not certain whether or not I can take advantage of the framework's real-time capabilities via the objective-C's native objects such as NSURLConnection. I have some specific questions referencing this question on how meteorjs works: How does the Meteor JavaScript framework work?
Let's start with web sockets:
The client/server messaging is done via websockets using something
like socks.js or socket.io.
Is there an objective-C library or framework for utilizing websockets in native apps that would be able to communicate with a Meteor server?
Second, is the mongoDB client:
The client side connection to mongodb is really cool. It replicates
the mongo-server driver into the client. Unfortunately, last I
checked, they were still working on securing this database connection.
This seems like the most intriguing part of meteor. However, does this mean there is no standard way to communicate to the meteor server other than executing strings of javascript in a hidden UIWebView?
For anyone interested in this, I've been working on an objective ddp client library here. I've only just started and there is no documentation yet, but everything works well. The project is here: https://github.com/boundsj/ObjectiveDDP
The specs for the ddp client are here: https://github.com/boundsj/ObjectiveDDP/blob/master/Specs/ObjectiveDDPSpec.mm
I'm also building a library for meteor auth so ios clients can authenticate with a meteor server using the password package. It's all put together and working in this sample todo app (also part of the same repo): https://github.com/boundsj/ObjectiveDDP/tree/master/Example
not a full answers but hopefully a few pointers to get you started.
Meteor uses a protocol called DDP - Distributed Data Protocol. The blog post introducing it is here: http://meteor.com/blog/2012/03/21/introducing-ddp
There is an Objective-C client library on github here: https://github.com/alansikora/objective-c_ddp-client Although I can't vouch for it and it has no real documentation, the code is short and should be reasonably understandable by someone who already writes Objective-C.
Other than that I would suggest digging in and see if you can uncover any techniques for iOS clients. It's early days for Meteor and were all learning how to use it.

What's the preferred way of using Rails and Flex?

I'd like to create a service, similar to a chat application (realtime app).
From what I can see from my research, BlazeDS is the preferred way, but it involves Java and Java EE. Also, the latest Ruby results seem to be from 2009-2010, so they are likely outdated.
Are there any actively maintained Ruby/Rails solutions for integrating push notifications with Flex?
The current situation
Do you have to use Flex? HTML5 websockets is a nascent but growing technology and there are implementations now. Flex's days are numbered. Yet, websockets doesn't yet have native support in IE.
em-websocket is a ruby websocket server based on eventmachine. The service Pusher is based on it.
Faye is a websocket server and client. (Railscast)
There are other Ruby implementations such as Cramp and Socky.
If you're open to servers in other technologies such as Node, there are many with Ruby or Javascript clients ready to go.
Update: I might mention that I looked into doing something similar with Flex a while back, and got a copy of Flex on Rails. The book's server push example uses Juggernaut, which unfortunately has stopped further development. The author states that Server-Sent Events (SSEs) make Juggernaut redundant. All major browsers except IE support them natively, similar to the situation with websockets.
There are shims ("polyfills") that use javascript to bring these missing capabilities to the browsers. For example, the jQuery Graceful WebSocket is a jQuery plugin that implements a websocket client but falls back to AJAX polling so the functionality will still work in IE, just won't be quite as instant. Because it detects websocket support, as soon as a browser supports websockets they will be used.
Bridging the Gap
We seem to be caught in a transition period, where we are at the sunset era of Flash but not yet at broad support for its replacement technologies. There is one library that may bridge the gap: Socket.IO. This library selects the most capable technology transport at runtime. It will use Flash if present, but can also use websockets, AJAX long polling, AJAX multipart streaming, a "forever iframe" if necessary. This gives it broad browser support:
IE 5.5+
Safari 3+
Google Chrome 4+
Firefox 3+
Opera 10.61+
iPhone Safari
iPad Safari
Android Webkit
WebOS Webkit
This is actually broader compatibility than either Flash/Flex or WebSockets alone. Socket.IO is implemented in Javascript for both server and client, so you need a server-side Javascript runtime such as Node.
Possible solutions
While there don't seem to be many current references to a Rails 3 -> Flex solution (as you have found), it appears there is some traction with the combination of Ruby/Rails and Socket.IO.
If you want to add chat to a Rails app using Socket.IO, there's a nice reference blog post by Liam Kaufman who creates a chat app in Rails 3 using Socket.IO: http://liamkaufman.com/blog/2012/02/25/adding_real-time_to_rails_with_socket.IO_nodejs_and_backbonejs_with_demo/
There's also a socket.io gem which adds support to the Cramp server mentioned above.
There also seem to be other stackoverflow questions with others working on the Rails 3 and Socket.IO combination.
TL;DR summary
While there isn't much indication that folks are doing direct-to-Flex from Rails anymore, there are other solutions with the most promising being a combination of Rails and Socket.IO.
If you want to live within the Ruby world, you can use regular WebSockets to talk to a Flex application. It won't be pretty, but it would work, and you could avoid the Java back-end. This would be a lot more raw than telling BlazeDS to fling structures around, but it should be doable.
On the Flex client side, there is a library written by Kaazing, that is bundled with their WebSocket servers. Download one of their WebSocket servers, and in the client-libs folder, there should be a swc (with docs) that you can use to talk to em-websocket (or really, any websocket tech).
Now, all this being said, you won't have nearly the scaleability of BlazeDS or GraniteDS, but it should work for smaller implementations and demos.
You can use https://github.com/rubyamf/rubyamf or https://github.com/victorcoder/rubyamf_plugin
But you will be have problem with realtime messaging because rubyamf and rubyamf_plugin don't support RTMP.
You can use the RestfulX gem & Flex framework. That's what I use for Rails/Flex.

What WebSockets system should I use for this?

I'm building a Rails app where I need a real time commenting system. I'm going to use WebSockets, but I'm new to them and I'm kinda lost. I tried em-websockets and websocket-rails, but neither worked well with what I have to do. I also though of a Node.JS and Socket.io app, but I don't know how to start with that.
What I want to do is send a WebSocket message when a new comment is made on a post, on the create action of my CommentsController. I'll send a message containing the comment content and creator and the post ID.
Thanks in advance! :D
Sorry, but I dont think so. Be careful with WebSockets. It is fundamental concept that provides a very powerful mechanism.
Websockets is good for super, absolutely real-time applications like online games. For commenting system (even realtime) you dont need them, the AJAX is more then enought for this.
You could use a realtime hosted service if you don't want to deal with your own realtime infrastructure, fallbacks for older browsers, scaling complications etc.
I recently wrote a post on Smashing Mag on building a realtime commenting system. It uses PHP and Pusher (who I work for) but the separation between client and server should meant that you could use any backend technology/service. It also demonstrates how to progressively enhance your app.
The most commonly used self-hosted ruby technologies for realtime communication does seem to be Faye, as #Alfred suggested.
Just using websockets as the only available transport is not a good idea, because websockets are not yet supported in every browser. Luckily for example Faye does support multiple transports so that it will work in every browser. I also found this interesting video in the past explaining how you could use Faye in conjunction with RoR from RailsCast.

How to make webmachine play nice with websockets?

Webmachine seems like a great system to build REST web services, but I know it does not provide websocket compatibility. My question is rather straightforward : What would be a good approach to add websocket capabilities on top of a web service built with webmachine?
I'm running Misultin alongside Webmachine for that exact matter.
For easy use websockets in webmachine I implemented that by changing sources of webmachine (adding support mochiweb_websockets ) and mochiweb (add support secure websockets).
You can download from git full solution (webmachine with websockets support) by this link:
https://github.com/Dryymoon/webmachine.git
And by this link example usage of solution.
Or if want dig a little deeper:
I changed only two files of sources:
1) webmachine_decision_core.erl changed (add support websocket handler).
2) mochiweb_websocket.erl (add support secure websockets and patch existig).
Late answer, but just stumbled upon this, but another option is to run SimpleBridge (https://github.com/nitrogen/simple_bridge), which adds an abstraction layer (conditionally bypassed using webmachines routing system) which adds websocket support to any erlang webserver it supports (includes webmachine).

Simple web service solution for iOS and ruby on rails?

The architecture which iPhone works as client, communicating with back-end service by RESTful way,Ruby on Rails is good at building REST web service.
So just wonder if there is very simple open source project for this sort of solution available now ? ( Just like hello world.)
I've been looking in to this as well. The closest thing to a fully integrated solution on the Objective-C side I've seen is ObjectiveResource but it doesn't look very well maintained anymore.
You can use RestKit for object mapping.

Resources