{"id":13544644,"url":"https://github.com/sebyx07/opal-express-socketio","last_synced_at":"2025-08-24T08:15:05.574Z","repository":{"id":49031726,"uuid":"216368741","full_name":"sebyx07/opal-express-socketio","owner":"sebyx07","description":"Opal Ruby + Express + Socket.io","archived":false,"fork":false,"pushed_at":"2022-12-11T10:06:49.000Z","size":1036,"stargazers_count":22,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-02T11:23:48.105Z","etag":null,"topics":["express","nodejs","opal","realtime","ruby","socketio","websockets"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/sebyx07.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}},"created_at":"2019-10-20T13:46:16.000Z","updated_at":"2022-05-19T14:36:56.000Z","dependencies_parsed_at":"2023-01-26T20:46:14.806Z","dependency_job_id":null,"html_url":"https://github.com/sebyx07/opal-express-socketio","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/sebyx07%2Fopal-express-socketio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebyx07%2Fopal-express-socketio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebyx07%2Fopal-express-socketio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebyx07%2Fopal-express-socketio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebyx07","download_url":"https://codeload.github.com/sebyx07/opal-express-socketio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222838581,"owners_count":17045301,"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":["express","nodejs","opal","realtime","ruby","socketio","websockets"],"created_at":"2024-08-01T11:00:51.860Z","updated_at":"2024-11-03T11:32:22.151Z","avatar_url":"https://github.com/sebyx07.png","language":"Ruby","readme":"# Opal implementation of a simple server with Express and Socket.io\n\n\nDemo https://opal-realtime-socket-express.herokuapp.com/\n\n### Run\n\nInstallation\n```bash\ngit clone https://github.com/sebyx07/opal-express-socketio.git opal-server\ncd opal-server\nbundle install \u0026\u0026 yarn install # install deps\n```\n\nUpdate index.html\n```js\nvar socket = io.connect('https://opal-realtime-socket-express.herokuapp.com', {transports:['websocket']});\n// with\nvar socket = io.connect('http://localhost:8000', {transports:['websocket']});\n```\n\n\n### Usage\n\n`rake` it's the default rake task that starts the server\n\ngo to http://localhost:8000\n\n\n```ruby\nServer.new(8000) do |s, io|\n  s # you can access express methods: with get, post, use, etc. Most is supported\n    # callbacks, you replace them with do; end blocks\n\n  io # you can use socket-io methods: on, emit etc. Most is supported\n     #  socket must be wrapped using Native()\nend\n```\n\n\n### Example server usage\n\n```ruby\nServer.new(8000) do |s, io|\n  # express part\n  s.use(Logger) # use middlewares\n  s.start! # start the server\n\n  s.get(\"/\") do |_, res| # handle get to root request\n    res.sendFile(s.view(\"index.html\")) # send the index html file\n  end\n\n  s.get(\"/:name\") do |req, res| # handle dynamic requests\n    res.send(req.params.name)\n  end\n\n  # socket io part\n  io.on 'connection' do |socket| # initialize socket io connection\n    socket = Native(socket) # if you have problems with apply for a object, just Native() it\n\n    socket.on('chat message') do |msg| # listen for messages\n      io.emit('chat message', msg) # send it back, to all clients\n    end\n\n    socket.on('disconnect') do # handle disconnect\n      p \"disconnect\"\n    end\n  end\nend\n```\n\n","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebyx07%2Fopal-express-socketio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebyx07%2Fopal-express-socketio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebyx07%2Fopal-express-socketio/lists"}