Skip to content

Commit

Permalink
add arc on builder
Browse files Browse the repository at this point in the history
  • Loading branch information
shenjackyuanjie committed May 17, 2024
1 parent 73dc93a commit bd0916d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions engineio/src/asynchronous/client/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ impl ClientBuilder {
}

/// Specify Packet Serializer
pub fn packet_serializer(mut self, packet_serializer: PacketSerializer) -> Self {
self.serializer = Arc::new(packet_serializer);
pub fn packet_serializer(mut self, packet_serializer: Arc<PacketSerializer>) -> Self {
self.serializer = packet_serializer;

self
}
Expand Down
11 changes: 6 additions & 5 deletions socketio/src/asynchronous/client/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rust_engineio::{
asynchronous::ClientBuilder as EngineIoClientBuilder,
header::{HeaderMap, HeaderValue},
};
use std::collections::HashMap;
use std::{collections::HashMap, sync::Arc};
use url::Url;

use crate::{error::Result, Event, PacketSerializer, Payload, TransportType};
Expand All @@ -31,7 +31,7 @@ pub struct ClientBuilder {
tls_config: Option<TlsConnector>,
opening_headers: Option<HeaderMap>,
transport_type: TransportType,
packet_serializer: PacketSerializer,
packet_serializer: Arc<PacketSerializer>,
pub(crate) auth: Option<serde_json::Value>,
pub(crate) reconnect: bool,
pub(crate) reconnect_on_disconnect: bool,
Expand Down Expand Up @@ -91,7 +91,7 @@ impl ClientBuilder {
tls_config: None,
opening_headers: None,
transport_type: TransportType::default(),
packet_serializer: PacketSerializer::default(),
packet_serializer: PacketSerializer::default_arc(),
auth: None,
reconnect: true,
reconnect_on_disconnect: false,
Expand Down Expand Up @@ -415,7 +415,7 @@ impl ClientBuilder {
/// }
/// ```
pub fn packet_serializer(mut self, packet_serializer: PacketSerializer) -> Self {
self.packet_serializer = packet_serializer;
self.packet_serializer = Arc::new(packet_serializer);

self
}
Expand Down Expand Up @@ -462,7 +462,8 @@ impl ClientBuilder {
url.set_path("/socket.io/");
}

let mut builder = EngineIoClientBuilder::new(url);
let mut builder =
EngineIoClientBuilder::new(url).packet_serializer(self.packet_serializer.clone());

if let Some(tls_config) = &self.tls_config {
builder = builder.tls_config(tls_config.to_owned());
Expand Down
2 changes: 1 addition & 1 deletion socketio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ pub use error::Error;

pub use {event::Event, payload::Payload};

pub use rust_engineio::Error as EngineIOError;
pub use client::{ClientBuilder, EngineIOPacket, PacketSerializer, RawClient, TransportType};
pub use rust_engineio::Error as EngineIOError;

// TODO: 0.4.0 remove
#[deprecated(since = "0.3.0-alpha-2", note = "Socket renamed to Client")]
Expand Down

0 comments on commit bd0916d

Please sign in to comment.