More work on implementing networking

This commit is contained in:
2020-05-10 11:05:16 -05:00
parent e94f2582f9
commit cf1e72225c
11 changed files with 253 additions and 118 deletions

23
lib/networking/peer.rb Normal file
View File

@@ -0,0 +1,23 @@
class IMICFPS
module Networking
class Peer
attr_reader :packet_read_queue, :packet_write_queue
attr_accessor :packets_sent, :packets_received, :data_sent, :data_received, :last_read_time, :last_write_time
def initialize(peer_id:, address:, port:)
@address, @port = address, port
@peer_id = peer_id
@packet_write_queue = []
@packet_read_queue = []
@last_read_time = Networking.milliseconds
@last_write_time = Networking.milliseconds
@packets_sent = 0
@packets_received = 0
@data_sent = 0
@data_received = 0
end
end
end
end