connects to websockets (wrong library feature enabled)

This commit is contained in:
Brandon Thomas committed 2021-09-26 04:04:07 -04:00
1 parent e95ff9a7fa
commit f67d048f27
3 files changed
+96 -41

No files matched your search

Generated
+77 -26
View File
@@ -65,12 +65,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "base64"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
[[package]]
name = "base64"
version = "0.13.0"
@@ -849,7 +843,7 @@ version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "246e9f61b9bb77df069a947682be06e31ac43ea37862e244a69f177694ea6d22"
dependencies = [
"base64 0.13.0",
"base64",
"bytes",
"encoding_rs",
"futures-core",
@@ -892,30 +886,41 @@ dependencies = [
"winapi",
]
[[package]]
name = "rustls"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d1126dcf58e93cee7d098dbda643b5f92ed724f1f6a63007c1116eed6700c81"
dependencies = [
"base64 0.12.3",
"log",
"ring",
"sct",
"webpki",
]
[[package]]
name = "rustls"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7"
dependencies = [
"base64 0.13.0",
"base64",
"log",
"ring",
"sct",
"webpki",
"sct 0.6.1",
"webpki 0.21.4",
]
[[package]]
name = "rustls"
version = "0.20.0-beta2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f85530c337a44ed700862acf71f9013cd62600f79de996d3c3ea87773df910d5"
dependencies = [
"log",
"ring",
"sct 0.7.0",
"webpki 0.22.0",
]
[[package]]
name = "rustls-native-certs"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092"
dependencies = [
"openssl-probe",
"rustls 0.19.1",
"schannel",
"security-framework",
]
[[package]]
@@ -944,6 +949,16 @@ dependencies = [
"untrusted",
]
[[package]]
name = "sct"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "security-framework"
version = "2.4.2"
@@ -1172,6 +1187,17 @@ dependencies = [
"tokio",
]
[[package]]
name = "tokio-rustls"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
dependencies = [
"rustls 0.19.1",
"tokio",
"webpki 0.21.4",
]
[[package]]
name = "tokio-tungstenite"
version = "0.15.0"
@@ -1183,7 +1209,10 @@ dependencies = [
"pin-project",
"rustls 0.19.1",
"tokio",
"tokio-rustls",
"tungstenite",
"webpki 0.21.4",
"webpki-roots",
]
[[package]]
@@ -1247,17 +1276,20 @@ version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0b2d8558abd2e276b0a8df5c05a2ec762609344191e5fd23e292c910e9165b5"
dependencies = [
"base64 0.13.0",
"base64",
"byteorder",
"bytes",
"http",
"httparse",
"log",
"rand",
"rustls 0.19.1",
"rustls-native-certs",
"sha-1",
"thiserror",
"url",
"utf-8",
"webpki 0.21.4",
]
[[package]]
@@ -1269,7 +1301,7 @@ dependencies = [
"futures-util",
"log",
"reqwest",
"rustls 0.18.1",
"rustls 0.20.0-beta2",
"serde",
"serde_derive",
"tokio",
@@ -1313,7 +1345,7 @@ checksum = "af3ac686c0fd364beafa745e4471c602d945ff5e1962e36e27c38ad92660e929"
dependencies = [
"aliri_braid",
"async-trait",
"base64 0.13.0",
"base64",
"displaydoc",
"http",
"once_cell",
@@ -1504,6 +1536,25 @@ dependencies = [
"untrusted",
]
[[package]]
name = "webpki"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "webpki-roots"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940"
dependencies = [
"webpki 0.21.4",
]
[[package]]
name = "winapi"
version = "0.3.9"
+10 -7
View File
@@ -12,12 +12,18 @@ name = "twitch-tts-desktop-client"
path = "src/main.rs"
[dependencies]
# Async runtime
#tokio = { version = "0.2", features = ["full"] }
# Async runtime, Futures, etc.
tokio = { version = "1.10.0", features = ["rt-multi-thread", "macros"] }
futures-util = "0.3.17"
# Crypto
rustls = "0.18"
tokio-tungstenite = { version = "0.15.0", features = ["rustls"] }
rustls = "0.20.0-beta2"
# Websockets
tokio-tungstenite = { version = "0.15.0", features = ["rustls", "rustls-tls"] }
# HTTP
reqwest = { version = "0.11.4" }
# Serialization
serde = "1.0.130"
@@ -35,9 +41,6 @@ toml = "0.5.8"
# NB "unsupported" pubsub features may disappear from the Twitch API at any time. It's an unofficial API.
twitch_api2 = { version = "0.6.0-rc.2", features = ["helix", "reqwest_client", "pubsub", "chrono", "unsupported"] }
twitch_oauth2 = "0.6.0-rc.2"
reqwest = { version = "0.11.4" }
tokio = { version = "1.10.0", features = ["rt-multi-thread", "macros"] }
futures-util = "0.3.17"
# Utils
anyhow = "1.0.44"
+9 -8
View File
@@ -10,10 +10,7 @@ use twitch_api2::pubsub;
use twitch_oauth2::{AppAccessToken, Scope, TwitchToken, tokens::errors::AppAccessTokenError, ClientId, ClientSecret};
use twitch_api2::pubsub::Topic;
use tokio_tungstenite::{
connect_async,
tungstenite::{Error as TungsteniteError, Result as TungsteniteResult},
};
use tokio_tungstenite::{connect_async, tungstenite::{Error as TungsteniteError, Result as TungsteniteResult}, connect_async_with_config};
use reqwest::Url;
pub mod twitch;
@@ -39,7 +36,7 @@ fn main() -> AnyhowResult<()> {
async fn run() -> AnyhowResult<()> {
let secrets = TwitchSecrets::from_file("secrets.toml")?;
let client_id = ClientId::new(&secrets.app_client_id);
/*let client_id = ClientId::new(&secrets.app_client_id);
let client_secret = ClientSecret::new(&secrets.app_client_secret);
let client: TwitchClient<reqwest::Client> = TwitchClient::default();
@@ -58,7 +55,7 @@ async fn run() -> AnyhowResult<()> {
println!(
"{:?}",
&client.helix.req_get(req, &token).await?.data.unwrap().title
);
);*/
// Want this:
@@ -75,7 +72,7 @@ async fn run() -> AnyhowResult<()> {
.into_topic();*/
// Listen to follows as well
let follows = pubsub::following::Following { channel_id: 1234 }.into_topic();
/*let follows = pubsub::following::Following { channel_id: 1234 }.into_topic();
let topics = [follows];
// Create the topic command to send to twitch
let command = pubsub::listen_command(
@@ -84,7 +81,7 @@ async fn run() -> AnyhowResult<()> {
"random nonce string",
)?;
println!("Pubsub command: {:?}", command);
println!("Pubsub command: {:?}", command);*/
// Send the message with your favorite websocket client
//send_command(command).unwrap();
@@ -94,6 +91,10 @@ async fn run() -> AnyhowResult<()> {
println!("Connecting...");
if let Err(e) = connect_async(&url).await {
println!("Error connecting: {:?}", e);
}
let (mut socket, _response) =
connect_async(url).await?;