Class: Client
- Inherits:
-
Object
- Object
- Client
- Defined in:
- lib/teeworlds_server.rb
Instance Attribute Summary collapse
-
#ack ⇒ Object
readonly
Returns the value of attribute ack.
-
#addr ⇒ Object
Returns the value of attribute addr.
-
#id ⇒ Object
Returns the value of attribute id.
-
#in_game ⇒ Object
Returns the value of attribute in_game.
-
#last_recv_time ⇒ Object
Returns the value of attribute last_recv_time.
-
#player ⇒ Object
Returns the value of attribute player.
-
#token ⇒ Object
Returns the value of attribute token.
-
#vital_sent ⇒ Object
Returns the value of attribute vital_sent.
Instance Method Summary collapse
- #bump_ack ⇒ Object
- #in_game? ⇒ Boolean
-
#initialize(attr = {}) ⇒ Client
constructor
A new instance of Client.
-
#seq ⇒ Object
TODO: use or remove not sure if its cool one can make vital_sent read only and then the seq reader increments it so everytime a header is created the chunk builder just calls seq = client.seq.
Constructor Details
#initialize(attr = {}) ⇒ Client
Returns a new instance of Client.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/teeworlds_server.rb', line 21 def initialize(attr = {}) @id = attr[:id] @addr = attr[:addr] @vital_sent = 0 @ack = 0 @in_game = false @last_recv_time = Time.now @player = Player.new( id: @id, local: 0, team: 0, name: '(connecting)', clan: '', country: -1 ) @token = attr[:token] SecurityToken.validate(@token) end |
Instance Attribute Details
#ack ⇒ Object (readonly)
Returns the value of attribute ack.
19 20 21 |
# File 'lib/teeworlds_server.rb', line 19 def ack @ack end |
#addr ⇒ Object
Returns the value of attribute addr.
18 19 20 |
# File 'lib/teeworlds_server.rb', line 18 def addr @addr end |
#id ⇒ Object
Returns the value of attribute id.
18 19 20 |
# File 'lib/teeworlds_server.rb', line 18 def id @id end |
#in_game ⇒ Object
Returns the value of attribute in_game.
18 19 20 |
# File 'lib/teeworlds_server.rb', line 18 def in_game @in_game end |
#last_recv_time ⇒ Object
Returns the value of attribute last_recv_time.
18 19 20 |
# File 'lib/teeworlds_server.rb', line 18 def last_recv_time @last_recv_time end |
#player ⇒ Object
Returns the value of attribute player.
18 19 20 |
# File 'lib/teeworlds_server.rb', line 18 def player @player end |
#token ⇒ Object
Returns the value of attribute token.
18 19 20 |
# File 'lib/teeworlds_server.rb', line 18 def token @token end |
#vital_sent ⇒ Object
Returns the value of attribute vital_sent.
18 19 20 |
# File 'lib/teeworlds_server.rb', line 18 def vital_sent @vital_sent end |
Instance Method Details
#bump_ack ⇒ Object
44 45 46 |
# File 'lib/teeworlds_server.rb', line 44 def bump_ack @ack = (@ack + 1) % NET_MAX_SEQUENCE end |
#in_game? ⇒ Boolean
40 41 42 |
# File 'lib/teeworlds_server.rb', line 40 def in_game? @in_game end |
#seq ⇒ Object
TODO: use or remove
not sure if its cool
one can make vital_sent read only
and then the seq reader increments it
so everytime a header is created
the chunk builder just calls
seq = client.seq
55 56 57 |
# File 'lib/teeworlds_server.rb', line 55 def seq @vital_sent + 1 end |