Class: Fargo::Connection::Upload
- Defined in:
- lib/fargo/connection/upload.rb
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Publisher
Instance Method Summary collapse
- #file_length ⇒ Object
- #post_listen ⇒ Object
- #receive(data) ⇒ Object
- #supports ⇒ Object
- #write_chunk ⇒ Object
Methods included from Parser
#parse_command_message, #parse_message
Methods included from Utils
#encode_char, #generate_key, #generate_lock
Methods inherited from Base
#connect, #connected?, #disconnect, #initialize, #listen, #open_socket, #write
Methods included from Publisher
#publish, #subscribe, #subscribed_to?, #unsubscribe
Constructor Details
This class inherits a constructor from Fargo::Connection::Base
Instance Method Details
#file_length ⇒ Object
80 81 |
# File 'lib/fargo/connection/upload.rb', line 80 def file_length end |
#post_listen ⇒ Object
9 10 11 12 13 |
# File 'lib/fargo/connection/upload.rb', line 9 def post_listen @lock, @pk = generate_lock write "$MyNick #{self[:nick]}|$Lock #{@lock} Pk=#{@pk}" @handshake_step = 0 end |
#receive(data) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fargo/connection/upload.rb', line 19 def receive data = data publish [:type], case [:type] when :mynick if @handshake_step == 0 @remote_nick = [:nick] @handshake_step = 1 else disconnect end when :lock if @handshake_step == 1 @remote_lock = [:lock] @handshake_step = 2 else disconnect end when :supports if @handshake_step == 2 @remote_extensions = [:extensions] @handshake_step = 3 else disconnect end when :direction if @handshake_step == 3 && [:direction] == 'download' @handshake_step = 4 @client_num = [:number] else disconnect end when :key if @handshake_step == 4 && generate_key(@lock) == [:key] write supports write "$Direction Download #{@my_num = rand 10000}" write "$Key #{generate_key @remote_lock}" @handshake_step = 5 else disconnect end when :get if @handshake_step == 5 @filepath = [:path] @offset = [:offset] write "$FileLength #{file_length}" @handshake_step = 5 else disconnect end when :send write_chunk if @handshake_step == 5 else # Fargo.logger.warn "Ignoring `#{data}'\n" end end |
#supports ⇒ Object
15 16 17 |
# File 'lib/fargo/connection/upload.rb', line 15 def supports "$Supports BZList TTHL TTHF" # ??? end |
#write_chunk ⇒ Object
77 78 |
# File 'lib/fargo/connection/upload.rb', line 77 def write_chunk end |