Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
--color
--require fuubar
--format Fuubar
--pattern **/*.rb
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# encoding: utf-8
source "https://rubygems.org"

gem 'corundum'
gem "thin"
gem "thin", ">=1.8.2"
gem "rack"
gem "faye-websocket"
gem "rake"

gemspec

group(:test) do
gem 'uuid'
gem 'rack-test'
gem "rspec"
gem 'fuubar'
end
133 changes: 54 additions & 79 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,104 +1,79 @@
PATH
remote: .
specs:
sockjs (0.3.4.0)
faye-websocket (~> 0.7.1)
sockjs (0.3.4.3)
faye-websocket (~> 0.11.3)
json
racc
rack
rack-mount (~> 0.8.3)
sorted_set
thin

GEM
remote: https://rubygems.org/
specs:
chunky_png (1.2.9)
compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
corundum (0.3.2)
bundler
compass (>= 0.12.1)
mailfactory (~> 1.4.0)
mattock (~> 0.7)
nokogiri
rdoc
rspec (>= 2.0)
sass (>= 3.1)
simplecov (>= 0.5.4)
yard
daemons (1.1.9)
diff-lcs (1.2.5)
docile (1.1.1)
eventmachine (1.0.3)
faye-websocket (0.7.1)
base64 (0.2.0)
daemons (1.4.1)
diff-lcs (1.5.1)
eventmachine (1.2.7)
faye-websocket (0.11.3)
eventmachine (>= 0.12.0)
websocket-driver (>= 0.3.1)
fssm (0.2.10)
fuubar (1.2.1)
rspec (~> 2.0)
rspec-instafail (~> 0.2.0)
ruby-progressbar (~> 1.0)
json (1.8.1)
macaddr (1.6.1)
systemu (~> 2.5.0)
mailfactory (1.4.0)
mime-types (>= 1.13.1)
mattock (0.7.0)
rake (~> 10.0)
tilt (> 0)
valise (>= 0.9.1)
mime-types (2.0)
mini_portile (0.5.2)
multi_json (1.8.2)
nokogiri (1.6.0)
mini_portile (~> 0.5.0)
rack (1.5.2)
websocket-driver (>= 0.5.1)
json (2.9.1)
macaddr (1.7.2)
systemu (~> 2.6.5)
racc (1.8.1)
rack (2.2.10)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-test (0.6.2)
rack (>= 1.0)
rake (10.1.0)
rdoc (4.0.1)
json (~> 1.4)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
rspec-instafail (0.2.4)
rspec-mocks (2.14.4)
ruby-progressbar (1.2.0)
sass (3.2.12)
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
systemu (2.5.2)
thin (1.6.1)
daemons (>= 1.0.9)
eventmachine (>= 1.0.0)
rack (>= 1.0.0)
tilt (2.0.0)
uuid (2.3.7)
rack-test (2.2.0)
rack (>= 1.3)
rake (13.2.1)
rbtree (0.4.6)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.2)
set (1.1.1)
sorted_set (1.0.3)
rbtree
set (~> 1.0)
systemu (2.6.5)
thin (1.8.2)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
uuid (2.3.9)
macaddr (~> 1.0)
valise (1.1.1)
websocket-driver (0.3.1)
yard (0.8.7.3)
websocket-driver (0.7.7)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)

PLATFORMS
ruby
arm64-darwin-21
arm64-darwin-22
arm64-darwin-24

DEPENDENCIES
corundum
faye-websocket
fuubar
rack
rack-test
rake
rspec
sockjs!
thin
thin (>= 1.8.2)
uuid

BUNDLED WITH
2.6.3
43 changes: 3 additions & 40 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,46 +1,9 @@
# vim: set ft=ruby :
require 'corundum/tasklibs'

module Corundum
Corundum::register_project(__FILE__)

core = Core.new

core.in_namespace do
GemspecFiles.new(core)
QuestionableContent.new(core) do |dbg|
dbg.words = %w{debug! debugger}
end
rspec = RSpec.new(core)
cov = SimpleCov.new(core, rspec) do |cov|
cov.threshold = 70
cov.coverage_filter = proc do |path|
/\.rb$/ =~ path and /version/ !~ path
end
end

gem = GemBuilding.new(core)
cutter = GemCutter.new(core,gem)
email = Email.new(core)
vc = Git.new(core) do |vc|
vc.branch = "master"
end

yd = YARDoc.new(core)

docs = DocumentationAssembly.new(core, yd, rspec, cov)

pages = GithubPages.new(docs)
end
end

task :default => [:release, :publish_docs]


# Get list of all the tests in format for TODO.todo.
require 'socket'
Bundler.require(:default, :development)

task :unpack_tests do
version = "0.2.1"
version = "0.3.4"

tests = {}
File.foreach("protocol/sockjs-protocol-#{version}.py").each_with_object(tests) do |line, buffer|
Expand Down
11 changes: 4 additions & 7 deletions lib/rack/sockjs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require "sockjs/servers/request"
require "sockjs/servers/response"

require "rack"
require 'rack/mount'

require 'sockjs/duck-punch-rack-mount'
Expand Down Expand Up @@ -74,21 +75,17 @@ def initialize(options)
end

def call(env)
prefix = env["PATH_INFO"]
method = env["REQUEST_METHOD"]
prefix = env[Rack::PATH_INFO]
method = env[Rack::REQUEST_METHOD]
body = <<-HTML
<!DOCTYPE html>
<html>
<body>
<h1>Handler Not Found</h1>
<ul>
<li>Prefix: #{prefix.inspect}</li>
<li>Method: #{method.inspect}</li>
</ul>
</body>
</html>
HTML
::SockJS.debug "Handler not found!"
::SockJS.debug "Handler not found! #{method} #{prefix}"
[404, {"Content-Type" => "text/html; charset=UTF-8", "Content-Length" => body.bytesize.to_s}, [body]]
end
end
Expand Down
7 changes: 4 additions & 3 deletions lib/sockjs/servers/request.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# encoding: utf-8

require "uri"
require "rack"

module SockJS
#This is the SockJS wrapper for a Rack env hash-like. Currently it requires
Expand All @@ -17,13 +18,13 @@ def initialize(env)
# request.path_info
# => /echo/abc
def path_info
env["PATH_INFO"]
env[Rack::PATH_INFO]
end

# request.http_method
# => "GET"
def http_method
env["REQUEST_METHOD"]
env[Rack::REQUEST_METHOD]
end

def async_callback
Expand Down Expand Up @@ -119,7 +120,7 @@ def content_type

def callback
callback = self.query_string["callback"] || self.query_string["c"]
URI.unescape(callback) if callback
URI.decode_www_form_component(callback) if callback
end

def keep_alive?
Expand Down
33 changes: 33 additions & 0 deletions lib/sockjs/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ def close(status = nil, message = nil)
def set_heartbeat_timer
_set_heartbeat_timer
end

def closed?
false
end

def suspended?
false
end
end

state :Attached do
Expand Down Expand Up @@ -139,6 +147,15 @@ def close(status = 1002, message = "Connection interrupted")
def set_heartbeat_timer
_set_heartbeat_timer
end


def closed?
false
end

def suspended?
false
end
end

state :Suspended do
Expand Down Expand Up @@ -187,6 +204,14 @@ def close(status = 1002, message = "Connection interrupted")
def set_heartbeat_timer
_set_heartbeat_timer
end

def closed?
false
end

def suspended?
true
end
end

state :Closed do
Expand Down Expand Up @@ -214,6 +239,14 @@ def close(status=nil, message=nil)
#can be called from faye onclose hook
end

def closed?
true
end

def suspended?
false
end

def set_heartbeat_timer
SockJS.debug "trying to setup heartbeat on closed session!"
end
Expand Down
6 changes: 3 additions & 3 deletions lib/sockjs/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(map)
attr_reader :method_map

def call(env)
app = @method_map.fetch(env["REQUEST_METHOD"])
app = @method_map.fetch(env[Rack::REQUEST_METHOD])
app.call(env)
rescue KeyError
::SockJS.debug "Method not supported!"
Expand Down Expand Up @@ -133,7 +133,7 @@ def format_frame(session, payload)
def call(env)
@remote_addr = env["REMOTE_ADDR"]
@http_origin = env["HTTP_ORIGIN"]
SockJS.debug "Request for #{self.class}: #{env["REQUEST_METHOD"]}/#{env["PATH_INFO"]}"
SockJS.debug "Request for #{self.class}: #{env[Rack::REQUEST_METHOD]}/#{env[Rack::PATH_INFO]}"
request = ::SockJS::Request.new(env)
EM.next_tick do
handle(request)
Expand Down Expand Up @@ -202,7 +202,7 @@ def self.routing_prefix

class Transport < SessionEndpoint
def handle_request(request)
SockJS::debug({:Request => request, :Transport => self}.inspect)
SockJS.debug({:Request => request, :Transport => self}.inspect)

response = build_response(request)
session = get_session(response)
Expand Down
Loading