github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/protocol/networking-status.go (about)

     1  /* For license and copyright information please see the LEGAL file in the code repository */
     2  
     3  package protocol
     4  
     5  type Network_Status interface {
     6  	Status() NetworkStatus     // return last connection||stream status
     7  	State() chan NetworkStatus // return status channel to listen to new connection||stream status. for more than one listener use channel hub(repeater)
     8  
     9  	// SetStatus is low level API that must use very carefully and usually in not services layer.
    10  	// It is Non-Blocking operation. Change status of stream and send notification on stream StateChannel.
    11  	SetStatus(ns NetworkStatus)
    12  }
    13  
    14  // NetworkStatus indicate connection and stream state
    15  type NetworkStatus uint32
    16  
    17  // Connection States
    18  const (
    19  	NetworkStatus_Unset NetworkStatus = iota // State not set yet
    20  
    21  	NetworkStatus_New          // means connection not saved yet to storage
    22  	NetworkStatus_Loaded       // means connection load from storage
    23  	NetworkStatus_Unregistered //
    24  
    25  	NetworkStatus_Opening // connection||stream plan to open and not ready to accept stream
    26  	NetworkStatus_Open    // connection||stream is open and ready to use
    27  	NetworkStatus_Closing // connection||stream plan to close and not accept new stream
    28  	NetworkStatus_Closed  // connection||stream had been closed
    29  
    30  	NetworkStatus_NotResponse // peer not response to recently send request
    31  	NetworkStatus_RateLimited // connection||stream limited due to higher usage than permitted
    32  	NetworkStatus_Timeout     // connection||stream timeout(DeadlineExceeded) and must close
    33  
    34  	NetworkStatus_BrokenPacket
    35  	NetworkStatus_NeedMoreData
    36  	NetworkStatus_Sending
    37  	NetworkStatus_Receiving
    38  	NetworkStatus_ReceivedCompletely
    39  	NetworkStatus_SentCompletely
    40  
    41  	NetworkStatus_Encrypted
    42  	NetworkStatus_Decrypted
    43  	NetworkStatus_Ready
    44  	NetworkStatus_Idle
    45  
    46  	NetworkStatus_Blocked
    47  	NetworkStatus_BlockedByPeer
    48  
    49  	// Each package can declare it's own state with NetworkStatus > 127 e.g. tcp: TCP_SYN_SENT, TCP_SYN_RECV, ...
    50  )