-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: moved all examples to jarust crate
- Loading branch information
Showing
12 changed files
with
138 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Jarust | ||
|
||
Jarust is a memory safe and high-performance Rust adapter for [Janus WebRTC server](https://github.com/meetecho/janus-gateway). | ||
|
||
Inspired by [Janode](https://github.com/meetecho/janode), jarust offers similar functionalities but it's designed | ||
to be customizable, for exmaple, you could use the built-in WebSocket transport or provide your own RabbitMQ transport implementation. | ||
|
||
The crate wraps the Janus core API and some of the most popular plugins APIs. | ||
|
||
## Example Usage | ||
|
||
```rust | ||
use jarust::core::jaconfig::JaConfig; | ||
use jarust::core::jaconfig::JanusAPI; | ||
use jarust::core::prelude::Attach; | ||
use jarust::interface::tgenerator::RandomTransactionGenerator; | ||
use std::time::Duration; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let config = JaConfig { | ||
url: "ws://localhost:8188/ws".to_string(), | ||
apisecret: None, | ||
server_root: "janus".to_string(), | ||
capacity: 32, | ||
}; | ||
let mut connection = | ||
jarust::core::connect(config, JanusAPI::WebSocket, RandomTransactionGenerator) | ||
.await | ||
.unwrap(); | ||
|
||
let info = connection | ||
.server_info(Duration::from_secs(5)) | ||
.await | ||
.unwrap(); | ||
println!("{:#?}", info); | ||
|
||
let session = connection | ||
.create_session(10, Duration::from_secs(5)) | ||
.await | ||
.unwrap(); | ||
|
||
let (handle, _) = session | ||
.attach("janus.plugin.echotest".to_string(), Duration::from_secs(5)) | ||
.await | ||
.unwrap(); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,8 @@ | ||
# Jarust | ||
# Jarust Core | ||
|
||
The core of jarust. | ||
|
||
It under the hood it uses [jarust_interface](https://crates.io/crates/jarust_interface) to provide an abstract api | ||
for connecting, creating a session, attaching to a plugin, and then communicate with the plugin handle. | ||
|
||
It's also the building block for the plugin crate [jarust_plugins](https://crates.io/crates/jarust_plugins) | ||
|
||
## Example usage | ||
|
||
```rust | ||
use jarust_core::jaconfig::JaConfig; | ||
use jarust_core::jaconfig::TransportType; | ||
use jarust_core::japlugin::Attach; | ||
use serde_json::json; | ||
use tracing_subscriber::EnvFilter; | ||
|
||
#[tokio::main(flavor = "current_thread")] | ||
async fn main() -> anyhow::Result<()> { | ||
tracing_subscriber::fmt() | ||
.with_env_filter(EnvFilter::from_default_env().add_directive("jarust_core=trace".parse()?)) | ||
.init(); | ||
|
||
let mut connection = jarust_core::connect( | ||
JaConfig::new("ws://localhost:8188/ws", None, "janus"), | ||
TransportType::Ws, | ||
) | ||
.await?; | ||
let session = connection.create(10).await?; | ||
let (handle, mut event_receiver) = session.attach("janus.plugin.echotest").await?; | ||
|
||
handle | ||
.message(json!({ | ||
"video": true, | ||
"audio": true, | ||
})) | ||
.await?; | ||
|
||
while let Some(event) = event_receiver.recv().await { | ||
tracing::info!("response: {event:#?}"); | ||
} | ||
|
||
Ok(()) | ||
} | ||
``` |
Oops, something went wrong.