Skip to content

Commit

Permalink
chore: reduce unnecessary cloning (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Extheoisah authored Sep 12, 2024
1 parent 8b7fce4 commit b3e3669
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/app/websockets/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,16 @@ pub async fn websocket_handler(
};

let conn_id = manager_handle
.connect(session_token.clone(), &session)
.connect(&session_token, &session)
.await
.map_err(Error::from)?;

log::info!("WebSocket connected: Connection ID {:?}", conn_id);

let session = Some(session);
let session_clone = session.clone();
actix_web::rt::spawn(async move {
let mut last_heartbeat = Instant::now();
let mut interval = interval(HEARTBEAT_INTERVAL);
let mut session = session_clone;
let mut session = Some(session);

loop {
tokio::select! {
Expand Down
4 changes: 2 additions & 2 deletions src/app/websockets/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl WebSocketManager {

pub async fn connect(
&self,
session_token: SessionToken,
session_token: &SessionToken,
session: Session,
) -> io::Result<ConnId> {
let conn_id = ConnId::new_v4();
Expand Down Expand Up @@ -228,7 +228,7 @@ impl WebSocketManagerHandle {

pub async fn connect(
&self,
session_token: SessionToken,
session_token: &SessionToken,
session: &Session,
) -> io::Result<ConnId> {
self.manager.connect(session_token, session.clone()).await
Expand Down

0 comments on commit b3e3669

Please sign in to comment.