mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 23:52:35 +00:00
Removed async-websocket, more work on netcode
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -3,7 +3,6 @@ gem "rake"
|
|||||||
gem "opengl-bindings", require: "opengl"
|
gem "opengl-bindings", require: "opengl"
|
||||||
gem "cyberarm_engine", git: "https://github.com/cyberarm/cyberarm_engine"
|
gem "cyberarm_engine", git: "https://github.com/cyberarm/cyberarm_engine"
|
||||||
gem "nokogiri", ">= 1.11.0.rc1"
|
gem "nokogiri", ">= 1.11.0.rc1"
|
||||||
gem "async-websocket"
|
|
||||||
|
|
||||||
group(:packaging) do
|
group(:packaging) do
|
||||||
gem "releasy", github: "gosu/releasy"
|
gem "releasy", github: "gosu/releasy"
|
||||||
|
|||||||
33
Gemfile.lock
33
Gemfile.lock
@@ -19,58 +19,25 @@ GIT
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
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)
|
cri (2.1.0)
|
||||||
excon (0.73.0)
|
excon (0.73.0)
|
||||||
gosu (0.15.1)
|
gosu (0.15.1)
|
||||||
gosu (0.15.1-x64-mingw32)
|
gosu (0.15.1-x64-mingw32)
|
||||||
gosu_more_drawables (0.3.0)
|
gosu_more_drawables (0.3.0)
|
||||||
mini_portile2 (2.5.0)
|
mini_portile2 (2.5.0)
|
||||||
nio4r (2.5.2)
|
|
||||||
nokogiri (1.11.0.rc2)
|
nokogiri (1.11.0.rc2)
|
||||||
mini_portile2 (~> 2.5.0)
|
mini_portile2 (~> 2.5.0)
|
||||||
nokogiri (1.11.0.rc2-x64-mingw32)
|
nokogiri (1.11.0.rc2-x64-mingw32)
|
||||||
ocra (1.3.11)
|
ocra (1.3.11)
|
||||||
opengl-bindings (1.6.10)
|
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)
|
rake (13.0.1)
|
||||||
rubyzip (2.3.0)
|
rubyzip (2.3.0)
|
||||||
timers (4.3.0)
|
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
x64-mingw32
|
x64-mingw32
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
async-websocket
|
|
||||||
cyberarm_engine!
|
cyberarm_engine!
|
||||||
excon
|
excon
|
||||||
nokogiri (>= 1.11.0.rc1)
|
nokogiri (>= 1.11.0.rc1)
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ require "tmpdir"
|
|||||||
require "opengl"
|
require "opengl"
|
||||||
require "glu"
|
require "glu"
|
||||||
require "nokogiri"
|
require "nokogiri"
|
||||||
require "async/websocket"
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require_relative "../cyberarm_engine/lib/cyberarm_engine"
|
require_relative "../cyberarm_engine/lib/cyberarm_engine"
|
||||||
|
|||||||
@@ -1,8 +1,20 @@
|
|||||||
class IMICFPS
|
class IMICFPS
|
||||||
module Networking
|
module Networking
|
||||||
class Client
|
class Client
|
||||||
|
attr_reader :uuid,
|
||||||
|
:packets_sent, :packets_received,
|
||||||
|
:data_sent, :data_received
|
||||||
def initialize(socket:)
|
def initialize(socket:)
|
||||||
@socket = socket
|
@socket = socket
|
||||||
|
@write_queue = []
|
||||||
|
@read_queue = []
|
||||||
|
|
||||||
|
@uuid = "not_defined"
|
||||||
|
|
||||||
|
@packets_sent = 0
|
||||||
|
@packets_received = 0
|
||||||
|
@data_sent = 0
|
||||||
|
@data_received = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def read
|
def read
|
||||||
@@ -11,7 +23,16 @@ class IMICFPS
|
|||||||
def write
|
def write
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def puts(packet)
|
||||||
|
@write_queue << packet
|
||||||
|
end
|
||||||
|
|
||||||
|
def gets
|
||||||
|
@socket.recvfrom_nonblock(Protocol::MAX_PACKET_SIZE)
|
||||||
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
|
@socket.close if @socket
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
0
lib/networking/packet_handlers/move.rb
Normal file
0
lib/networking/packet_handlers/move.rb
Normal file
39
lib/networking/protocol.rb
Normal file
39
lib/networking/protocol.rb
Normal 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
|
||||||
Reference in New Issue
Block a user