xmpp/status.go
changeset 166 8093a2da46db
parent 163 3f891f7fe817
child 167 7ce61108ed86
equal deleted inserted replaced
165:d3182a279bf4 166:8093a2da46db
     3 package xmpp
     3 package xmpp
     4 
     4 
     5 import (
     5 import (
     6 	"fmt"
     6 	"fmt"
     7 )
     7 )
       
     8 
       
     9 // Status of the connection.
       
    10 type Status int
       
    11 
       
    12 const (
       
    13 	statusUnconnected = iota
       
    14 	statusConnected
       
    15 	statusConnectedTls
       
    16 	statusAuthenticated
       
    17 	statusBound
       
    18 	statusRunning
       
    19 	statusShutdown
       
    20 	statusError
       
    21 )
       
    22 
       
    23 var (
       
    24 	// The client has not yet connected, or it has been
       
    25 	// disconnected from the server.
       
    26 	StatusUnconnected Status = statusUnconnected
       
    27 	// Initial connection established.
       
    28 	StatusConnected Status = statusConnected
       
    29 	// Like StatusConnected, but with TLS.
       
    30 	StatusConnectedTls Status = statusConnectedTls
       
    31 	// Authentication succeeded.
       
    32 	StatusAuthenticated Status = statusAuthenticated
       
    33 	// Resource binding complete.
       
    34 	StatusBound Status = statusBound
       
    35 	// Session has started and normal message traffic can be sent
       
    36 	// and received.
       
    37 	StatusRunning Status = statusRunning
       
    38 	// The session has closed, or is in the process of closing.
       
    39 	StatusShutdown Status = statusShutdown
       
    40 	// The session has encountered an error. Otherwise identical
       
    41 	// to StatusShutdown.
       
    42 	StatusError Status = statusError
       
    43 )
       
    44 
       
    45 func (s Status) fatal() bool {
       
    46 	switch s {
       
    47 	default:
       
    48 		return false
       
    49 	case StatusShutdown, StatusError:
       
    50 		return true
       
    51 	}
       
    52 }
     8 
    53 
     9 type statmgr struct {
    54 type statmgr struct {
    10 	newStatus   chan Status
    55 	newStatus   chan Status
    11 	newlistener chan chan Status
    56 	newlistener chan chan Status
    12 }
    57 }