mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-16 08:02:36 +00:00
Added rubocop config, more work on CyberarmEngine Netcode; basic sending and receiving of packets is now functional
This commit is contained in:
@@ -1,14 +1,34 @@
|
||||
module CyberarmEngine
|
||||
module Networking
|
||||
class Peer
|
||||
attr_reader :id, :hostname, :port, :data
|
||||
attr_reader :id, :hostname, :port, :data, :read_queue, :write_queue
|
||||
attr_accessor :total_packets_sent, :total_packets_received,
|
||||
:total_data_sent, :total_data_received,
|
||||
:last_read_time, :last_write_time
|
||||
|
||||
def initialize(id:, hostname:, port:)
|
||||
@id = id
|
||||
@hostname = hostname
|
||||
@port = port
|
||||
|
||||
@data = {}
|
||||
@read_queue = []
|
||||
@write_queue = []
|
||||
|
||||
@last_read_time = Networking.milliseconds
|
||||
@last_write_time = Networking.milliseconds
|
||||
|
||||
@total_packets_sent = 0
|
||||
@total_packets_received = 0
|
||||
@total_data_sent = 0
|
||||
@total_data_received = 0
|
||||
end
|
||||
|
||||
def id=(n)
|
||||
raise "Peer id must be an integer" unless n.is_a?(Integer)
|
||||
|
||||
@id = n
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user