diff options
author | crowlKats <13135287+crowlKats@users.noreply.github.com> | 2021-01-05 13:37:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-05 13:37:02 +0100 |
commit | f85cd54cb4a1c54d835374d83dba4f8f7b89d2d1 (patch) | |
tree | a9f1d28b6b34014972ed36c1666d069bcca1c95e /runtime/ops/websocket.rs | |
parent | c823211a2cae13ff6fdb7d3d3fc585bb4e096232 (diff) |
fix(runtime/websocket): respond to ping with pong (#8974)
Diffstat (limited to 'runtime/ops/websocket.rs')
-rw-r--r-- | runtime/ops/websocket.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/runtime/ops/websocket.rs b/runtime/ops/websocket.rs index 812844f39..b220655ae 100644 --- a/runtime/ops/websocket.rs +++ b/runtime/ops/websocket.rs @@ -216,6 +216,7 @@ pub async fn op_ws_create( #[serde(rename_all = "camelCase")] struct SendArgs { rid: u32, + kind: String, text: Option<String>, } @@ -226,9 +227,11 @@ pub async fn op_ws_send( ) -> Result<Value, AnyError> { let args: SendArgs = serde_json::from_value(args)?; - let msg = match args.text { - Some(text) => Message::Text(text), - None => Message::Binary(bufs[0].to_vec()), + let msg = match args.kind.as_str() { + "text" => Message::Text(args.text.unwrap()), + "binary" => Message::Binary(bufs[0].to_vec()), + "pong" => Message::Pong(vec![]), + _ => unreachable!(), }; let rid = args.rid; |