Sha256: 1ca29325a7bedae7178ad0baee82132a547ff094e1e4f9e6fd68345248fb8e9b
Contents?: true
Size: 591 Bytes
Versions: 6
Compression:
Stored size: 591 Bytes
Contents
# frozen_string_literal: true require 'bundler/setup' require 'polyphony/http' require 'localhost/authority' def ws_handler(conn) while (msg = conn.recv) conn << "you said: #{msg}" end end authority = Localhost::Authority.fetch opts = { reuse_addr: true, dont_linger: true, upgrade: { websocket: Polyphony::Websocket.handler(&method(:ws_handler)) }, secure_context: authority.server_context } puts "pid: #{Process.pid}" puts 'Listening on port 1234...' Polyphony::HTTP::Server.serve('0.0.0.0', 1234, opts) do |req| req.respond("Hello world!\n") end
Version data entries
6 entries across 6 versions & 2 rubygems