rubtella 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/bin/rubtella CHANGED
@@ -22,7 +22,8 @@ when "start"
22
22
  Thread.new do
23
23
  gnutella = Rubtella::Sender.new
24
24
  gnutella.connect
25
- gnutella.send_query("doors")
25
+ gnutella.send_ping
26
+ #gnutella.send_query("doors")
26
27
  end
27
28
 
28
29
  while true
@@ -103,7 +103,6 @@ module Rubtella
103
103
  @@logger.info 'connection established'
104
104
  @connected = @peer
105
105
  @@logger.info "Connected with #{@connected.ip} #{@connected.port}"
106
- @@logger.info "Connected with #{@connected.ip} #{@connected.port}"
107
106
 
108
107
  manage_connection stream
109
108
  else
@@ -114,8 +113,8 @@ module Rubtella
114
113
  end
115
114
  rescue Timeout::Error,Errno::ECONNREFUSED
116
115
  @@logger.info "Timeout"
117
- @peer = resp.peers.shift
118
- connect
116
+ @peer = @peers.shift
117
+ retry
119
118
  rescue => e
120
119
  @@logger.info e.to_s
121
120
  end
@@ -156,6 +155,16 @@ module Rubtella
156
155
 
157
156
  end
158
157
 
158
+ def send_ping
159
+ stream = TCPSocket.new @connected.ip, @connected.port
160
+ query = TCPData::Builder::Ping.new
161
+ @@logger.info "sending ping"
162
+ stream.send query.build, 0
163
+ @@logger.info 'we\'re listening..'
164
+ resp = stream.recv 1000
165
+ parse(resp)
166
+ end
167
+
159
168
  def send_query(text)
160
169
  stream = TCPSocket.new @connected.ip, @connected.port
161
170
  query = TCPData::Builder::Query.new(:criteria => text)
data/rubtella.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubtella}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mateusz Zawisza"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubtella
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Zawisza