{"id":13483712,"url":"https://github.com/foi/crystal-json-socket","last_synced_at":"2026-02-20T10:04:04.510Z","repository":{"id":137137379,"uuid":"139826575","full_name":"foi/crystal-json-socket","owner":"foi","description":" JSON-socket client \u0026 server implementation. Inspired by and compatible with sebastianseilund/node-json-socket","archived":false,"fork":false,"pushed_at":"2023-02-05T09:39:02.000Z","size":33,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-27T14:47:38.876Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/foi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-07-05T09:27:28.000Z","updated_at":"2025-02-20T15:51:36.000Z","dependencies_parsed_at":"2024-01-27T09:10:04.224Z","dependency_job_id":"266d8df8-a98a-4ab9-bad3-3d58381bbbc2","html_url":"https://github.com/foi/crystal-json-socket","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/foi/crystal-json-socket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foi%2Fcrystal-json-socket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foi%2Fcrystal-json-socket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foi%2Fcrystal-json-socket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foi%2Fcrystal-json-socket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foi","download_url":"https://codeload.github.com/foi/crystal-json-socket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foi%2Fcrystal-json-socket/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29647768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T09:27:29.698Z","status":"ssl_error","status_checked_at":"2026-02-20T09:26:12.373Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-07-31T17:01:14.454Z","updated_at":"2026-02-20T10:04:04.495Z","avatar_url":"https://github.com/foi.png","language":"Crystal","funding_links":[],"categories":["Network Protocols"],"sub_categories":[],"readme":"# crystal json-socket ![master branch](https://github.com/foi/crystal-json-socket/actions/workflows/ci.yml/badge.svg)\n\n\nJSON-socket client \u0026 server implementation. Inspired by and compatible with  [sebastianseilund/node-json-socket](https://github.com/sebastianseilund/node-json-socket/) and\n[ruby json-socket](https://github.com/foi/ruby-json-socket)\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n```yaml\ndependencies:\n  json-socket:\n    github: foi/crystal-json-socket\n```\n\n## Usage\n\nserver.cr\n\n```crystal\nrequire \"json-socket\"\n\nstruct CustomJSONSocketServer\n\n  include JSONSocket::Server\n\n  def on_message(message, socket)\n    puts message\n    result = (message[\"a\"].as_i + message[\"b\"].as_i) * message[\"b\"].as_i * message[\"a\"].as_i\n    self.send_end_message({ :result =\u003e result}, socket)\n  end\n\n  # Additionally you can define a custom on_error handler\n  def on_error(ex)\n    puts \"#{ex.message}\"\n  end\n\nend\n\nserver = CustomJSONSocketServer.new(\"127.0.0.1\", 1234) # OR CustomJSONSocketServer.new(unix_socket: \"/tmp/json-socket-server.sock\", delimeter: \"µ\")\nserver.listen\n```\n\nclient.cr\n\n```crystal\nrequire \"json-socket\"\nto_server = JSONSocket::Client.new(host: \"127.0.0.1\", port: 1234) # OR JSONSocket::Client.new(unix_socket: \"/tmp/json-socket-server.sock\", delimeter: \"µ\")\nresult = to_server.send({ a: 12, b: 8})\nif (result)\n  puts result\nend\n```\n\nclient.cr with timeouts in seconds\n\n```crystal\nrequire \"json-socket\"\nto_server = JSONSocket::Client.new(host: \"127.0.0.1\", port: 1234, read_timeout: 10, write_timeout: 5) # OR JSONSocket::Client.new(unix_socket: \"/tmp/json-socket-server.sock\", delimeter: \"µ\", read_timeout: 10, write_timeout: 5)\nresult = to_server.send({ a: 12, b: 8})\nif (result)\n  puts result\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoi%2Fcrystal-json-socket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoi%2Fcrystal-json-socket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoi%2Fcrystal-json-socket/lists"}