Archive

Archive for January, 2009

Sockets/IRC using Flash/Openlaszlo without server side proxy

Written on January 22nd 2009, 02:01 by sYnie

some weeks ago I’ve been playing around with the possibility of flash of using sockets. I tried to connect to various services, but unless there is any crossdomain.xml on the server it is just impossible. Well, there is a way to use a server side proxy to create such connections, as it’s allowed to open sockets from the flash client to the same domain, but this isn’t always the best solution. For example if you want to connect to an IRC server, you will be limited to a few connections. Besides that, not everybody has the possibility to run a proxy server for such services.
After some hours of experiments, I got a solution. It’s not very nice and it’s questionable whether this could ever be used in productive environments – but it’s pretty nice to play with ;-)

In this example I used OpenLaszlo to do the flash part – but it can be easily reproduced with actionscript. Furthermore I decided to explain it with an IRC network and as for that (to keep it simple) I used a library to do the protocol stuff. But you can extend this to any service, that uses network connections.
It’s pretty simple:

  • First we create a Java Applet, which does all the socket stuff
  • This Applet will be signed to be able to open connections outside of its sandbox
  • Then the Flash Client will be designed
  • And after all that, a small set of Javascript Functions are needed to make them communicate

This is the example. It’s quick’n'dirty, but it works. You have to accept the Certificate. If you don’t the network connections won’t work.

Keep on reading for examples …
Read more…