README.md in hara-0.2.1 vs README.md in hara-0.2.2
- old
+ new
@@ -1,17 +1,17 @@
# Hara
[![Gem Version](https://badge.fury.io/rb/hara.png)](http://badge.fury.io/rb/hara)
[![Build Status](https://travis-ci.org/jjyr/hara.png?branch=master)](https://travis-ci.org/jjyr/hara)
-Hara is a simple framework, help you build async & concurrent websocket server.
+Hara is a simple framework, help you build async-io & concurrent websocket server.
-Hara's async ability from [em-websocket](https://github.com/igrigorik/em-websocket),
+Hara's async-io ability from [em-websocket](https://github.com/igrigorik/em-websocket),
Hara's concurrent ability from [celluloid](https://github.com/celluloid/celluloid).
-Yes, hara is a combination of them, eventmachine and celluloid work well together :)
+Seems eventmachine and celluloid work well together :smile:
## Installation
Add this line to your application's Gemfile:
@@ -55,17 +55,18 @@
*start server*
`ruby test.rb`
`ruby test.rb -h` to view options
-## Other Usages & How it work
+## Full Usages
```ruby
require 'hara/base'
class Echo
- #include Hara::App, make you Echo class become Celluloid::Actor and per actor handle a socket
+ #include Hara::App, make you Echo class become Celluloid::Actor,
+ # and per actor handle a socket
include Hara::App
#Hara::App provide some callbacks
def after_connect
@@ -77,24 +78,42 @@
puts 'called when action comming'
end
define_action :echo do |str|
puts "#{client_ip} #{client_port}"
+ #send message to socket
socket.send str
end
+ define_action :exit do
+ puts "#{client_ip} exit"
+ # close client connection
+ close
+ end
+
def after_action action, *args
puts 'called when action complete'
end
+
+ def action_missing action, *args
+ socket.send 'error'
+ super
+ end
+
+ def on_close close_info
+ puts "#{client_ip} connection closed"
+ end
end
#if you require 'hara/base' you need start server you self, like below
Hara::Server.start 'localhost', '3000'
```
-## RoadMap
+## Client
js client is processing
+
+current format is JSON.stringify({action: 'echo',args:['hello world']})
## Contributing
1. Fork it
2. Feel free to send pull requests