@@ -4,7 +4,6 @@ use std::io;
44use std:: convert:: Into ;
55#[ cfg( feature="sync-ssl" ) ]
66use native_tls:: { TlsStream , TlsAcceptor } ;
7- use stream:: Stream ;
87use server:: { WsServer , OptionalTlsAcceptor , NoTlsAcceptor , InvalidConnection } ;
98use server:: upgrade:: sync:: { Upgrade , IntoWs , Buffer } ;
109pub use server:: upgrade:: { Request , HyperIntoWsError } ;
@@ -33,7 +32,8 @@ pub type AcceptResult<S> = Result<Upgrade<S>, InvalidConnection<S, Buffer>>;
3332///extern crate websocket;
3433///# fn main() {
3534///use std::thread;
36- ///use websocket::{Server, Message};
35+ ///use websocket::Message;
36+ ///use websocket::sync::Server;
3737///
3838///let server = Server::bind("127.0.0.1:1234").unwrap();
3939///
@@ -54,30 +54,24 @@ pub type AcceptResult<S> = Result<Upgrade<S>, InvalidConnection<S, Buffer>>;
5454///# Secure Servers
5555/// ```no_run
5656///extern crate websocket;
57- ///extern crate openssl ;
57+ ///extern crate native_tls ;
5858///# fn main() {
5959///use std::thread;
6060///use std::io::Read;
6161///use std::fs::File;
62- ///use websocket::{Server, Message} ;
63- ///use openssl::pkcs12::Pkcs12 ;
64- ///use openssl::ssl::{SslMethod, SslAcceptorBuilder, SslStream };
62+ ///use websocket::Message;
63+ ///use websocket::sync::Server ;
64+ ///use native_tls::{Pkcs12, TlsAcceptor };
6565///
6666///// In this example we retrieve our keypair and certificate chain from a PKCS #12 archive,
6767///// but but they can also be retrieved from, for example, individual PEM- or DER-formatted
6868///// files. See the documentation for the `PKey` and `X509` types for more details.
6969///let mut file = File::open("identity.pfx").unwrap();
7070///let mut pkcs12 = vec![];
7171///file.read_to_end(&mut pkcs12).unwrap();
72- ///let pkcs12 = Pkcs12::from_der(&pkcs12).unwrap();
73- ///let identity = pkcs12.parse("password123").unwrap();
72+ ///let pkcs12 = Pkcs12::from_der(&pkcs12, "hacktheplanet").unwrap();
7473///
75- ///let acceptor = SslAcceptorBuilder::mozilla_intermediate(SslMethod::tls(),
76- /// &identity.pkey,
77- /// &identity.cert,
78- /// &identity.chain)
79- /// .unwrap()
80- /// .build();
74+ ///let acceptor = TlsAcceptor::builder(pkcs12).unwrap().build().unwrap();
8175///
8276///let server = Server::bind_secure("127.0.0.1:1234", acceptor).unwrap();
8377///
@@ -116,14 +110,16 @@ impl<S> WsServer<S, TcpListener>
116110 }
117111
118112 /// Changes whether the Server is in nonblocking mode.
113+ /// NOTE: It is strongly encouraged to use the `websocket::async` module instead
114+ /// of this. It provides high level APIs for creating asynchronous servers.
119115 ///
120- /// If it is in nonblocking mode, accept() will return an error instead of blocking when there
121- /// are no incoming connections.
116+ /// If it is in nonblocking mode, accept() will return an error instead of
117+ /// blocking when there are no incoming connections.
122118 ///
123119 ///# Examples
124120 ///```no_run
125121 /// # extern crate websocket;
126- /// # use websocket::Server;
122+ /// # use websocket::sync:: Server;
127123 /// # fn main() {
128124 /// // Suppose we have to work in a single thread, but want to
129125 /// // accomplish two unrelated things:
0 commit comments