@@ -11,7 +11,7 @@ lazy_static! {
11
11
12
12
#[ no_mangle]
13
13
pub fn abi_version ( ) -> String {
14
- String :: from ( "0.0.1 " )
14
+ String :: from ( "0.0.5 " )
15
15
}
16
16
17
17
#[ no_mangle]
@@ -21,7 +21,7 @@ pub fn wss_serve(
21
21
_finish : Box < dyn FnOnce ( ) > ,
22
22
) -> Result < Edn , String > {
23
23
let port = match args. get ( 0 ) {
24
- Some ( Edn :: Map ( m) ) => match m. get ( & Edn :: Keyword ( String :: from ( "port" ) ) ) {
24
+ Some ( Edn :: Map ( m) ) => match m. get ( & Edn :: kwd ( "port" ) ) {
25
25
Some ( Edn :: Number ( n) ) => n. floor ( ) . round ( ) as u16 ,
26
26
Some ( a) => return Err ( format ! ( "Unknown port: {}" , a) ) ,
27
27
None => 9001 ,
@@ -50,7 +50,7 @@ pub fn wss_serve(
50
50
clients. insert ( client_id, responder) ;
51
51
}
52
52
if let Err ( e) = handler ( vec ! [ Edn :: List ( vec![
53
- Edn :: Keyword ( String :: from ( "connect" ) ) ,
53
+ Edn :: kwd ( "connect" ) ,
54
54
Edn :: Number ( client_id as f64 ) ,
55
55
] ) ] ) {
56
56
println ! ( "Failed to handle connect: {}" , e)
@@ -63,7 +63,7 @@ pub fn wss_serve(
63
63
clients. remove ( & client_id) ;
64
64
}
65
65
if let Err ( e) = handler ( vec ! [ Edn :: List ( vec![
66
- Edn :: Keyword ( String :: from ( "disconnect" ) ) ,
66
+ Edn :: kwd ( "disconnect" ) ,
67
67
Edn :: Number ( client_id as f64 ) ,
68
68
] ) ] ) {
69
69
println ! ( "Failed to handle disconnect: {}" , e)
@@ -72,16 +72,16 @@ pub fn wss_serve(
72
72
Event :: Message ( client_id, message) => match message {
73
73
Message :: Text ( s) => {
74
74
if let Err ( e) = handler ( vec ! [ Edn :: List ( vec![
75
- Edn :: Keyword ( String :: from ( "message" ) ) ,
75
+ Edn :: kwd ( "message" ) ,
76
76
Edn :: Number ( client_id as f64 ) ,
77
- Edn :: Str ( s) ,
77
+ Edn :: Str ( s. into_boxed_str ( ) ) ,
78
78
] ) ] ) {
79
79
println ! ( "Failed to handle text message: {}" , e)
80
80
}
81
81
}
82
82
Message :: Binary ( buf) => {
83
83
if let Err ( e) = handler ( vec ! [ Edn :: List ( vec![
84
- Edn :: Keyword ( String :: from ( "message" ) ) ,
84
+ Edn :: kwd ( "message" ) ,
85
85
Edn :: Number ( client_id as f64 ) ,
86
86
Edn :: Buffer ( buf) ,
87
87
] ) ] ) {
@@ -105,7 +105,7 @@ pub fn wss_send(args: Vec<Edn>) -> Result<Edn, String> {
105
105
let clients = CLIENTS . read ( ) . unwrap ( ) ;
106
106
let responder = clients. get ( & ( * id as u64 ) ) . unwrap ( ) ;
107
107
// echo the message back:
108
- responder. send ( Message :: Text ( s. to_owned ( ) ) ) ;
108
+ responder. send ( Message :: Text ( s. to_string ( ) . to_owned ( ) ) ) ;
109
109
Ok ( Edn :: Nil )
110
110
}
111
111
( a, b) => Err ( format ! ( "wss-send expected id and message, got {} {}" , a, b) ) ,
0 commit comments