sockjs / sockjs-ruby Goto Github PK
View Code? Open in Web Editor NEWWebSocket emulation - Ruby server
Home Page: http://sockjs.org
License: MIT License
WebSocket emulation - Ruby server
Home Page: http://sockjs.org
License: MIT License
Hi guys,
I've problem running simple sockjs-ruby server with rack 1.4.1 - my code
#!/usr/bin/env ruby
# encoding: utf-8
require "thin"
require "rack"
require "rack/sockjs"
require "eventmachine"
# Your custom app.
class MyHelloWorld
def call(env)
body = "This is the app, not SockJS."
headers = {
"Content-Type" => "text/plain; charset=UTF-8",
"Content-Length" => body.bytesize.to_s
}
[200, headers, [body]]
end
end
app = Rack::Builder.new do
# Run one SockJS app on /echo.
use SockJS, "/echo" do |connection|
connection.subscribe do |session, message|
session.send(message)
end
end
# ... and the other one on /close.
use SockJS, "/close" do |connection|
connection.session_open do |session|
session.close(3000, "Go away!")
end
end
# This app will run on other URLs than /echo and /close,
# as these has already been assigned to SockJS.
run MyHelloWorld.new
end
EM.run do
thin = Rack::Handler.get("thin")
thin.run(app.to_app, Port: 8081)
end
and after trying to run I'm encountering following error
/Users/null/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:82:in `block in use': undefined method `new' for SockJS:Module (NoMethodError)
from /Users/null/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:130:in `[]'
from /Users/null/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:130:in `block in to_app'
from /Users/null/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:130:in `each'
from /Users/null/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:130:in `inject'
from /Users/null/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:130:in `to_app'
from server/server.rb:46:in `block in <main>'
from /Users/null/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `call'
from /Users/null/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
from /Users/null/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
from server/server.rb:44:in `<main>'
How to fix that ?
There are some blank spots:
spec/sockjs/transport_spec.rb 100: # TODO 141: # TODO 145: # TODO 149: # TODO 153: # TODO spec/sockjs/transports/chunking_test_spec.rb 65: # TODO: test if Transport#handler(prefix) can find it (it can't). spec/sockjs/transports/jsonp_spec.rb 126: # TODO: test with invalid data like d=sth, we should get Broken encoding. spec/sockjs/transports/websocket_spec.rb 14: # TODO: This should be a mixin. 18: # TODO: In fact the first argument should always be the transport, 21: # TODO: Use Connection#create_session instead of spec/sockjs/transports/xhr_spec.rb 183: # TODO: Come up with a better way how to test it.
Plus all the pending specs and spec/sockjs/session_spec.rb
.
Running rspec spec
results in 17 errors. They don't occur the specs are run separately.
I'd really like to use sockjs in a Ruby project I'm working on, but I don't see the gem. I'm loathe to push your gem for you, or to include sockjs-ruby wholesale into my project.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.