Removed async-websocket, more work on netcode

This commit is contained in:
2020-05-08 21:42:14 -05:00
parent e3a2c9abe0
commit bae6a6a332
6 changed files with 60 additions and 35 deletions

View File

@@ -3,7 +3,6 @@ gem "rake"
gem "opengl-bindings", require: "opengl"
gem "cyberarm_engine", git: "https://github.com/cyberarm/cyberarm_engine"
gem "nokogiri", ">= 1.11.0.rc1"
gem "async-websocket"
group(:packaging) do
gem "releasy", github: "gosu/releasy"

View File

@@ -19,58 +19,25 @@ GIT
GEM
remote: https://rubygems.org/
specs:
async (1.26.0)
console (~> 1.0)
nio4r (~> 2.3)
timers (~> 4.1)
async-http (0.52.2)
async (~> 1.25)
async-io (~> 1.28)
async-pool (~> 0.2)
protocol-http (~> 0.19.0)
protocol-http1 (~> 0.13.0)
protocol-http2 (~> 0.14.0)
async-io (1.29.0)
async (~> 1.14)
async-pool (0.3.1)
async (~> 1.25)
async-websocket (0.14.0)
async-http (~> 0.51)
async-io (~> 1.23)
protocol-websocket (~> 0.7.0)
console (1.8.2)
cri (2.1.0)
excon (0.73.0)
gosu (0.15.1)
gosu (0.15.1-x64-mingw32)
gosu_more_drawables (0.3.0)
mini_portile2 (2.5.0)
nio4r (2.5.2)
nokogiri (1.11.0.rc2)
mini_portile2 (~> 2.5.0)
nokogiri (1.11.0.rc2-x64-mingw32)
ocra (1.3.11)
opengl-bindings (1.6.10)
protocol-hpack (1.4.2)
protocol-http (0.19.0)
protocol-http1 (0.13.0)
protocol-http (~> 0.19)
protocol-http2 (0.14.0)
protocol-hpack (~> 1.4)
protocol-http (~> 0.18)
protocol-websocket (0.7.4)
protocol-http (~> 0.2)
protocol-http1 (~> 0.2)
rake (13.0.1)
rubyzip (2.3.0)
timers (4.3.0)
PLATFORMS
ruby
x64-mingw32
DEPENDENCIES
async-websocket
cyberarm_engine!
excon
nokogiri (>= 1.11.0.rc1)

View File

@@ -9,7 +9,6 @@ require "tmpdir"
require "opengl"
require "glu"
require "nokogiri"
require "async/websocket"
begin
require_relative "../cyberarm_engine/lib/cyberarm_engine"

View File

@@ -1,8 +1,20 @@
class IMICFPS
module Networking
class Client
attr_reader :uuid,
:packets_sent, :packets_received,
:data_sent, :data_received
def initialize(socket:)
@socket = socket
@write_queue = []
@read_queue = []
@uuid = "not_defined"
@packets_sent = 0
@packets_received = 0
@data_sent = 0
@data_received = 0
end
def read
@@ -11,7 +23,16 @@ class IMICFPS
def write
end
def puts(packet)
@write_queue << packet
end
def gets
@socket.recvfrom_nonblock(Protocol::MAX_PACKET_SIZE)
end
def close
@socket.close if @socket
end
end
end

View File

View File

@@ -0,0 +1,39 @@
class IMICFPS
module Networking
module Protocol
MAX_CLIENTS = 32
MAX_PACKET_SIZE = 1024
PROTOCOL_VERSION = 0 # int
HEARTBEAT_INTERVAL = 250 # ms
TIMEOUT_PERIOD = 30_000 # ms
packet_types = %w{
# protocol packets
reliable
multipart
acknowledgement
control
data
# protocol control packets
connect
disconnect
authenticate
heartbeat
# game data packets
client_connected
client_disconnected
entity_move
play_sound_effect
create_particle
}
# emulate c-like enum
packet_types.each_with_index do |type, i|
next if type.start_with?("#")
self.const_set(:"#{type.upcase}", i)
end
end
end
end