{"id":13750636,"url":"https://github.com/Asmod4n/mruby-wslay","last_synced_at":"2025-05-09T15:32:10.879Z","repository":{"id":76216601,"uuid":"38917294","full_name":"Asmod4n/mruby-wslay","owner":"Asmod4n","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-16T20:57:55.000Z","size":59,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-02T16:54:57.029Z","etag":null,"topics":["mruby","websockets"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Asmod4n.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-11T07:03:47.000Z","updated_at":"2024-03-16T17:58:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"4a61cede-ba01-4815-b296-a852463df510","html_url":"https://github.com/Asmod4n/mruby-wslay","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/Asmod4n%2Fmruby-wslay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-wslay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-wslay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-wslay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Asmod4n","download_url":"https://codeload.github.com/Asmod4n/mruby-wslay/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253275619,"owners_count":21882340,"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":["mruby","websockets"],"created_at":"2024-08-03T08:00:43.230Z","updated_at":"2025-05-09T15:32:10.582Z","avatar_url":"https://github.com/Asmod4n.png","language":"C","readme":"# mruby-wslay\n\nwslay is a callback based WebSocket Client and Server library written in C, it doesn't come with a event loop or does I/O operations on its own. https://github.com/tatsuhiro-t/wslay\n\nThe following callbacks are exposed in this wrapper\n\n```ruby\nwslay_callbacks = Wslay::Event::Callbacks.new\n\nwslay_callbacks.recv_callback do |buf, len|\n  # when wslay wants to read data\n  # buf is a cptr, if your I/O gem can write to a C pointer you have to write at most len bytes into it\n  # and return the bytes written\n  # or else return a mruby String or a object which can be converted into a String via to_str\n  # and be up to len bytes long\n  # the I/O object must be in non blocking mode and raise EAGAIN/EWOULDBLOCK when there is nothing to read\nend\n\nwslay_callbacks.on_msg_recv_callback do |msg|\n  # when a WebSocket msg is fully recieved this callback is called\n  # you get a Wslay::Event::OnMsgRecvArg Struct back with the following fields\n  # :rsv =\u003e reserved field from WebSocket spec, there are Wslay.get_rsv1/2/3 helper methods\n  # :opcode =\u003e :continuation_frame, :text_frame, :binary_frame, :connection_close, :ping or\n  # :pong, Wslay.is_ctrl_frame? helper method is provided too\n  # :msg =\u003e the message revieced\n  # :status_code =\u003e :normal_closure, :going_away, :protocol_error, :unsupported_data, :no_status_rcvd,\n  # :abnormal_closure, :invalid_frame_payload_data, :policy_violation, :message_too_big, :mandatory_ext,\n  # :internal_server_error, :tls_handshake\n  # to_str =\u003e returns the message revieced\nend\n\nwslay_callbacks.send_callback |buf|\n  # when there is data to send, you have to return the bytes send here\n  # the I/O object must be in non blocking mode and raise EAGAIN/EWOULDBLOCK when sending would block\nend\n```\n\nHow to setup\n```ruby\nclient = Wslay::Event::Client.new wslay_callbacks\n```\n\nTo queue a message for sending\n```ruby\nclient.queue_msg(\"hello world\", #optional :opcode)\n```\n\nTo queue a close message\n```ruby\nclient.queue_close(:status_code, #optional reason)\n```\n\nFor a fully working example: https://github.com/Asmod4n/mruby-websockets/blob/master/mrblib/client.rb\n\nAcknowledgements\n================\nThis is using code from https://github.com/tatsuhiro-t/wslay\n\nThe MIT License\n\nCopyright (c) 2011, 2012, 2015 Tatsuhiro Tsujikawa\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["Distributed Systems"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAsmod4n%2Fmruby-wslay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAsmod4n%2Fmruby-wslay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAsmod4n%2Fmruby-wslay/lists"}