{"id":19819231,"url":"https://github.com/minoritea/drunkmonkey","last_synced_at":"2025-06-17T23:36:12.035Z","repository":{"id":11298746,"uuid":"13713304","full_name":"minoritea/drunkmonkey","owner":"minoritea","description":null,"archived":false,"fork":false,"pushed_at":"2013-12-27T04:58:38.000Z","size":186,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-05T06:56:13.739Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/minoritea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-20T03:59:58.000Z","updated_at":"2013-12-27T04:58:39.000Z","dependencies_parsed_at":"2022-09-16T19:22:37.713Z","dependency_job_id":null,"html_url":"https://github.com/minoritea/drunkmonkey","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/minoritea/drunkmonkey","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minoritea%2Fdrunkmonkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minoritea%2Fdrunkmonkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minoritea%2Fdrunkmonkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minoritea%2Fdrunkmonkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minoritea","download_url":"https://codeload.github.com/minoritea/drunkmonkey/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minoritea%2Fdrunkmonkey/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260458535,"owners_count":23012495,"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-11-12T10:18:17.677Z","updated_at":"2025-06-17T23:36:07.025Z","avatar_url":"https://github.com/minoritea.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DrunkMonkey\n\n[![Build Status](https://travis-ci.org/minoritea/drunkmonkey.png?branch=master)](https://travis-ci.org/minoritea/drunkmonkey)\n\nDrunkMonkey is a rack middleware providing realtime two-way http communication with API for [Portal](https://github.com/flowersinthesand/portal/ \"Portal\").\n\n## Supported servers\nYou should use servers which supports Rack hijacking API, such as follows:\n- Puma\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'drunkmonkey'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install drunkmonkey\n\n## Usage\n\nAdd DrunkMonkey::Builder to Rack application by **use** method.\n\nPlain Rack:\n```ruby\napp = Rack::Builder.new do\n  use DrunkMonkey::Middleware do\n    on :message do |socket, message|\n      socket.push \"ECHO: #{message}\"\n    end\n  end\nend\n\nrun app\n```\n\nSinatra:\n```ruby\nrequire \"sinatra\"\n\nuse DrunkMonkey::Middleware do\n  on :message do |socket, message|\n    socket.push \"ECHO: #{message}\"\n  end\nend\n```\nNote: the passed block will be executed once when *use* is called at first.\n\nThen, include [Portal](https://github.com/flowersinthesand/portal/ \"Portal\") to HTML and initialize it as follows.\n\n```html\n\u003cscript src=\"/portal.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n/*\n * Following option is a hack to switch protocols automatically\n * when the connection cannot be established.\n */\nvar options = {\n    transports:[\"ws\",\"longpollajax\"],\n    reconnect:function(lastDelay,attempts){\n      if(options.transports.length \u003e 1)\n        options.transports.shift();\n      return 2 * (lastDelay || 100);},\n    prepare:function(connect,disconnect,opts){\n      opts.transports = options.transports;connect();}\n};\n\n//Add above options and drunkmonkey's path; default is \"/drunkmonkey\".\nvar socket = portal.open(\"/drunkmonkey\",options).on(\"open\",function(){\n  //Add you event.\n  socket.send(\"Hello!\");\n});\n\u003c/script\u003e\n```\n\nNote: in current version, supported transports by Drunkmonkey are websocket and long-poll ajax only.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminoritea%2Fdrunkmonkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminoritea%2Fdrunkmonkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminoritea%2Fdrunkmonkey/lists"}