• Stars
    star
    1,805
  • Rank 24,812 (Top 0.6 %)
  • Language
    Java
  • Created over 11 years ago
  • Updated over 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Real Time communication library using Animated Gifs as a transport™

gifsockets

"This library is the websockets of the '90s" - Somebody at Hacker News.

This library shows how to achieve realtime text communication using GIF images as transport.

Mind Blown

The interesting part is that you can even use IE6 with this library and get the data in Real Time (TM).

Of course this should have been delivered as an April's Fools joke but sadly we are in mid September here in the northern hemisphere.

See it in action in this video: https://vimeo.com/49447841.

How does it work

The idea is pretty simple. We use Animated Gif images to stream data in real time to the browser. Since a gif image doesn't specify how many frames it has, once the browser opens it, it will keep waiting for new frames until you send the bits indicating that there's no more image to fetch.

Pretty simple uh!

And yes. It works in IE6.

Usage

The usage now is a bit rudimentary and manual. Feel free to improve it and send a PR.

$ git clone git://github.com/videlalvaro/gifsockets.git
$ cd gifsockets
$ lein deps
% lein repl

Then perform the following commands on the Clojure REPL.

;; in the repl do the following to import the libs
(use 'gifsockets.core)
(use 'gifsockets.server)
;;
;;Then we declare the tcp server
(def server (tcp-server :port 8081 :handler gif-handler))
(start2 server)
;; wait for a browser connection on port 8081
;; go and open http://localhost:8081/ in Safari or IE6
;; In Chrome it works a bit laggy and in Firefox it doesn't work at all
;;
;; Now let's create the gif encoder that we use to write messages to the browser.
(def encoder (create-gif (.getOutputStream client)))
;;
;;Now we are ready to send messages to that browser client
(add-message encoder "Hello gif-sockets")
;; now you should see a GIF image with the new message on it.
(add-message encoder "Zup zup zup")
(add-message encoder "And so forth")
;;
;; Now let's clean up and close the connection
(.finish encoder)
(.close client)

As you can see from the code this handles only one connection in what is called an UPoC (Uber Proof Of Concept).

Possible uses:

All joking aside I think this is a very low tech way to have say, a website where you could tail logs for instance and you need to do it with a browser that have zero websockets support or something like that.

Or what about progress bars for stuff that your server is doing in the background, say, while it resizes an image?

Yes. You need gifsockets.

NOTE:

If you need a good library for real time communications on the web then I would recommend using sockjs.

License

Copyright © 2012 Alvaro Videla

The following classes:

  • AnimatedGifEncoder.java
  • GifDecoder.java
  • LZWEncoder.java
  • NeuQuant.java

Were taken from this website: http://www.fmsware.com/stuff/gif.html.

And the server code was taken from here https://github.com/weavejester/tcp-server

The awesome image that illustrates this page was given by the internet.

Distributed under the Eclipse Public License, the same as Clojure.

CREDITS

I've stole this idea (ehem, took inspiration) from a chat a colleague showed me like three years ago. It wasn't open source back then and I was always wondering how to implement something like that. So kudos to Ka-Ping Yee, who had the original idea.

Thanks simonw for posting the link to the original chat.

More Repositories

1

rabbitmq-chat

A Web chat implemented with RabbitMQ and Websockets
JavaScript
157
star
2

gen_microservice

Microservices for Erlang
Erlang
93
star
3

rabbit-internals

Documentation about the RabbitMQ internals
89
star
4

clochure

Clochure - A better Clojure
Java
85
star
5

rmq_patterns

Implementation of several messaging patterns with RabbitMQ and AMQP
Erlang
79
star
6

phacterl

The Actor Model in PHP
PHP
76
star
7

erlang-prime-sieve

Naive Parallel Prime Numbers Sieve
Erlang
37
star
8

RabbitMqBundle

RabbitMQ Bundle for the Symfony2 web framework
PHP
35
star
9

cloudstagram

Sample Instagram Clone wannabe website for Cloud Foundry
JavaScript
34
star
10

rabbitmq-websockets

RabbitMQ Plugin that bridges AMQP to Websockets
Erlang
32
star
11

mypeb

PHP Erlang Bridge
HTML
26
star
12

closerl

Clojure Erlang Bridge using JInterface
Clojure
23
star
13

rabbitmq-recent-history-exchange-elixir

The Recent History Exchange Implemented in Elixir
Elixir
18
star
14

azserverless

PHP Custom Handler for Azure Functions Serverless
PHP
16
star
15

rabbitmq-stream

RabbitMQ Stream plugin for message distribution aka queue sharding
Erlang
15
star
16

InspectorD

python server to inspect php sessions
Python
14
star
17

cloudfoundry-octopress

Deploy your octopress blogs to Cloud Foundry
Ruby
12
star
18

tamedrabbit

Shell
12
star
19

claude

Utilities to connect Clojure with Cloud Foundry
Clojure
12
star
20

number-theory-and-computing

Readings in Number Theory and Computing
CSS
12
star
21

rmq_msmq

RabbitMQ Microsoft MQ bridge
F#
10
star
22

msg_store_bitcask_index

RabbitMQ message store index with Bitcask Backend
Erlang
9
star
23

cloudfoundry-clojure-demo

Demo for Clojure integration with Cloud Foundry using claude
Clojure
8
star
24

elixir_wrapper

Wrapper for Elixir Lang to write RabbitMQ plugins
7
star
25

rabbitmq-global-fanout-exchange

RabbitMQ Global Fanout Exchage - Fanouts messages to all queues
Erlang
6
star
26

phpcask

PHP Client for the Bitcask K/V store
PHP
6
star
27

sfTwigPlugin

Symfony Plugin to enable Twig usage in templates.
PHP
6
star
28

rmq_ws_test

Sample project for the RabbitMQ Websockets Plugin
Erlang
5
star
29

Enable-Sites

Manage apache2 virtual hosts in Mac ala Ubuntu:
Shell
4
star
30

todos_hackday

Hackday app using Webmachine and Ember.js
Erlang
4
star
31

upload_image

How to upload an image to Azure Blog Storage using Azure Functions
JavaScript
3
star
32

erlang_credis

Redis C Driver for Erlang based on credis
C
3
star
33

fabric-kafka-sample

Java
3
star
34

ServerlessComputer

A Serverless Computer running on Azure Functions
JavaScript
2
star
35

thanksgiving

Demo nodejs app that consumes the Instagram Api
JavaScript
2
star
36

misultin_wrapper

Misultin web server wrapper to be used for RabbitMQ Plugin Development
2
star
37

avRedisLoggerPlugin

Sample symfony logger
PHP
2
star
38

bitcask_wrapper

Bitcask wrapper to be used to build RabbitMQ plugins
2
star
39

rabbitmq-es

Spanish Translation of www.rabbitmq.com
1
star
40

phone-guide

sample project showing how to test Java classes from ScalaCheck
Scala
1
star
41

wolfskin

Clojure
1
star
42

videlalvaro.github.io

My own blog
CSS
1
star
43

panopticore

1
star
44

test-app

PHP
1
star
45

eleveldb_wrapper

Eleveldb wrapper for RabbitMQ plugins
Makefile
1
star
46

scalable-web-architectures

Repository for my “Scalable Web Architectures” tution during my second semester of my master studies at the University of Applied Science in Salzburg.
JavaScript
1
star
47

gen_bunny

An RabbitMQ client library for erlang which aims at being easy to use for simple publisher and subscriber applications.
Erlang
1
star