From dfb4bc4032f18b2d25cf8af8e492a703bf234785 Mon Sep 17 00:00:00 2001 From: Eric Guo Date: Sun, 31 Dec 2023 15:02:50 +0800 Subject: [PATCH 1/4] Need mruby 3.2.0 --- Rakefile | 2 +- build_config.rb.lock | 46 ++++++++++++++++++++++---------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Rakefile b/Rakefile index 8e542c2..ea8b63d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,6 @@ require "fileutils" -MRUBY_VERSION = "3.0.0" +MRUBY_VERSION = "3.2.0" task :mruby do sh "git clone --branch=#{MRUBY_VERSION} --depth=1 https://github.com/mruby/mruby" diff --git a/build_config.rb.lock b/build_config.rb.lock index 6440f16..29a7386 100644 --- a/build_config.rb.lock +++ b/build_config.rb.lock @@ -1,92 +1,92 @@ --- mruby: - version: 3.0.0 - release_no: 30000 - git_commit: 0f45836b5954accf508f333f932741b925214471 + version: 3.2.0 + release_no: 30200 + git_commit: 87260e7bb1a9edfb2ce9b41549c4142129061ca5 builds: host: https://github.com/iij/mruby-regexp-pcre.git: url: https://github.com/iij/mruby-regexp-pcre.git - branch: HEAD + branch: master commit: 71bd16ba59239f04aefb73bb6d46d5b581f27b1b version: 0.0.0 https://github.com/Asmod4n/mruby-uri-parser.git: url: https://github.com/Asmod4n/mruby-uri-parser.git - branch: HEAD + branch: master commit: bbfb475e3125bb7edf50aae110f5d5a64f4e3f6a version: 0.0.0 https://github.com/mttech/mruby-getopts: url: https://github.com/mttech/mruby-getopts - branch: HEAD + branch: master commit: 32878292c1162a911b39e1e0810a28ab2cb83f6a version: 0.0.0 https://github.com/Asmod4n/mruby-websockets.git: url: https://github.com/Asmod4n/mruby-websockets.git - branch: HEAD + branch: master commit: 9bb66308085acbeb727f8ef21979b7884d8fb322 version: 0.0.0 https://github.com/Asmod4n/mruby-simplemsgpack.git: url: https://github.com/Asmod4n/mruby-simplemsgpack.git - branch: HEAD - commit: 9df3c4a4d6ff1b62cbedb6c680b2af2f72015e40 + branch: master + commit: d7e9142afe9d5d53855c1611d2c35b5b71f02fa9 version: 0.0.0 https://github.com/iij/mruby-mtest.git: url: https://github.com/iij/mruby-mtest.git - branch: HEAD + branch: master commit: 34a477d249b0d21671058be33aa75d04c3e981ba version: 0.0.0 https://github.com/iij/mruby-errno.git: url: https://github.com/iij/mruby-errno.git - branch: HEAD + branch: master commit: b4415207ff6ea62360619c89a1cff83259dc4db0 version: 0.0.0 https://github.com/Asmod4n/mruby-phr.git: url: https://github.com/Asmod4n/mruby-phr.git - branch: HEAD - commit: 1bab77000280141802d56a20a5413ba0900b69df + branch: master + commit: a9b5776c5c6926ce30b09aadd5743c34e16ca522 version: 0.0.0 https://github.com/Asmod4n/mruby-wslay: url: https://github.com/Asmod4n/mruby-wslay - branch: HEAD + branch: master commit: 47fc6c9795399efb4bcf2258a69125afcab00428 version: 0.0.0 https://github.com/Asmod4n/mruby-poll.git: url: https://github.com/Asmod4n/mruby-poll.git - branch: HEAD - commit: f33ce28bc3ebb8650d91a0bf31da3e163e29af45 + branch: master + commit: 867c2a650675dd8278600388ce8f0e64284977e5 version: 0.0.0 https://github.com/Asmod4n/mruby-tls.git: url: https://github.com/Asmod4n/mruby-tls.git - branch: HEAD + branch: master commit: af809343feb18d11b97d346072e15ab736f1ac3f version: 0.0.0 https://github.com/Asmod4n/mruby-sysrandom.git: url: https://github.com/Asmod4n/mruby-sysrandom.git - branch: HEAD + branch: master commit: 75347e898686c8c044b0fa8a76f42ad25daee45c version: 0.0.0 https://github.com/Asmod4n/mruby-b64.git: url: https://github.com/Asmod4n/mruby-b64.git - branch: HEAD + branch: master commit: 6d8f36b1bd310aa1b0dccd6fe7b0e9d7551d7718 version: 0.0.0 https://github.com/Asmod4n/mruby-secure-compare.git: url: https://github.com/Asmod4n/mruby-secure-compare.git - branch: HEAD + branch: master commit: 433a73a483b550ad13e3a9af33707300c1c7822d version: 0.0.0 https://github.com/Asmod4n/mruby-string-is-utf8.git: url: https://github.com/Asmod4n/mruby-string-is-utf8.git - branch: HEAD + branch: master commit: 1c639fe845008d437420a61852329a158ddd74b1 version: 0.0.0 https://github.com/palkan/mruby-simplemsgpack.git: url: https://github.com/palkan/mruby-simplemsgpack.git - branch: HEAD + branch: master commit: 2d908b1c9cdfb5f12319866ef483179be22660ad version: 0.0.0 https://github.com/palkan/mruby-json.git: url: https://github.com/palkan/mruby-json.git - branch: HEAD + branch: master commit: 29550959d21f6eea75a26b0e05c1bda0c43f5ef4 version: 0.0.0 From b7e5671423b13decbe710db3017cd275272ca809 Mon Sep 17 00:00:00 2001 From: Eric Guo Date: Sun, 31 Dec 2023 15:44:59 +0800 Subject: [PATCH 2/4] Using ruby 2.7 syntax. --- mrblib/acli/client.rb | 44 ++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/mrblib/acli/client.rb b/mrblib/acli/client.rb index 470e8ca..66b54f1 100644 --- a/mrblib/acli/client.rb +++ b/mrblib/acli/client.rb @@ -47,28 +47,30 @@ def close def handle_incoming(msg) logger.log "Incoming: #{msg}" - data = coder.decode(msg) - data = data.transform_keys!(&:to_sym) - case data - in type: "confirm_subscription", identifier: - subscribed! identifier - in type: "reject_subscription", identifier: + data = coder.decode(msg).transform_keys!(&:to_sym) + + case data[:type] + when "confirm_subscription" + subscribed! data[:identifier] + when "reject_subscription" puts "Subscription rejected" - in type: "confirm_history", identifier: + when "confirm_history" # no-op - in type: "reject_history", identifier: + when "reject_history" puts "Failed to retrieve history" - in type: "ping" + when "ping" track_ping! - in type: "welcome", **opts - connected!(opts) - in type: "disconnect", **opts + when "welcome" + connected!(data) + when "disconnect" puts "Disconnected by server: " \ - "#{opts.fetch(:reason, "unknown reason")} " \ - "(reconnect: #{opts.fetch(:reconnect, "")})" + "#{data.fetch(:reason, "unknown reason")} " \ + "(reconnect: #{data.fetch(:reconnect, "")})" close - in message:, identifier:, **meta - received(message, meta) + else + if data[:message] && data[:identifier] + received(data[:message], data) + end end end @@ -134,11 +136,11 @@ def quit! def parse_quit_after!(value) @quit_after = case value - in "connect" | "subscribed" - value - in /\d+/ - @quit_after_messages = value.to_i - "message" + when "connect", "subscribed" + value + when /\d+/ + @quit_after_messages = value.to_i + "message" end end end From 312e00fcafa64d5fbcb29365f06ac61cef41b261 Mon Sep 17 00:00:00 2001 From: Eric-Guo Date: Sun, 31 Dec 2023 19:51:31 +0800 Subject: [PATCH 3/4] mruby-poll merged. https://github.com/Asmod4n/mruby-poll/pull/5 --- build_config.rb.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/build_config.rb.lock b/build_config.rb.lock index 29a7386..e47729f 100644 --- a/build_config.rb.lock +++ b/build_config.rb.lock @@ -7,22 +7,22 @@ builds: host: https://github.com/iij/mruby-regexp-pcre.git: url: https://github.com/iij/mruby-regexp-pcre.git - branch: master + branch: HEAD commit: 71bd16ba59239f04aefb73bb6d46d5b581f27b1b version: 0.0.0 https://github.com/Asmod4n/mruby-uri-parser.git: url: https://github.com/Asmod4n/mruby-uri-parser.git - branch: master + branch: HEAD commit: bbfb475e3125bb7edf50aae110f5d5a64f4e3f6a version: 0.0.0 https://github.com/mttech/mruby-getopts: url: https://github.com/mttech/mruby-getopts - branch: master + branch: HEAD commit: 32878292c1162a911b39e1e0810a28ab2cb83f6a version: 0.0.0 https://github.com/Asmod4n/mruby-websockets.git: url: https://github.com/Asmod4n/mruby-websockets.git - branch: master + branch: HEAD commit: 9bb66308085acbeb727f8ef21979b7884d8fb322 version: 0.0.0 https://github.com/Asmod4n/mruby-simplemsgpack.git: @@ -32,7 +32,7 @@ builds: version: 0.0.0 https://github.com/iij/mruby-mtest.git: url: https://github.com/iij/mruby-mtest.git - branch: master + branch: HEAD commit: 34a477d249b0d21671058be33aa75d04c3e981ba version: 0.0.0 https://github.com/iij/mruby-errno.git: @@ -42,51 +42,51 @@ builds: version: 0.0.0 https://github.com/Asmod4n/mruby-phr.git: url: https://github.com/Asmod4n/mruby-phr.git - branch: master + branch: HEAD commit: a9b5776c5c6926ce30b09aadd5743c34e16ca522 version: 0.0.0 https://github.com/Asmod4n/mruby-wslay: url: https://github.com/Asmod4n/mruby-wslay - branch: master + branch: HEAD commit: 47fc6c9795399efb4bcf2258a69125afcab00428 version: 0.0.0 https://github.com/Asmod4n/mruby-poll.git: url: https://github.com/Asmod4n/mruby-poll.git - branch: master - commit: 867c2a650675dd8278600388ce8f0e64284977e5 + branch: HEAD + commit: 404299c264c183ec4fa65d0f1bdb322ba761c296 version: 0.0.0 https://github.com/Asmod4n/mruby-tls.git: url: https://github.com/Asmod4n/mruby-tls.git - branch: master + branch: HEAD commit: af809343feb18d11b97d346072e15ab736f1ac3f version: 0.0.0 https://github.com/Asmod4n/mruby-sysrandom.git: url: https://github.com/Asmod4n/mruby-sysrandom.git - branch: master + branch: HEAD commit: 75347e898686c8c044b0fa8a76f42ad25daee45c version: 0.0.0 https://github.com/Asmod4n/mruby-b64.git: url: https://github.com/Asmod4n/mruby-b64.git - branch: master + branch: HEAD commit: 6d8f36b1bd310aa1b0dccd6fe7b0e9d7551d7718 version: 0.0.0 https://github.com/Asmod4n/mruby-secure-compare.git: url: https://github.com/Asmod4n/mruby-secure-compare.git - branch: master + branch: HEAD commit: 433a73a483b550ad13e3a9af33707300c1c7822d version: 0.0.0 https://github.com/Asmod4n/mruby-string-is-utf8.git: url: https://github.com/Asmod4n/mruby-string-is-utf8.git - branch: master + branch: HEAD commit: 1c639fe845008d437420a61852329a158ddd74b1 version: 0.0.0 https://github.com/palkan/mruby-simplemsgpack.git: url: https://github.com/palkan/mruby-simplemsgpack.git - branch: master + branch: HEAD commit: 2d908b1c9cdfb5f12319866ef483179be22660ad version: 0.0.0 https://github.com/palkan/mruby-json.git: url: https://github.com/palkan/mruby-json.git - branch: master + branch: HEAD commit: 29550959d21f6eea75a26b0e05c1bda0c43f5ef4 version: 0.0.0 From 6137a50d791646582093bd0f129ede2fccc329af Mon Sep 17 00:00:00 2001 From: Eric-Guo Date: Tue, 2 Jan 2024 09:33:38 +0800 Subject: [PATCH 4/4] no if here --- mrblib/acli/client.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mrblib/acli/client.rb b/mrblib/acli/client.rb index 66b54f1..bb6dea2 100644 --- a/mrblib/acli/client.rb +++ b/mrblib/acli/client.rb @@ -68,9 +68,7 @@ def handle_incoming(msg) "(reconnect: #{data.fetch(:reconnect, "")})" close else - if data[:message] && data[:identifier] - received(data[:message], data) - end + received(data[:message], data) end end