Skip to content
Snippets Groups Projects
Select Git revision
  • c7537c3f747fc9d5949f16f7796ed86c5bd65e50
  • dev default protected
  • vainamoinen197-transactiondocument-replace-vec-fields-by-smallvec-2
  • dvermd/200-keypairs-dewif
  • elois/wot
  • jawaka/155-dbex-add-dump-fork-tree-command
  • elois/195-bcdbwriteop
  • elois/deps-crypto
  • elois/gva-monetary-mass
  • elois/191-sled
  • elois/195
  • ji_emme/gva-humantimefield
  • 184-gva-rename-commontime-field-to-blockchaintime
  • ji_emme/182-gva-implement-block-meta-data
  • ji_emme/rml14
  • hugo/151-ws2pv2-sync
  • ji_emme/181-gva-implement-identity-request
  • ji_emme/89-implement-client-api-gva-graphql-verification-api
  • logo
  • test-juniper-from-schema
  • elois/exemple-gva-global-context
  • v0.2.0-a4 protected
  • v0.2.0-a2 protected
  • v0.2.0-a protected
  • v0.1.1-a1 protected
  • documents/v0.10.0-b1 protected
  • crypto/v0.4.0-b1 protected
  • crypto/v0.3.0-b3 protected
  • crypto/v0.3.0-b2 protected
  • crypto/v0.3.0-b1 protected
  • wot/v0.8.0-a0.9 protected
  • wot/v0.8.0-a0.8 protected
  • 0.1.0-a0.1 protected
  • v0.0.1-a0.12 protected
  • v0.0.1-a0.11 protected
  • v0.0.1-a0.10 protected
  • v0.0.1-a0.9 protected
  • v0.0.1-a0.8 protected
  • v0.0.1-a0.7 protected
  • v0.0.1-a0.6 protected
  • v0.0.1-a0.5 protected
41 results

mod.rs

Blame
  • mod.rs 4.27 KiB
    //  Copyright (C) 2018  The Durs Project Developers.
    //
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU Affero General Public License as
    // published by the Free Software Foundation, either version 3 of the
    // License, or (at your option) any later version.
    //
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU Affero General Public License for more details.
    //
    // You should have received a copy of the GNU Affero General Public License
    // along with this program.  If not, see <https://www.gnu.org/licenses/>.
    
    //! WS2P connections controllers.
    
    //use constants::*;
    use dubp_documents::Blockstamp;
    use dup_crypto::hashs::Hash;
    use ws::Sender;
    //use dup_crypto::keys::*;
    use durs_network_documents::network_peer::PeerCardV11;
    use durs_network_documents::*;
    use durs_ws2p_messages::v2::api_features::WS2PFeatures;
    use durs_ws2p_messages::v2::connect::WS2Pv2ConnectType;
    use durs_ws2p_messages::*;
    //use std::sync::mpsc;
    use std::time::SystemTime;
    
    pub mod handler;
    pub mod incoming_connections;
    pub mod outgoing_connections;
    
    /// Order transmitted to the controller
    #[derive(Debug, Clone)]
    pub enum Ws2pControllerOrder {
        /// Give a message to be transmitted
        SendMsg(Box<WS2PMessage>),
        /// Close the connection
        Close,
    }
    
    /// Store a websocket sender
    pub struct WsSender(pub Sender);
    
    impl ::std::fmt::Debug for WsSender {
        fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
            write!(f, "WsSender {{ }}")
        }
    }
    
    #[derive(Debug, Copy, Clone, PartialEq)]
    /// WS2P connection state
    pub enum WS2PConnectionState {
        /// Never try to establish this connection
        NeverTry,
        /// Try to open websocket
        TryToOpenWS,
        /// Websocket error
        WSError,
        /// Try to send connect message
        TryToSendConnectMsg,
        /// Endpoint unreachable
        Unreachable,
        /// Waiting connect message
        WaitingConnectMsg,
        /// No response
        NoResponse,
        /// Negociation timeout