rubyfox-client 0.0.1-java → 0.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -23,7 +23,32 @@ Or install it yourself as:
23
23
 
24
24
  == Usage
25
25
 
26
- See examples/ for usage.
26
+ require 'rubyfox/client'
27
+
28
+ ARGV.size == 3 or abort "usage: simple.rb username password zone"
29
+
30
+ Rubyfox::Client.boot!
31
+
32
+ client = Rubyfox::Client.new
33
+ client.on_event :connection do |event|
34
+ p :connected!
35
+ client.send :login, *ARGV
36
+ end
37
+ client.on_event :login do |event|
38
+ p :login => event.arguments["zone"]
39
+ client.disconnect
40
+ end
41
+ client.on_event :login_error do |event|
42
+ p :login_failed
43
+ client.disconnect
44
+ end
45
+ client.on_event :connection_lost do |event|
46
+ p :disconnected
47
+ client.exit
48
+ end
49
+ client.connect
50
+
51
+ See https://github.com/neopoly/rubyfox-client/tree/master/examples for more examples.
27
52
 
28
53
  == TODO
29
54
 
@@ -0,0 +1,41 @@
1
+ require 'rubyfox/client'
2
+
3
+ unless ARGV.size == 3
4
+ abort "usage: #{$0} username password zone"
5
+ end
6
+
7
+ unless ENV['SF_DIR']
8
+ abort "Point SF_DIR to your SmartFox installation"
9
+ end
10
+
11
+ Rubyfox::Client.require_libs(ENV['SF_DIR'] + "/lib")
12
+ Rubyfox::Client.boot!
13
+
14
+ Rubyfox::Client.new(:debug => true) do |client|
15
+ client.on_event :connection do
16
+ client.send :login, *ARGV
17
+ end
18
+
19
+ client.on_event :connection_attempt_http, :connection_resume, :connection_retry do |event|
20
+ p :problems => event
21
+ end
22
+
23
+ client.on_event :login do |event|
24
+ p :login => event
25
+ client.send_extension "KeepAlive"
26
+ end
27
+
28
+ client.on_event :login_error, :connection_lost, :logout do |event|
29
+ p event
30
+ client.exit
31
+ end
32
+
33
+ client.on_extension "KeepAlive" do |request|
34
+ next_in = request.params[:next_in]
35
+ p :keep_alive => next_in
36
+ Thread.start do
37
+ sleep next_in
38
+ client.send_extension "KeepAlive"
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,24 @@
1
+ require 'rubyfox/client'
2
+
3
+ ARGV.size == 3 or abort "usage: simple.rb username password zone"
4
+
5
+ Rubyfox::Client.boot!
6
+
7
+ client = Rubyfox::Client.new
8
+ client.on_event :connection do |event|
9
+ p :connected!
10
+ client.send :login, *ARGV
11
+ end
12
+ client.on_event :login do |event|
13
+ p :login => event.arguments["zone"]
14
+ client.disconnect
15
+ end
16
+ client.on_event :login_error do |event|
17
+ p :login_failed
18
+ client.disconnect
19
+ end
20
+ client.on_event :connection_lost do |event|
21
+ p :disconnected
22
+ client.exit
23
+ end
24
+ client.connect
@@ -1,13 +1,15 @@
1
1
  module Rubyfox
2
2
  module Client
3
- def self.new(*args)
3
+ def self.new(*args, &block)
4
4
  config = Config.new(*args)
5
- Transport.new(config)
5
+ Transport.new(config, &block)
6
6
  end
7
7
 
8
8
  def self.boot!(vendor_dir=File.expand_path('client/vendor', File.dirname(__FILE__)))
9
9
  require_libs vendor_dir
10
10
 
11
+ require 'rubyfox/sfsobject/core_ext'
12
+
11
13
  require 'rubyfox/client/transport'
12
14
  require 'rubyfox/client/event_handler'
13
15
  end
@@ -12,6 +12,10 @@ module Rubyfox
12
12
  @smartfox = Java::SmartFox.new(@config.debug?)
13
13
  @event_handler = EventHandler.new(@smartfox)
14
14
  @extension_handler = ExtensionHandler.new(@event_handler)
15
+ if block_given?
16
+ yield self
17
+ connect
18
+ end
15
19
  end
16
20
 
17
21
  def connect
@@ -1,5 +1,5 @@
1
1
  module Rubyfox
2
2
  module Client
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |gem|
19
19
  gem.require_paths = ["lib"]
20
20
 
21
21
  gem.add_dependency 'activesupport'
22
+ gem.add_dependency 'rubyfox-sfsobject', '>= 0.2.2'
22
23
 
23
24
  gem.add_development_dependency 'rake'
24
25
  gem.add_development_dependency 'rdoc'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rubyfox-client
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.1.0
6
6
  platform: java
7
7
  authors:
8
8
  - Peter Suschlik
@@ -30,6 +30,22 @@ dependencies:
30
30
  none: false
31
31
  prerelease: false
32
32
  type: :runtime
33
+ - !ruby/object:Gem::Dependency
34
+ name: rubyfox-sfsobject
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: 0.2.2
40
+ none: false
41
+ requirement: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.2.2
46
+ none: false
47
+ prerelease: false
48
+ type: :runtime
33
49
  - !ruby/object:Gem::Dependency
34
50
  name: rake
35
51
  version_requirements: !ruby/object:Gem::Requirement
@@ -79,7 +95,8 @@ files:
79
95
  - Gemfile
80
96
  - README.rdoc
81
97
  - Rakefile
82
- - examples/login_tester.rb
98
+ - examples/keep_alive.rb
99
+ - examples/simple.rb
83
100
  - lib/rubyfox/client.rb
84
101
  - lib/rubyfox/client/config.rb
85
102
  - lib/rubyfox/client/event.rb
@@ -1,44 +0,0 @@
1
- require 'java'
2
- require 'rubyfox/client'
3
-
4
- unless ARGV.size == 3
5
- abort "usage: #{$0} username password zone"
6
- end
7
-
8
- unless ENV['SF_DIR']
9
- abort "Point SF_DIR to your SmartFox installation"
10
- end
11
-
12
- Rubyfox::Client.require_libs(ENV['SF_DIR'] + "/lib")
13
- Rubyfox::Client.boot!
14
-
15
- client = Rubyfox::Client.new(:debug => true)
16
-
17
- client.on_event :connection do
18
- client.send :login, *ARGV
19
- end
20
-
21
- client.on_event :connection_attempt_http, :connection_resume, :connection_retry do |event|
22
- p :problems => event
23
- end
24
-
25
- client.on_event :login do |event|
26
- p :login => event
27
- client.send_extension "KeepAlive"
28
- end
29
-
30
- client.on_event :login_error, :connection_lost, :logout do |event|
31
- p event
32
- client.exit
33
- end
34
-
35
- client.on_extension "KeepAlive" do |request|
36
- p request
37
- next_in = request.params.get_int("next_in")
38
- Thread.start do
39
- sleep next_in
40
- client.send_extension "KeepAlive"
41
- end
42
- end
43
-
44
- client.connect