1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-26 16:09:27 -05:00
denoland-deno/runtime/ops/websocket.rs

34 lines
1 KiB
Rust
Raw Normal View History

2021-01-10 21:59:07 -05:00
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
use crate::permissions::Permissions;
use deno_websocket::op_ws_check_permission;
use deno_websocket::op_ws_close;
use deno_websocket::op_ws_create;
use deno_websocket::op_ws_next_event;
use deno_websocket::op_ws_send;
use deno_websocket::WsCaData;
use deno_websocket::WsUserAgent;
pub fn init(
rt: &mut deno_core::JsRuntime,
user_agent: String,
ca_data: Option<Vec<u8>>,
) {
{
let op_state = rt.op_state();
let mut state = op_state.borrow_mut();
state.put::<WsUserAgent>(WsUserAgent(user_agent));
if let Some(ca_data) = ca_data {
state.put::<WsCaData>(WsCaData(ca_data));
}
}
super::reg_json_sync(
rt,
"op_ws_check_permission",
op_ws_check_permission::<Permissions>,
);
super::reg_json_async(rt, "op_ws_create", op_ws_create::<Permissions>);
super::reg_json_async(rt, "op_ws_send", op_ws_send);
super::reg_json_async(rt, "op_ws_close", op_ws_close);
super::reg_json_async(rt, "op_ws_next_event", op_ws_next_event);
2020-09-05 10:39:25 -04:00
}