{"id":13529614,"url":"https://github.com/videlalvaro/gifsockets","last_synced_at":"2025-05-16T13:05:07.474Z","repository":{"id":4662613,"uuid":"5808540","full_name":"videlalvaro/gifsockets","owner":"videlalvaro","description":"Real Time communication library using Animated Gifs as a transport™","archived":false,"fork":false,"pushed_at":"2012-09-19T19:05:06.000Z","size":1174,"stargazers_count":1849,"open_issues_count":2,"forks_count":100,"subscribers_count":112,"default_branch":"master","last_synced_at":"2025-05-16T13:05:01.413Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/videlalvaro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-14T11:39:00.000Z","updated_at":"2025-05-15T16:21:55.000Z","dependencies_parsed_at":"2022-07-05T13:09:29.963Z","dependency_job_id":null,"html_url":"https://github.com/videlalvaro/gifsockets","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/videlalvaro%2Fgifsockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/videlalvaro%2Fgifsockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/videlalvaro%2Fgifsockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/videlalvaro%2Fgifsockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/videlalvaro","download_url":"https://codeload.github.com/videlalvaro/gifsockets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535827,"owners_count":22087399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:00:37.871Z","updated_at":"2025-05-16T13:05:07.412Z","avatar_url":"https://github.com/videlalvaro.png","language":"Java","funding_links":[],"categories":["Utilities","Java","III. Network and Integration","网络编程"],"sub_categories":["3. Message, message broker and message queue","Spring Cloud框架"],"readme":"# gifsockets\n\n\"This library is the websockets of the '90s\" - Somebody at Hacker News.\n\nThis library shows how to achieve realtime text communication using GIF images as transport.\n\n![Mind Blown](https://raw.github.com/videlalvaro/gifsockets/master/doc/mybrain.gif)\n\nThe interesting part is that you can even use IE6 with this library and get the data in Real Time (TM).\n\nOf course this should have been delivered as an April's Fools joke but sadly we are in mid September here in the northern hemisphere.\n\nSee it in action in this video: [https://vimeo.com/49447841](https://vimeo.com/49447841).\n\n## How does it work\n\nThe 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.\n\nPretty simple uh!\n\nAnd yes. It works in IE6.\n\n## Usage\n\nThe usage now is a bit rudimentary and manual. Feel free to improve it and send a PR.\n\n```bash\n$ git clone git://github.com/videlalvaro/gifsockets.git\n$ cd gifsockets\n$ lein deps\n% lein repl\n```\n\nThen perform the following commands on the Clojure REPL.\n\n```clojure\n;; in the repl do the following to import the libs\n(use 'gifsockets.core)\n(use 'gifsockets.server)\n;;\n;;Then we declare the tcp server\n(def server (tcp-server :port 8081 :handler gif-handler))\n(start2 server)\n;; wait for a browser connection on port 8081\n;; go and open http://localhost:8081/ in Safari or IE6\n;; In Chrome it works a bit laggy and in Firefox it doesn't work at all\n;;\n;; Now let's create the gif encoder that we use to write messages to the browser.\n(def encoder (create-gif (.getOutputStream client)))\n;;\n;;Now we are ready to send messages to that browser client\n(add-message encoder \"Hello gif-sockets\")\n;; now you should see a GIF image with the new message on it.\n(add-message encoder \"Zup zup zup\")\n(add-message encoder \"And so forth\")\n;;\n;; Now let's clean up and close the connection\n(.finish encoder)\n(.close client)\n```\n\nAs you can see from the code this handles only one connection in what is called  an UPoC (Uber Proof Of Concept).\n\n## Possible uses:\n\nAll 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.\n\nOr what about progress bars for stuff that your server is doing in the background, say, while it resizes an image?\n\nYes. You need _gifsockets_.\n\n## NOTE:\n\nIf you need a good library for real time communications on the web then I would recommend using [sockjs](https://github.com/sockjs).\n\n## License\n\nCopyright © 2012 Alvaro Videla\n\nThe following classes:\n\n- AnimatedGifEncoder.java\n- GifDecoder.java\n- LZWEncoder.java\n- NeuQuant.java\n\nWere taken from this website: [http://www.fmsware.com/stuff/gif.html](http://www.fmsware.com/stuff/gif.html).\n\nAnd the server code was taken from here [https://github.com/weavejester/tcp-server](https://github.com/weavejester/tcp-server)\n\nThe awesome image that illustrates this page was given by the internet.\n\nDistributed under the Eclipse Public License, the same as Clojure.\n\n## CREDITS\n\nI've stole this idea (ehem, took inspiration) from a [chat](http://zesty.ca/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.\n\nThanks [simonw](http://news.ycombinator.com/user?id=simonw) for posting the link to the original chat.\n\n- [@old_sound](https://twitter.com/old_sound).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvidelalvaro%2Fgifsockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvidelalvaro%2Fgifsockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvidelalvaro%2Fgifsockets/lists"}