Skip to content

Commit

Permalink
0.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
lz1998 committed Jun 20, 2022
1 parent a8ea308 commit 2349b80
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pbbot-rq"
version = "0.1.6"
version = "0.1.7"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub enum RCError {
Timeout,
#[error("client_not_found error")]
ClientNotFound,
#[error("protocol_not_supported error")]
ProtocolNotSupported,
#[error("io error, {0}")]
IO(#[from] io::Error),
#[error("websocket error, {0}")]
Expand All @@ -39,6 +41,7 @@ impl IntoResponse for RCError {
fn into_response(self) -> Response {
let code = match self {
Self::ClientNotFound => StatusCode::BAD_REQUEST,
Self::ProtocolNotSupported => StatusCode::BAD_REQUEST,
_ => StatusCode::INTERNAL_SERVER_ERROR,
};
(code, self.to_string()).into_response()
Expand Down
6 changes: 5 additions & 1 deletion src/handler/qrcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ pub struct CreateClientResp {
pub async fn create(Json(req): Json<CreateClientReq>) -> RCResult<Json<CreateClientResp>> {
let rand_seed = req.device_seed.unwrap_or_else(rand::random);
let device = Device::random_with_rng(&mut StdRng::seed_from_u64(rand_seed));
let protocol = Protocol::from_u8(req.protocol);
let protocol = match Protocol::from_u8(req.protocol) {
Protocol::MacOS => Protocol::MacOS,
Protocol::AndroidWatch => Protocol::AndroidWatch,
_ => return Err(RCError::ProtocolNotSupported),
};
let (sender, receiver) = tokio::sync::broadcast::channel(10);
let cli = Arc::new(Client::new(device, get_version(protocol), sender));
let stream = tokio::net::TcpStream::connect(cli.get_address())
Expand Down

0 comments on commit 2349b80

Please sign in to comment.