<commit_before>extern crate websocket;

use futures::future::Future;
use futures::stream::Stream;
use self::websocket::{WebSocketError};

use std::rc::Rc;
use std::cell::RefCell;

use self::websocket::server::upgrade::async::IntoWs;

use super::{Peer, io_other_error, BoxedNewPeerFuture, box_up_err};
use super::ws_peer::{WsReadWrapper, WsWriteWrapper, PeerForWs};

pub fn ws_upgrade_peer(inner_peer : Peer) -> BoxedNewPeerFuture {
    let step1 = PeerForWs(inner_peer);
    let step2 : Box<Future<Item=self::websocket::server::upgrade::async::Upgrade<_>,Error=_>> = step1.into_ws();
    let step3 = step2
        .map_err(|(_,_,_,e)| WebSocketError::IoError(io_other_error(e)) )
        .and_then(|x| {
            x.accept().map(|(y,_)| {
                info!("Incoming websocket connection");
                let (sink, stream) = y.split();
                let mpsink = Rc::new(RefCell::new(sink));<commit_msg>Improve logging for websocket server<commit_after>extern crate websocket;

use futures::future::Future;
use futures::stream::Stream;
use self::websocket::{WebSocketError};

use std::rc::Rc;
use std::cell::RefCell;

use self::websocket::server::upgrade::async::IntoWs;

use super::{Peer, io_other_error, BoxedNewPeerFuture, box_up_err};
use super::ws_peer::{WsReadWrapper, WsWriteWrapper, PeerForWs};

pub fn ws_upgrade_peer(inner_peer : Peer) -> BoxedNewPeerFuture {
    let step1 = PeerForWs(inner_peer);
    let step2 : Box<Future<Item=self::websocket::server::upgrade::async::Upgrade<_>,Error=_>> = step1.into_ws();
    let step3 = step2
        .map_err(|(_,_,_,e)| WebSocketError::IoError(io_other_error(e)) )
        .and_then(|x| {
            info!("Incoming connection to websocket: {}",x.request.subject.1);
            debug!("{:?}", x.request);
            debug!("{:?}", x.headers);
            x.accept().map(|(y,headers)| {
                debug!("{:?}", headers);
                info!("Upgraded");
                let (sink, stream) = y.split();
                let mpsink = Rc::new(RefCell::new(sink));
{'fraction_non_alphanumeric': 0.1720747295968535, 'fraction_numerical': 0.005408062930186824, 'mean_word_length': 4.1002506265664165, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1033509', 'n_tokens_mistral': 707, 'n_tokens_neox': 679, 'n_words': 118}