Skip to content

Commit d9b9227

Browse files
authored
Merge pull request #3 from calcit-lang/abi-version
change about ABI version
2 parents 63de5d4 + 671b23e commit d9b9227

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "calcit_wss"
3-
version = "0.0.1-a2"
3+
version = "0.0.1"
44
authors = ["jiyinyiyong <[email protected]>"]
55
edition = "2018"
66

calcit.cirru

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compact.cirru

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{} (:package |wss)
33
:configs $ {} (:init-fn |wss.test/main!) (:reload-fn |wss.test/reload!)
44
:modules $ []
5-
:version |0.0.1-a2
5+
:version |0.0.1
66
:files $ {}
77
|wss.core $ {}
88
:ns $ quote
@@ -30,15 +30,15 @@
3030
|demo! $ quote
3131
defn demo! ()
3232
wss-serve!
33-
{} $ :port 0
33+
{} $ :port 9001
3434
fn (income) (println income)
3535
wss-each! $ fn (id)
3636
wss-send! id $ str "\"hello from: " income
37-
println "\"TODO started"
37+
println "\"demo started"
3838
|main! $ quote
3939
defn main! () $ run-tests
4040
|reload! $ quote
41-
defn reload! $
41+
defn reload! () $ println "\"did nothing on reload"
4242
|wss.util $ {}
4343
:ns $ quote
4444
ns wss.util $ :require

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ lazy_static! {
99
static ref CLIENTS: RwLock<HashMap<u64, Responder>> = RwLock::new(HashMap::new());
1010
}
1111

12+
#[no_mangle]
13+
pub fn abi_version() -> String {
14+
String::from("0.0.1")
15+
}
16+
1217
#[no_mangle]
1318
pub fn wss_serve(
1419
args: Vec<Edn>,
1520
handler: Arc<dyn Fn(Vec<Edn>) -> Result<Edn, String> + Send + Sync + 'static>,
21+
_finish: Box<dyn FnOnce()>,
1622
) -> Result<Edn, String> {
1723
let port = match args.get(0) {
1824
Some(Edn::Map(m)) => match m.get(&Edn::Keyword(String::from("port"))) {
@@ -27,6 +33,7 @@ pub fn wss_serve(
2733

2834
// listen for WebSockets on port, defaults to 9001:
2935
let event_hub = simple_websockets::launch(port).expect("failed to listen on port 9001");
36+
println!("WebSocket server started at port {}", port);
3037

3138
spawn(move || {
3239
loop {
@@ -112,6 +119,7 @@ pub fn wss_send(args: Vec<Edn>) -> Result<Edn, String> {
112119
pub fn wss_each(
113120
_args: Vec<Edn>,
114121
handler: Arc<dyn Fn(Vec<Edn>) -> Result<Edn, String> + Send + Sync + 'static>,
122+
finish: Box<dyn FnOnce()>,
115123
) -> Result<Edn, String> {
116124
let mut ids: Vec<u64> = vec![];
117125
{
@@ -127,5 +135,6 @@ pub fn wss_each(
127135
handler(vec![Edn::Number(id as f64)])?;
128136
}
129137

138+
finish();
130139
Ok(Edn::Nil)
131140
}

0 commit comments

Comments
 (0)