amf_socket 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +18 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +38 -0
- data/amf_socket.gemspec +20 -0
- data/lib/amf_socket/amf_connection.rb +7 -0
- data/lib/amf_socket/amf_rpc_connection.rb +19 -0
- data/lib/amf_socket/exceptions.rb +4 -0
- data/lib/amf_socket/rpc_request.rb +51 -0
- data/lib/amf_socket/serializer.rb +9 -0
- data/lib/amf_socket/version.rb +3 -0
- data/lib/amf_socket.rb +11 -0
- metadata +98 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
amf_socket (0.0.1)
|
5
|
+
RocketAMF (>= 0.2.1)
|
6
|
+
eventmachine (>= 1.0.0.rc.4)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
RocketAMF (0.2.1)
|
12
|
+
eventmachine (1.0.0.rc.4)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
amf_socket!
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Chad Remesch
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# AMF Socket - Ruby
|
2
|
+
|
3
|
+
This library is an implementation of [AMF Socket](https://github.com/chadrem/amf_socket) for Ruby's EventMachine.
|
4
|
+
Currently it is in the early stages and the API is incomplete.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'amf_socket'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install amf_socket
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Currently this library is immature and the API is evolving.
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
|
26
|
+
1. Fork it
|
27
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
28
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
29
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
30
|
+
5. Create new Pull Request
|
31
|
+
|
32
|
+
## Copyright
|
33
|
+
|
34
|
+
Copyright (c) 2012 Chad Remesch. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'debugger'
|
8
|
+
rescue Exception
|
9
|
+
end
|
10
|
+
|
11
|
+
begin
|
12
|
+
Bundler.setup(:default, :development)
|
13
|
+
rescue Bundler::BundlerError => e
|
14
|
+
$stderr.puts(e.message)
|
15
|
+
$stderr.puts("Run `bundle install` to install missing gems")
|
16
|
+
exit e.status_code
|
17
|
+
end
|
18
|
+
|
19
|
+
task :environment do
|
20
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
21
|
+
require 'amf_socket'
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Start an IRB console with offier loaded'
|
25
|
+
task :console => :environment do
|
26
|
+
require 'irb'
|
27
|
+
|
28
|
+
ARGV.clear
|
29
|
+
|
30
|
+
IRB.start
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Start a test server'
|
34
|
+
task :harness => :environment do
|
35
|
+
EM.run do
|
36
|
+
EM.start_server('localhost', 9000, AmfSocket::AmfRpcConnection)
|
37
|
+
end
|
38
|
+
end
|
data/amf_socket.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/amf_socket/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Chad Remesch"]
|
6
|
+
gem.email = ["chad@remesch.com"]
|
7
|
+
gem.description = %q{Ruby implementation of AMF Socket}
|
8
|
+
gem.summary = %q{AMF Socket is a bi-directional RPC system for Adobe Flash (Actionscript) programs.}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "amf_socket"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = AmfSocket::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency('eventmachine', ['>= 1.0.0.rc.4'])
|
19
|
+
gem.add_dependency('RocketAMF', ['>= 0.2.1'])
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class AmfSocket::AmfRpcConnection < AmfSocket::AmfConnection
|
2
|
+
def receive_object(object)
|
3
|
+
request = nil
|
4
|
+
|
5
|
+
begin
|
6
|
+
request = AmfSocket::RpcRequest.new(object, self)
|
7
|
+
rescue AmfSocket::InvalidRequest => e
|
8
|
+
close_connection
|
9
|
+
return
|
10
|
+
end
|
11
|
+
|
12
|
+
receive_request(request)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Override this method in your subclass.
|
16
|
+
def receive_request(request)
|
17
|
+
request.reply('You should override AmfSocket::AmfRpcConenction in a subclass.')
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class AmfSocket::RpcRequest
|
2
|
+
attr_reader :amf_connection
|
3
|
+
attr_reader :state # Valid states: :initialized, replied.
|
4
|
+
|
5
|
+
def initialize(object, amf_connection)
|
6
|
+
raise RpcSocket::InvalidRequest unless validate_object(object)
|
7
|
+
|
8
|
+
@request_obj = object[:request]
|
9
|
+
@amf_connection = amf_connection
|
10
|
+
@state = :initialized
|
11
|
+
end
|
12
|
+
|
13
|
+
def message_id
|
14
|
+
return @request_obj[:messageId]
|
15
|
+
end
|
16
|
+
|
17
|
+
def command
|
18
|
+
return @request_obj[:command]
|
19
|
+
end
|
20
|
+
|
21
|
+
def params
|
22
|
+
return @request_obj[:params]
|
23
|
+
end
|
24
|
+
|
25
|
+
def reply(result)
|
26
|
+
return false if @state == :replied
|
27
|
+
|
28
|
+
object = {}
|
29
|
+
object[:type] = 'rpcResponse'
|
30
|
+
object[:response] = {}
|
31
|
+
object[:response][:messageId] = message_id
|
32
|
+
object[:response][:result] = result
|
33
|
+
|
34
|
+
@amf_connection.send_object(object)
|
35
|
+
|
36
|
+
return true
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def validate_object(object)
|
42
|
+
return false unless object.is_a?(Hash)
|
43
|
+
return false unless %(rpcRequest rpcResponse).include?(object[:type])
|
44
|
+
return false unless object[:request].is_a?(Hash)
|
45
|
+
return false unless object[:request][:command].is_a?(String)
|
46
|
+
return false unless object[:request][:params].is_a?(Hash)
|
47
|
+
return false unless object[:request][:messageId].is_a?(String)
|
48
|
+
|
49
|
+
return true
|
50
|
+
end
|
51
|
+
end
|
data/lib/amf_socket.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'eventmachine'
|
2
|
+
require 'rocketamf'
|
3
|
+
|
4
|
+
module AmfSocket; end
|
5
|
+
|
6
|
+
require 'amf_socket/version'
|
7
|
+
require 'amf_socket/amf_connection'
|
8
|
+
require 'amf_socket/amf_rpc_connection'
|
9
|
+
require 'amf_socket/rpc_request'
|
10
|
+
require 'amf_socket/serializer'
|
11
|
+
require 'amf_socket/exceptions'
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: amf_socket
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chad Remesch
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: eventmachine
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0.rc.4
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.0.rc.4
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: RocketAMF
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.2.1
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.2.1
|
46
|
+
description: Ruby implementation of AMF Socket
|
47
|
+
email:
|
48
|
+
- chad@remesch.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- Gemfile.lock
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- amf_socket.gemspec
|
60
|
+
- lib/amf_socket.rb
|
61
|
+
- lib/amf_socket/amf_connection.rb
|
62
|
+
- lib/amf_socket/amf_rpc_connection.rb
|
63
|
+
- lib/amf_socket/exceptions.rb
|
64
|
+
- lib/amf_socket/rpc_request.rb
|
65
|
+
- lib/amf_socket/serializer.rb
|
66
|
+
- lib/amf_socket/version.rb
|
67
|
+
homepage: ''
|
68
|
+
licenses: []
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
hash: -1947393351038552103
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
hash: -1947393351038552103
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 1.8.24
|
94
|
+
signing_key:
|
95
|
+
specification_version: 3
|
96
|
+
summary: AMF Socket is a bi-directional RPC system for Adobe Flash (Actionscript)
|
97
|
+
programs.
|
98
|
+
test_files: []
|