Skip to content

Commit

Permalink
Merge pull request #275 from alexgeek/example-imports
Browse files Browse the repository at this point in the history
Use re-exported tungstenite types so its easier to copy examples and …
  • Loading branch information
daniel-abramov committed Apr 16, 2023
2 parents db99615 + f153688 commit 1c97eb7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 4 additions & 2 deletions examples/autobahn-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use futures_util::{SinkExt, StreamExt};
use log::*;
use std::net::SocketAddr;
use tokio::net::{TcpListener, TcpStream};
use tokio_tungstenite::{accept_async, tungstenite::Error};
use tungstenite::Result;
use tokio_tungstenite::{
accept_async,
tungstenite::{Error, Result},
};

async fn accept_connection(peer: SocketAddr, stream: TcpStream) {
if let Err(e) = handle_connection(peer, stream).await {
Expand Down
6 changes: 4 additions & 2 deletions examples/interval-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use futures_util::{SinkExt, StreamExt};
use log::*;
use std::{net::SocketAddr, time::Duration};
use tokio::net::{TcpListener, TcpStream};
use tokio_tungstenite::{accept_async, tungstenite::Error};
use tungstenite::{Message, Result};
use tokio_tungstenite::{
accept_async,
tungstenite::{Error, Message, Result},
};

async fn accept_connection(peer: SocketAddr, stream: TcpStream) {
if let Err(e) = handle_connection(peer, stream).await {
Expand Down
10 changes: 6 additions & 4 deletions examples/server-custom-accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ use hyper::{
use futures_channel::mpsc::{unbounded, UnboundedSender};
use futures_util::{future, pin_mut, stream::TryStreamExt, StreamExt};

use tokio_tungstenite::WebSocketStream;
use tungstenite::{
handshake::derive_accept_key,
protocol::{Message, Role},
use tokio_tungstenite::{
tungstenite::{
handshake::derive_accept_key,
protocol::{Message, Role},
},
WebSocketStream,
};

type Tx = UnboundedSender<Message>;
Expand Down
2 changes: 1 addition & 1 deletion examples/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use futures_channel::mpsc::{unbounded, UnboundedSender};
use futures_util::{future, pin_mut, stream::TryStreamExt, StreamExt};

use tokio::net::{TcpListener, TcpStream};
use tungstenite::protocol::Message;
use tokio_tungstenite::tungstenite::protocol::Message;

type Tx = UnboundedSender<Message>;
type PeerMap = Arc<Mutex<HashMap<SocketAddr, Tx>>>;
Expand Down

0 comments on commit 1c97eb7

Please sign in to comment.