mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-09-19 14:53:49 +00:00
Use ChunkyPNG for converting ICO bmp to png as gosu doesn't like doing it on the background thread, fixed Worker#service payload sometimes returning multiple events causing the json parser to have a bad time- also can support payloads larger than a megabyte now.
This commit is contained in:
3
Gemfile
3
Gemfile
@@ -8,7 +8,7 @@ gem "json"
|
|||||||
|
|
||||||
# "game" library gem
|
# "game" library gem
|
||||||
gem "cyberarm_engine"
|
gem "cyberarm_engine"
|
||||||
gem "sdl2-bindings"
|
gem "sdl3-bindings"
|
||||||
|
|
||||||
# networking libs
|
# networking libs
|
||||||
gem "async"
|
gem "async"
|
||||||
@@ -19,3 +19,4 @@ gem "async-websocket"
|
|||||||
gem "digest-crc"
|
gem "digest-crc"
|
||||||
gem "ircparser"
|
gem "ircparser"
|
||||||
gem "rubyzip"
|
gem "rubyzip"
|
||||||
|
gem "chunky_png"
|
||||||
|
|||||||
101
Gemfile.lock
101
Gemfile.lock
@@ -1,24 +1,20 @@
|
|||||||
GEM
|
GEM
|
||||||
remote: https://gem.coop/
|
remote: https://gem.coop/
|
||||||
specs:
|
specs:
|
||||||
async (2.39.0)
|
async (2.45.1)
|
||||||
console (~> 1.29)
|
console (~> 1.29)
|
||||||
fiber-annotation
|
fiber-annotation
|
||||||
io-event (~> 1.11)
|
io-event (~> 1.21)
|
||||||
metrics (~> 0.12)
|
async-http (0.103.0)
|
||||||
traces (~> 0.18)
|
async (>= 2.35.1)
|
||||||
async-http (0.95.1)
|
async-pool (~> 0.12)
|
||||||
async (>= 2.10.2)
|
io-endpoint (~> 0.18)
|
||||||
async-pool (~> 0.11)
|
io-stream (~> 0.14)
|
||||||
io-endpoint (~> 0.14)
|
protocol-http (~> 0.66)
|
||||||
io-stream (~> 0.6)
|
protocol-http1 (~> 0.41)
|
||||||
metrics (~> 0.12)
|
protocol-http2 (~> 0.28)
|
||||||
protocol-http (~> 0.62)
|
|
||||||
protocol-http1 (~> 0.39)
|
|
||||||
protocol-http2 (~> 0.26)
|
|
||||||
protocol-url (~> 0.2)
|
protocol-url (~> 0.2)
|
||||||
traces (~> 0.10)
|
async-pool (0.12.0)
|
||||||
async-pool (0.11.2)
|
|
||||||
async (>= 2.0)
|
async (>= 2.0)
|
||||||
async-websocket (0.30.1)
|
async-websocket (0.30.1)
|
||||||
async-http (~> 0.76)
|
async-http (~> 0.76)
|
||||||
@@ -26,7 +22,8 @@ GEM
|
|||||||
protocol-rack (~> 0.7)
|
protocol-rack (~> 0.7)
|
||||||
protocol-websocket (~> 0.17)
|
protocol-websocket (~> 0.17)
|
||||||
base64 (0.3.0)
|
base64 (0.3.0)
|
||||||
console (1.36.0)
|
chunky_png (1.4.0)
|
||||||
|
console (1.37.0)
|
||||||
fiber-annotation
|
fiber-annotation
|
||||||
fiber-local (~> 1.1)
|
fiber-local (~> 1.1)
|
||||||
json
|
json
|
||||||
@@ -40,34 +37,35 @@ GEM
|
|||||||
fiber-storage
|
fiber-storage
|
||||||
fiber-storage (1.0.1)
|
fiber-storage (1.0.1)
|
||||||
gosu (1.4.6)
|
gosu (1.4.6)
|
||||||
io-endpoint (0.17.2)
|
io-endpoint (0.18.0)
|
||||||
io-event (1.16.2)
|
openssl (>= 3.3.0)
|
||||||
io-stream (0.13.1)
|
io-event (1.21.1)
|
||||||
|
io-stream (0.14.0)
|
||||||
|
openssl (>= 3.3)
|
||||||
ircparser (1.0.0)
|
ircparser (1.0.0)
|
||||||
json (2.19.9)
|
json (3.0.1)
|
||||||
logger (1.7.0)
|
logger (1.7.0)
|
||||||
metrics (0.15.0)
|
openssl (4.0.2)
|
||||||
protocol-hpack (1.5.1)
|
protocol-hpack (1.5.1)
|
||||||
protocol-http (0.62.2)
|
protocol-http (0.71.0)
|
||||||
protocol-http1 (0.39.0)
|
protocol-http1 (0.41.0)
|
||||||
protocol-http (~> 0.62)
|
protocol-http (~> 0.68)
|
||||||
protocol-http2 (0.26.0)
|
protocol-http2 (0.28.0)
|
||||||
protocol-hpack (~> 1.4)
|
protocol-hpack (~> 1.4)
|
||||||
protocol-http (~> 0.62)
|
protocol-http (~> 0.62)
|
||||||
protocol-rack (0.22.1)
|
protocol-rack (0.22.1)
|
||||||
io-stream (>= 0.10)
|
io-stream (>= 0.10)
|
||||||
protocol-http (~> 0.58)
|
protocol-http (~> 0.58)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
protocol-url (0.4.0)
|
protocol-url (0.19.0)
|
||||||
protocol-websocket (0.21.1)
|
protocol-websocket (0.21.2)
|
||||||
protocol-http (~> 0.2)
|
protocol-http (~> 0.2)
|
||||||
rack (3.2.6)
|
rack (3.2.7)
|
||||||
rake (13.4.2)
|
rake (13.4.2)
|
||||||
rexml (3.4.4)
|
rexml (3.4.4)
|
||||||
rubyzip (3.4.0)
|
rubyzip (3.6.0)
|
||||||
sdl2-bindings (0.2.3)
|
sdl3-bindings (1.0.4)
|
||||||
ffi (~> 1.15)
|
ffi (~> 1.16)
|
||||||
traces (0.18.2)
|
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
x86_64-linux
|
x86_64-linux
|
||||||
@@ -77,6 +75,7 @@ DEPENDENCIES
|
|||||||
async-http
|
async-http
|
||||||
async-websocket
|
async-websocket
|
||||||
base64
|
base64
|
||||||
|
chunky_png
|
||||||
cyberarm_engine
|
cyberarm_engine
|
||||||
digest-crc
|
digest-crc
|
||||||
ircparser
|
ircparser
|
||||||
@@ -84,15 +83,16 @@ DEPENDENCIES
|
|||||||
logger
|
logger
|
||||||
rexml
|
rexml
|
||||||
rubyzip
|
rubyzip
|
||||||
sdl2-bindings
|
sdl3-bindings
|
||||||
|
|
||||||
CHECKSUMS
|
CHECKSUMS
|
||||||
async (2.39.0) sha256=df18730073f2bbb45788077dfa20cb365ecc1b9453969f44de6796b5191a00aa
|
async (2.45.1) sha256=95849f7432eca535146c69f3078dab3c7228d0075ed71f48733f3e585dd7c267
|
||||||
async-http (0.95.1) sha256=0c3dd458c204c06d5c4b20b01bbec4794a1203db627fb2ce536e1799ec14786c
|
async-http (0.103.0) sha256=137e3d5d419f7d72d5fa33cf04f30232e79c57b690025a650b8f9e48ece8bc41
|
||||||
async-pool (0.11.2) sha256=0a43a17b02b04d9c451b7d12fafa9a50e55dc6dd00d4369aca00433f16a7e3ed
|
async-pool (0.12.0) sha256=5580493dc024bd704dab2ed0bf1307100722e49cbb825c7965f8501194f58506
|
||||||
async-websocket (0.30.1) sha256=54bb8a8f184e4aa64434c7a78ecc55850a67a3d1dcd02e3ae787376e2c673936
|
async-websocket (0.30.1) sha256=54bb8a8f184e4aa64434c7a78ecc55850a67a3d1dcd02e3ae787376e2c673936
|
||||||
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
||||||
console (1.36.0) sha256=45599ea906cf80a73d8941f03abf873fe66a6a954e0bac5bc1c01e2cdc406f07
|
chunky_png (1.4.0) sha256=89d5b31b55c0cf4da3cf89a2b4ebc3178d8abe8cbaf116a1dba95668502fdcfe
|
||||||
|
console (1.37.0) sha256=8093b286c2595a063849c098594fee5155ecc7967d36f3aa8cbe7569c8f3efd7
|
||||||
cyberarm_engine (0.25.1) sha256=6f851a2ed0a32bdd25fc619172b546a8e26eefeb13a62c509f226337170d0efe
|
cyberarm_engine (0.25.1) sha256=6f851a2ed0a32bdd25fc619172b546a8e26eefeb13a62c509f226337170d0efe
|
||||||
digest-crc (0.7.0) sha256=64adc23a26a241044cbe6732477ca1b3c281d79e2240bcff275a37a5a0d78c07
|
digest-crc (0.7.0) sha256=64adc23a26a241044cbe6732477ca1b3c281d79e2240bcff275a37a5a0d78c07
|
||||||
ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
|
ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
|
||||||
@@ -100,26 +100,25 @@ CHECKSUMS
|
|||||||
fiber-local (1.1.0) sha256=c885f94f210fb9b05737de65d511136ea602e00c5105953748aa0f8793489f06
|
fiber-local (1.1.0) sha256=c885f94f210fb9b05737de65d511136ea602e00c5105953748aa0f8793489f06
|
||||||
fiber-storage (1.0.1) sha256=f48e5b6d8b0be96dac486332b55cee82240057065dc761c1ea692b2e719240e1
|
fiber-storage (1.0.1) sha256=f48e5b6d8b0be96dac486332b55cee82240057065dc761c1ea692b2e719240e1
|
||||||
gosu (1.4.6) sha256=80c7fa48cf61f4960ef067fdd1c000d98b4adc8e11faeaa486543d00908a5c15
|
gosu (1.4.6) sha256=80c7fa48cf61f4960ef067fdd1c000d98b4adc8e11faeaa486543d00908a5c15
|
||||||
io-endpoint (0.17.2) sha256=3feaf766c116b35839c11fac68b6aaadc47887bb488902a57bf8e1d288fb3338
|
io-endpoint (0.18.0) sha256=720d186bcd584e8ba490bfc91dab332cc3c5ffee848b5b03894555cb275151aa
|
||||||
io-event (1.16.2) sha256=9f9cb0a96ea5c3850a672606c65f27bc96d7621399ef6196acbfe2be0cd1279c
|
io-event (1.21.1) sha256=b3088f89ad67edf9be9fc2f48a5fae0790e92862487551eeb337b49098eb99e6
|
||||||
io-stream (0.13.1) sha256=570d7c4dfb0fbd767480b4a222048a2be6d9b78febc1ec68258d0e0a4cde20de
|
io-stream (0.14.0) sha256=07d9b13ea2066ccbbc761fff8d69ad5a31e47561d31e02cc271f3ed9c1a8f1cd
|
||||||
ircparser (1.0.0) sha256=0d4598f691172e2ad078207c50ba62c0d3428ae841836b0a682e6cd01d62878d
|
ircparser (1.0.0) sha256=0d4598f691172e2ad078207c50ba62c0d3428ae841836b0a682e6cd01d62878d
|
||||||
json (2.19.9) sha256=9b9025b7cdddafa38d316eca0b2358488e42d417045c1b90d216a9fefe46b79a
|
json (3.0.1) sha256=c80f74a3570c3a310cd41c526904e7ef8363abdece4432f31fe97d812bc4a39e
|
||||||
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
||||||
metrics (0.15.0) sha256=61ded5bac95118e995b1bc9ed4a5f19bc9814928a312a85b200abbdac9039072
|
openssl (4.0.2) sha256=1037ad2868ae58df9ad917891c0c0f9815a1172f6846d4bcdd508e4c2ee747c2
|
||||||
protocol-hpack (1.5.1) sha256=6feca238b8078da1cd295677d6f306c6001af92d75fe0643d33e6956cbc3ad91
|
protocol-hpack (1.5.1) sha256=6feca238b8078da1cd295677d6f306c6001af92d75fe0643d33e6956cbc3ad91
|
||||||
protocol-http (0.62.2) sha256=e1c1f2f56029c1af8c4e2b8a67d0d096c76620f3afd8d99d1dcd2f6b8ffa773b
|
protocol-http (0.71.0) sha256=38577bf3df0bf0c3f7ee7e21b43fcb4bd7624e36f697dbe9c3eea344f14bd9ba
|
||||||
protocol-http1 (0.39.0) sha256=e49b3f4cda6f5d94c76a323d2b7f6977cba3ebd082d2da437039594da77ad8eb
|
protocol-http1 (0.41.0) sha256=9863874a1228948a896c3e7ea16d13a680c8f3ed50706007c78b7033018b0ea3
|
||||||
protocol-http2 (0.26.0) sha256=bac89cd78082b241ccd0cf7246f5160e4bb0c9c975fb4bf7deef5f88cc317486
|
protocol-http2 (0.28.0) sha256=b7c6195dcfa80ec2484670e9fd8fc21024cc654a391aa0792433aff1188c1691
|
||||||
protocol-rack (0.22.1) sha256=1185d245927ef9849a603700d6991ca353bc89724fbf98efa4a4333ed62a9fc3
|
protocol-rack (0.22.1) sha256=1185d245927ef9849a603700d6991ca353bc89724fbf98efa4a4333ed62a9fc3
|
||||||
protocol-url (0.4.0) sha256=64d4c03b6b51ad815ac6fdaf77a1d91e5baf9220d26becb846c5459dacdea9e1
|
protocol-url (0.19.0) sha256=3f6b9f6aa742a259a0b3610fbbd9685dcd9506adf6734f428ff96259faabfb21
|
||||||
protocol-websocket (0.21.1) sha256=34325e4325697f0956877e67784bcc838cfd51ebbf4f8e9e5201be292041ee61
|
protocol-websocket (0.21.2) sha256=cbe35be8e045597b221874fba5928d7cd2483884126e3e36faece4741dc88eb7
|
||||||
rack (3.2.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2
|
rack (3.2.7) sha256=93e13e1c24f93556671d85d2d79fa228c3485815c50d7e2f265b5330c6528fb7
|
||||||
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
|
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
|
||||||
rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
|
rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
|
||||||
rubyzip (3.4.0) sha256=6de39bc9eba302b635a476d16c9e16b0872ad24517c2f98f2b3a7ea23caff57b
|
rubyzip (3.6.0) sha256=268994d44d62282d1cfd99bf10eae48d7267199158ad7ea3e1fee2da9458b695
|
||||||
sdl2-bindings (0.2.3) sha256=878c0755a4bea1aed0fa85c01596effd1c2b7d1878141ceec5bef808038bd309
|
sdl3-bindings (1.0.4) sha256=326f497c30e6a5cab402e6178403b30c9df4a11a4e109e08c5da6e920c7bb55b
|
||||||
traces (0.18.2) sha256=80f1649cb4daace1d7174b81f3b3b7427af0b93047759ba349960cb8f315e214
|
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
4.0.8
|
4.0.8
|
||||||
|
|||||||
@@ -122,7 +122,8 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Gosu::Image.from_blob(image.width, image.height, blob)
|
# Gosu::Image.from_blob(image.width, image.height, blob)
|
||||||
|
ChunkyPNG::Canvas.from_rgba_stream(image.width, image.height, blob)
|
||||||
end
|
end
|
||||||
|
|
||||||
def image_data(image)
|
def image_data(image)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ module W3DHubLauncher
|
|||||||
["user-agent", W3DHubLauncher::USER_AGENT]
|
["user-agent", W3DHubLauncher::USER_AGENT]
|
||||||
].freeze
|
].freeze
|
||||||
DEFAULT_NETWORK_TIMEOUT = 30
|
DEFAULT_NETWORK_TIMEOUT = 30
|
||||||
|
RESPONSE_SEPARATOR = "\04".freeze
|
||||||
|
|
||||||
Response = Data.define(:status, :request_id, :result)
|
Response = Data.define(:status, :request_id, :result)
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ module W3DHubLauncher
|
|||||||
def connect
|
def connect
|
||||||
puts :connect
|
puts :connect
|
||||||
|
|
||||||
|
@buffer = StringIO.new
|
||||||
@socket = UNIXSocket.new(IPC_PATH)
|
@socket = UNIXSocket.new(IPC_PATH)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -55,7 +57,9 @@ module W3DHubLauncher
|
|||||||
response = send(query.type, query)
|
response = send(query.type, query)
|
||||||
# pp [:server_to_client, response]
|
# pp [:server_to_client, response]
|
||||||
payload = { status: response.status, request_id: response.request_id, data: response.result.data, error: response.result.error }.to_json
|
payload = { status: response.status, request_id: response.request_id, data: response.result.data, error: response.result.error }.to_json
|
||||||
socket.puts(payload)
|
socket.write(payload)
|
||||||
|
socket.write(RESPONSE_SEPARATOR)
|
||||||
|
socket.flush
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -133,22 +137,32 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
def service
|
def service
|
||||||
data = @socket.read_nonblock(1_048_576) # 1 MB
|
data = @socket.read_nonblock(1_048_576) # 1 MB
|
||||||
# pp [:CLIENT, data]
|
@buffer << data
|
||||||
json = JSON.parse(data)
|
|
||||||
request = W3DHubLauncher::Worker::Request.requests.find { |r| r.request_id == json["request_id"] }
|
|
||||||
|
|
||||||
# pp [json, request]
|
@buffer.rewind
|
||||||
return unless request
|
payloads = @buffer.readlines(RESPONSE_SEPARATOR, chomp: true)
|
||||||
|
@buffer.reopen(@buffer.string[@buffer.pos..@buffer.length])
|
||||||
|
@buffer.pos = @buffer.length
|
||||||
|
|
||||||
CyberarmEngine::Window.instance&.add_to_queue(proc {
|
payloads.each do |payload|
|
||||||
request.handle_event(
|
# pp [:CLIENT, data]
|
||||||
json["status"],
|
json = JSON.parse(payload)
|
||||||
CyberarmEngine::Result.new(data: json["data"], error: json["error"])
|
request = W3DHubLauncher::Worker::Request.requests.find { |r| r.request_id == json["request_id"] }
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
rescue JSON::ParserError => e
|
# pp [json, request]
|
||||||
puts "This should never happen!?!?!"
|
return unless request
|
||||||
|
|
||||||
|
CyberarmEngine::Window.instance&.add_to_queue(proc {
|
||||||
|
request.handle_event(
|
||||||
|
json["status"],
|
||||||
|
CyberarmEngine::Result.new(data: json["data"], error: json["error"])
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
rescue JSON::ParserError => e
|
||||||
|
puts "This should never happen!?!?!"
|
||||||
|
pp data, payload
|
||||||
|
end
|
||||||
|
|
||||||
rescue Errno::EWOULDBLOCK
|
rescue Errno::EWOULDBLOCK
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ require "async/websocket"
|
|||||||
require "digest/crc"
|
require "digest/crc"
|
||||||
require "ircparser"
|
require "ircparser"
|
||||||
require "zip"
|
require "zip"
|
||||||
|
require "chunky_png"
|
||||||
|
|
||||||
require_relative "lib/version"
|
require_relative "lib/version"
|
||||||
require_relative "lib/constants"
|
require_relative "lib/constants"
|
||||||
|
|||||||
Reference in New Issue
Block a user