xmpp/xmpp.go
changeset 166 8093a2da46db
parent 164 6b527647086c
child 168 f4ccc2f29777
child 175 fc8702a8572e
equal deleted inserted replaced
165:d3182a279bf4 166:8093a2da46db
    31 
    31 
    32 	// DNS SRV names
    32 	// DNS SRV names
    33 	serverSrv = "xmpp-server"
    33 	serverSrv = "xmpp-server"
    34 	clientSrv = "xmpp-client"
    34 	clientSrv = "xmpp-client"
    35 )
    35 )
    36 
       
    37 // Status of the connection.
       
    38 type Status int
       
    39 
       
    40 const (
       
    41 	statusUnconnected = iota
       
    42 	statusConnected
       
    43 	statusConnectedTls
       
    44 	statusAuthenticated
       
    45 	statusBound
       
    46 	statusRunning
       
    47 	statusShutdown
       
    48 	statusError
       
    49 )
       
    50 
       
    51 var (
       
    52 	// The client has not yet connected, or it has been
       
    53 	// disconnected from the server.
       
    54 	StatusUnconnected Status = statusUnconnected
       
    55 	// Initial connection established.
       
    56 	StatusConnected Status = statusConnected
       
    57 	// Like StatusConnected, but with TLS.
       
    58 	StatusConnectedTls Status = statusConnectedTls
       
    59 	// Authentication succeeded.
       
    60 	StatusAuthenticated Status = statusAuthenticated
       
    61 	// Resource binding complete.
       
    62 	StatusBound Status = statusBound
       
    63 	// Session has started and normal message traffic can be sent
       
    64 	// and received.
       
    65 	StatusRunning Status = statusRunning
       
    66 	// The session has closed, or is in the process of closing.
       
    67 	StatusShutdown Status = statusShutdown
       
    68 	// The session has encountered an error. Otherwise identical
       
    69 	// to StatusShutdown.
       
    70 	StatusError Status = statusError
       
    71 )
       
    72 
       
    73 func (s Status) fatal() bool {
       
    74 	switch s {
       
    75 	default:
       
    76 		return false
       
    77 	case StatusShutdown, StatusError:
       
    78 		return true
       
    79 	}
       
    80 }
       
    81 
    36 
    82 // A filter can modify the XMPP traffic to or from the remote
    37 // A filter can modify the XMPP traffic to or from the remote
    83 // server. It's part of an Extension. The filter function will be
    38 // server. It's part of an Extension. The filter function will be
    84 // called in a new goroutine, so it doesn't need to return. The filter
    39 // called in a new goroutine, so it doesn't need to return. The filter
    85 // should close its output when its input is closed.
    40 // should close its output when its input is closed.