xmpp/status.go
changeset 166 8093a2da46db
parent 163 3f891f7fe817
child 167 7ce61108ed86
--- a/xmpp/status.go	Mon Sep 30 20:35:17 2013 -0600
+++ b/xmpp/status.go	Wed Oct 02 23:22:27 2013 -0600
@@ -6,6 +6,51 @@
 	"fmt"
 )
 
+// Status of the connection.
+type Status int
+
+const (
+	statusUnconnected = iota
+	statusConnected
+	statusConnectedTls
+	statusAuthenticated
+	statusBound
+	statusRunning
+	statusShutdown
+	statusError
+)
+
+var (
+	// The client has not yet connected, or it has been
+	// disconnected from the server.
+	StatusUnconnected Status = statusUnconnected
+	// Initial connection established.
+	StatusConnected Status = statusConnected
+	// Like StatusConnected, but with TLS.
+	StatusConnectedTls Status = statusConnectedTls
+	// Authentication succeeded.
+	StatusAuthenticated Status = statusAuthenticated
+	// Resource binding complete.
+	StatusBound Status = statusBound
+	// Session has started and normal message traffic can be sent
+	// and received.
+	StatusRunning Status = statusRunning
+	// The session has closed, or is in the process of closing.
+	StatusShutdown Status = statusShutdown
+	// The session has encountered an error. Otherwise identical
+	// to StatusShutdown.
+	StatusError Status = statusError
+)
+
+func (s Status) fatal() bool {
+	switch s {
+	default:
+		return false
+	case StatusShutdown, StatusError:
+		return true
+	}
+}
+
 type statmgr struct {
 	newStatus   chan Status
 	newlistener chan chan Status