Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
	modified:   Cargo.toml
	modified:   src/node.rs
  • Loading branch information
vicky5124 committed Oct 25, 2024
1 parent a4a8ade commit f6d05f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ features = ["rustls-webpki-roots", "twilight", "serenity", "songbird", "macros",
[dependencies]
arc-swap = "1"
serde_json = "1"
dashmap = "5"
dashmap = "6"
http = "1"
tracing = "0.1"
futures = "0.3"
Expand All @@ -55,7 +55,7 @@ bytes = "1"
urlencoding = "2"

[dependencies.tokio-tungstenite]
version = "0.21"
version = "0.24"

[dependencies.tokio]
version = "1"
Expand Down
30 changes: 18 additions & 12 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ use std::sync::Arc;
use arc_swap::ArcSwap;
use futures::stream::StreamExt;
use http::HeaderMap;
use http::Request;
//use http::Request;
use tokio_tungstenite::tungstenite::Message as TungsteniteMessage;
use tokio_tungstenite::{connect_async, tungstenite::handshake::client::generate_key};
use tokio_tungstenite::tungstenite::protocol::WebSocketConfig;
use tokio_tungstenite::tungstenite::client::IntoClientRequest;

#[derive(Debug, Clone)]
#[cfg_attr(not(feature = "python"), derive(Hash, Default))]
Expand Down Expand Up @@ -95,15 +96,16 @@ impl<'a> EventDispatcher<'a> {
impl Node {
/// Create a connection to the Lavalink server.
pub async fn connect(&self, lavalink_client: LavalinkClient) -> Result<(), LavalinkError> {
let mut url = Request::builder()
.method("GET")
.header("Host", &self.websocket_address)
.header("Connection", "Upgrade")
.header("Upgrade", "websocket")
.header("Sec-WebSocket-Version", "13")
.header("Sec-WebSocket-Key", generate_key())
.uri(&self.websocket_address)
.body(())?;
//let mut url = Request::builder()
// .method("GET")
// .header("Host", &self.websocket_address)
// .header("Connection", "Upgrade")
// .header("Upgrade", "websocket")
// .header("Sec-WebSocket-Version", "13")
// .header("Sec-WebSocket-Key", generate_key())
// .uri(&self.websocket_address)
// .body(())?;
let mut url = self.websocket_address.clone().into_client_request()?;

{
let ref_headers = url.headers_mut();
Expand All @@ -122,7 +124,11 @@ impl Node {
ref_headers.extend(headers.clone());
}

let (ws_stream, _) = connect_async(url).await?;
let (ws_stream, _) = tokio_tungstenite::connect_async_with_config(url, Some(WebSocketConfig {
max_message_size: None,
max_frame_size: None,
..Default::default()
}), false).await?;

info!("Connected to {}", self.websocket_address);

Expand Down

0 comments on commit f6d05f3

Please sign in to comment.