liehann / web-socket-ruby Goto Github PK
View Code? Open in Web Editor NEWThis project forked from gimite/web-socket-ruby
HTML5 Web Socket server/client implementation in Ruby
This project forked from gimite/web-socket-ruby
HTML5 Web Socket server/client implementation in Ruby
* How to run sample - Run sample Web Socket server (echo server) with: $ ruby samples/echo_server.rb localhost 10081 - Run sample Web Socket client and type something: $ ruby samples/stdio_client.rb ws://localhost:10081 Ready hoge Sent: "hoge" Received: "hoge" * Usage example Server: # Runs the server at port 10081. It allows connections whose origin is example.com. server = WebSocketServer.new(:port => 10081, :accepted_domains => ["example.com"]) server.run() do |ws| # The block is called for each connection. # Checks requested path. if ws.path == "/" # Call ws.handshake() without argument first. ws.handshake() # Receives one message from the client as String. while data = ws.receive() puts(data) # Sends the message to the client. ws.send(data) end else # You can call ws.handshake() with argument to return error status. ws.handshake("404 Not Found") end end Client: # Connects to Web Socket server at host example.com port 10081. client = WebSocket.new("ws://example.com:10081/") # Sends a message to the server. client.send("Hello") # Receives a message from the server. data = client.receive() puts(data) * Supported WebSocket protocol versions WebSocketServer class (server) accepts version hixie-75, hixie-76, hybi-07, hybi-10. WebSocket class (client) speaks version hixie-76. * Tips: JavaScript client implementation Google Chrome Dev Channel natively supports Web Socket. For other browsers, you can use an implementation using Flash: http://github.com/gimite/web-socket-js/tree/master * License New BSD License.
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.