Update rust_socketio dependency and add patch for local development
This commit is contained in:
parent
27db3d5ef0
commit
daf53ba226
4
ica-rs/Cargo.lock
generated
4
ica-rs/Cargo.lock
generated
|
@ -886,8 +886,6 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust_engineio"
|
name = "rust_engineio"
|
||||||
version = "0.4.4"
|
version = "0.4.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f9f737d090ee4b543ba85d22a7c7035f8e456a5253a85296615e296b91a95265"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"adler32",
|
"adler32",
|
||||||
"async-stream",
|
"async-stream",
|
||||||
|
@ -910,8 +908,6 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust_socketio"
|
name = "rust_socketio"
|
||||||
version = "0.4.4"
|
version = "0.4.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "48b3c9531f72da89c2eb9f54dcf79169d54e26b8c03438e395d0dd8e40167767"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"adler32",
|
"adler32",
|
||||||
"backoff",
|
"backoff",
|
||||||
|
|
|
@ -11,3 +11,6 @@ ed25519-dalek = "2.1.0"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
rust_socketio = "0.4.4"
|
rust_socketio = "0.4.4"
|
||||||
serde_json = "1.0.108"
|
serde_json = "1.0.108"
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
rust_socketio = { path = "V:/githubs/rust-socketio/socketio" }
|
|
@ -2,19 +2,28 @@ mod client;
|
||||||
|
|
||||||
use ed25519_dalek::{Signature, Signer, SigningKey};
|
use ed25519_dalek::{Signature, Signer, SigningKey};
|
||||||
use rust_socketio::{ClientBuilder, Event, Payload, RawClient};
|
use rust_socketio::{ClientBuilder, Event, Payload, RawClient};
|
||||||
|
use serde_json::Value;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
fn require_auth_callback(payload: Payload, client: RawClient) {
|
fn require_auth_callback(payload: Payload, client: RawClient, _id: Option<i32>) {
|
||||||
let key = std::env::args().nth(2).expect("No key given");
|
let key = std::env::args().nth(2).expect("No key given");
|
||||||
let auth_key = match payload {
|
let require_data = match payload {
|
||||||
Payload::String(str) => Some(str),
|
Payload::String(_) => None,
|
||||||
Payload::Binary(_) => None,
|
Payload::Binary(_) => None,
|
||||||
|
Payload::Text(json_value) => Some(json_value),
|
||||||
}
|
}
|
||||||
.expect("Payload should be String");
|
.expect("Payload should be Json data");
|
||||||
let auth_key = &auth_key[1..auth_key.len() - 1];
|
|
||||||
|
|
||||||
println!("auth_key: {}", auth_key);
|
println!("require_data: {:?}", require_data);
|
||||||
|
|
||||||
|
// let (auth_key, version) = (&require_data[0], &require_data[1]);
|
||||||
|
// println!("auth_key: {:?}, version: {:?}", auth_key, version);
|
||||||
|
let auth_key = match &require_data.get(0) {
|
||||||
|
Some(Value::String(auth_key)) => Some(auth_key),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
.expect("auth_key should be string");
|
||||||
|
|
||||||
let array_key: [u8; 32] = hex::decode(key)
|
let array_key: [u8; 32] = hex::decode(key)
|
||||||
.expect("Key should be hex")
|
.expect("Key should be hex")
|
||||||
|
@ -31,11 +40,12 @@ fn require_auth_callback(payload: Payload, client: RawClient) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
fn any_event(event: Event, payload: Payload, _client: RawClient) {
|
fn any_event(event: Event, payload: Payload, _client: RawClient, id: Option<i32>) {
|
||||||
// println!("event: {} | {:#?}", event, payload);
|
// println!("event: {} | {:#?}", event, payload);
|
||||||
match payload {
|
match payload {
|
||||||
Payload::Binary(bin) => println!("event: {} |bin: {:?}", event, bin),
|
Payload::Binary(bin) => println!("event: {}|id:{:?}|bin: {:?}", event, id, bin),
|
||||||
Payload::String(str) => println!("event: {} |str: {:?}", event, str),
|
Payload::String(str) => println!("event: {}|id:{:?}|str: {:?}", event, id, str),
|
||||||
|
Payload::Text(txt) => println!("event: {}|id:{:?}|txt: {:?}", event, id, txt),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +53,7 @@ fn ws_main() {
|
||||||
// define a callback which is called when a payload is received
|
// define a callback which is called when a payload is received
|
||||||
// this callback gets the payload as well as an instance of the
|
// this callback gets the payload as well as an instance of the
|
||||||
// socket to communicate with the server
|
// socket to communicate with the server
|
||||||
let connect_call_back = |payload: Payload, _client: RawClient| {
|
let connect_call_back = |payload: Payload, _client: RawClient, _id| {
|
||||||
println!("Connect callback: {:#?}", payload);
|
println!("Connect callback: {:#?}", payload);
|
||||||
};
|
};
|
||||||
// 从命令行获取 host 和 key
|
// 从命令行获取 host 和 key
|
||||||
|
|
Loading…
Reference in New Issue
Block a user