Skip to content

Commit

Permalink
Merge pull request #11 from calcit-lang/upgrade-abi
Browse files Browse the repository at this point in the history
upgrade to abi 0.0.7
  • Loading branch information
NoEgAm authored Jan 31, 2024
2 parents ebaca36 + 83037fd commit d016a44
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 21 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: supplypike/setup-bin@v3
with:
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.8.0-a3/cr'
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.8.21/cr'
name: 'cr'
version: '0.8.0-a3'
version: '0.8.21'

- uses: supplypike/setup-bin@v3
with:
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.8.0-a3/caps'
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.8.21/caps'
name: 'caps'
version: '0.8.0-a3'
version: '0.8.21'

- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
toolchain: nightly
components: clippy

- run: cargo build --release

Expand Down
52 changes: 49 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "calcit_wss"
version = "0.2.0-a2"
version = "0.2.1"
authors = ["jiyinyiyong <jiyinyiyong@gmail.com>"]
edition = "2021"

Expand All @@ -13,7 +13,7 @@ crate-type = ["dylib"] # Creates dynamic lib
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cirru_edn = "0.4.2"
cirru_edn = "0.5.4"
lazy_static = "1.4.0"
simple-websockets = "0.1.6"

2 changes: 1 addition & 1 deletion calcit.cirru

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion compact.cirru
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

{} (:package |wss)
:configs $ {} (:init-fn |wss.test/main!) (:reload-fn |wss.test/reload!) (:version |0.2.0-a3)
:configs $ {} (:init-fn |wss.test/main!) (:reload-fn |wss.test/reload!) (:version |0.2.1)
:modules $ []
:entries $ {}
:files $ {}
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lazy_static! {

#[no_mangle]
pub fn abi_version() -> String {
String::from("0.0.6")
String::from("0.0.7")
}

#[no_mangle]
Expand All @@ -20,7 +20,7 @@ pub fn wss_serve(
handler: Arc<dyn Fn(Vec<Edn>) -> Result<Edn, String> + Send + Sync + 'static>,
_finish: Box<dyn FnOnce()>,
) -> Result<Edn, String> {
let port = match args.get(0) {
let port = match args.first() {
Some(Edn::Map(m)) => match m.get(&Edn::tag("port")) {
Some(Edn::Number(n)) => n.floor().round() as u16,
Some(a) => return Err(format!("Unknown port: {}", a)),
Expand All @@ -44,7 +44,7 @@ pub fn wss_serve(
let mut clients = CLIENTS.write().unwrap();
clients.insert(client_id, responder);
}
if let Err(e) = handler(vec![Edn::Tuple(Box::new(Edn::tag("connect")), vec![Edn::Number(client_id as f64)])]) {
if let Err(e) = handler(vec![Edn::Tuple(Arc::new(Edn::tag("connect")), vec![Edn::Number(client_id as f64)])]) {
println!("Failed to handle connect: {}", e)
}
}
Expand All @@ -55,7 +55,7 @@ pub fn wss_serve(
clients.remove(&client_id);
}
if let Err(e) = handler(vec![Edn::Tuple(
Box::new(Edn::tag("disconnect")),
Arc::new(Edn::tag("disconnect")),
vec![Edn::Number(client_id as f64)],
)]) {
println!("Failed to handle disconnect: {}", e)
Expand All @@ -64,15 +64,15 @@ pub fn wss_serve(
Event::Message(client_id, message) => match message {
Message::Text(s) => {
if let Err(e) = handler(vec![Edn::Tuple(
Box::new(Edn::tag("message")),
vec![Edn::Number(client_id as f64), Edn::Str(s.into_boxed_str())],
Arc::new(Edn::tag("message")),
vec![Edn::Number(client_id as f64), Edn::Str(s.into())],
)]) {
println!("Failed to handle text message: {}", e)
}
}
Message::Binary(buf) => {
if let Err(e) = handler(vec![Edn::Tuple(
Box::new(Edn::tag("blob")),
Arc::new(Edn::tag("blob")),
vec![Edn::Number(client_id as f64), Edn::Buffer(buf)],
)]) {
println!("Failed to handle binary message: {}", e)
Expand Down

0 comments on commit d016a44

Please sign in to comment.