2022-10-11 17:36:09 +08:00
|
|
|
package network
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math/rand"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2023-04-05 16:15:59 +08:00
|
|
|
// ConnState represents the state of the connection.
|
|
|
|
type ConnState = string
|
2022-10-11 17:36:09 +08:00
|
|
|
|
|
|
|
// ConnState represents the state of a connection.
|
|
|
|
const (
|
2023-04-05 16:15:59 +08:00
|
|
|
ConnStateReady ConnState = "Ready"
|
|
|
|
ConnStateDisconnected ConnState = "Disconnected"
|
|
|
|
ConnStateConnecting ConnState = "Connecting"
|
|
|
|
ConnStateConnected ConnState = "Connected"
|
|
|
|
ConnStateClosed ConnState = "Closed"
|
2022-10-11 17:36:09 +08:00
|
|
|
)
|
|
|
|
|
2023-04-05 20:55:23 +08:00
|
|
|
// Prefix is the prefix for logger.
|
|
|
|
const (
|
|
|
|
ClientLogPrefix = "\033[36m[network:client]\033[0m "
|
|
|
|
ServerLogPrefix = "\033[32m[network:server]\033[0m "
|
|
|
|
ParseFrameLogPrefix = "\033[36m[network:stream_parser]\033[0m "
|
|
|
|
)
|
|
|
|
|
2022-10-11 17:36:09 +08:00
|
|
|
func init() {
|
|
|
|
rand.Seed(time.Now().Unix())
|
|
|
|
}
|