README.md in tribe_em_amfsocket-0.0.2 vs README.md in tribe_em_amfsocket-0.0.3

- old
+ new

@@ -1,8 +1,9 @@ -# TribeEmAmfsocket +# Tribe EM AMF Socket -TODO: Write a gem description +This Ruby gem provides AMF Socket bindings for [Tribe EM] (https://github.com/chadrem/tribe_em "Tribe EM"). +Currently sending and receive messages is integrated (requests are not). ## Installation Add this line to your application's Gemfile: @@ -16,10 +17,32 @@ $ gem install tribe_em_amfsocket ## Usage -TODO: Write usage instructions here + # Create a custom connection actor class. + class EchoConnection < Tribe::EM::AmfSocket::Connection + private + + def on_post_init(event) + puts "Actor (#{identifier}) connected to client using thread (#{Thread.current.object_id})." + super + end + + def on_unbind(event) + puts "Actor (#{identifier}) disconnected from client using thread (#{Thread.current.object_id})." + super + end + + def on_receive_message(event) + puts "Actor (#{identifier}) received message (command=#{event.data.command}, params=#{event.data.params} using thread (#{Thread.current.object_id})." + write_message(event.data.command, event.data.params) + enqueue(:shutdown) + end + end + + # Create your server actor. + server = Tribe::EM::TcpServer.new('localhost', 9000, EchoConnection) ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`)