2018-03-10 21:26:19 +00:00
|
|
|
package connections
|
|
|
|
|
2018-03-15 16:33:26 +00:00
|
|
|
// ConnectionState defines the various states a connection can be in from disconnected to authenticated
|
2018-03-10 21:26:19 +00:00
|
|
|
type ConnectionState int
|
|
|
|
|
2018-03-15 16:33:26 +00:00
|
|
|
// Connection States
|
|
|
|
// DISCONNECTED - No existing connection has been made, or all attempts have failed
|
|
|
|
// CONNECTING - We are in the process of attempting to connect to a given endpoint
|
|
|
|
// CONNECTED - We have connected but not yet authenticated
|
2019-05-15 20:12:11 +00:00
|
|
|
// AUTHENTICATED - im.ricochet.auth-hidden-server has succeeded on the connection.
|
2019-07-19 17:27:50 +00:00
|
|
|
// SYNCED - we have pulled all the messages for groups from the server and are ready to send
|
2018-03-10 21:26:19 +00:00
|
|
|
const (
|
|
|
|
DISCONNECTED ConnectionState = iota
|
|
|
|
CONNECTING
|
|
|
|
CONNECTED
|
|
|
|
AUTHENTICATED
|
2019-07-19 17:27:50 +00:00
|
|
|
SYNCED
|
2018-03-15 20:53:22 +00:00
|
|
|
FAILED
|
2018-05-30 17:41:02 +00:00
|
|
|
KILLED
|
2018-03-10 21:26:19 +00:00
|
|
|
)
|
2018-09-21 18:53:10 +00:00
|
|
|
|
|
|
|
var (
|
2019-01-28 20:09:25 +00:00
|
|
|
// ConnectionStateName allows conversion of states to their string representations
|
2019-07-19 17:27:50 +00:00
|
|
|
ConnectionStateName = []string{"Disconnected", "Connecting", "Connected", "Authenticated", "Synced", "Failed", "Killed"}
|
2021-03-19 21:20:22 +00:00
|
|
|
)
|
2019-05-15 20:12:11 +00:00
|
|
|
|
2021-03-19 21:20:22 +00:00
|
|
|
// ConnectionStateToType allows conversion of strings to their state type
|
|
|
|
func ConnectionStateToType() map[string]ConnectionState {
|
|
|
|
return map[string]ConnectionState{"Disconnected": DISCONNECTED, "Connecting": CONNECTING,
|
2019-07-19 17:27:50 +00:00
|
|
|
"Connected": CONNECTED, "Authenticated": AUTHENTICATED, "Synced": SYNCED, "Failed": FAILED, "Killed": KILLED}
|
2021-03-19 21:20:22 +00:00
|
|
|
}
|