-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
130 additions
and
8 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,16 @@ | ||
use chorus::instance::Instance; | ||
use chorus::UrlBundle; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let bundle = UrlBundle::new( | ||
"https://example.com/api".to_string(), | ||
"wss://example.com/".to_string(), | ||
"https://example.com/cdn".to_string(), | ||
); | ||
let instance = Instance::new(bundle, true) | ||
.await | ||
.expect("Failed to connect to the Spacebar server"); | ||
dbg!(instance.instance_info); | ||
dbg!(instance.limits_information); | ||
} |
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,30 @@ | ||
use chorus::instance::Instance; | ||
use chorus::types::LoginSchema; | ||
use chorus::UrlBundle; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let bundle = UrlBundle::new( | ||
"https://example.com/api".to_string(), | ||
"wss://example.com/".to_string(), | ||
"https://example.com/cdn".to_string(), | ||
); | ||
let instance = Instance::new(bundle, true) | ||
.await | ||
.expect("Failed to connect to the Spacebar server"); | ||
// Assume, you already have an account created on this instance. Registering an account works | ||
// the same way, but you'd use the Register-specific Structs and methods instead. | ||
let login_schema = LoginSchema { | ||
login: "user@example.com".to_string(), | ||
password: "Correct-Horse-Battery-Staple".to_string(), | ||
..Default::default() | ||
}; | ||
// Each user connects to the Gateway. The Gateway connection lives on a seperate thread. Depending on | ||
// the runtime feature you choose, this can potentially take advantage of all of your computers' threads. | ||
let user = instance | ||
.login_account(login_schema) | ||
.await | ||
.expect("An error occurred during the login process"); | ||
dbg!(user.belongs_to); | ||
dbg!(&user.object.read().unwrap().username); | ||
} |