@@ -1,6 +1,7 @@
package conn
import (
+ "fmt"
"net"
)
@@ -13,6 +14,19 @@ const (
ResponseMsg
+func (t MsgType) String() string {
+ switch t {
+ case PingMsg:
+ return "PingMsg"
+ case RequestMsg:
+ return "RequestMsg"
+ case ResponseMsg:
+ return "ResponseMsg"
+ default:
+ return fmt.Sprintf("Unknown MsgType (%d)", t)
+ }
+}
+
// 连接接口,代表一个原始的连接
type Connect interface {
WriteAuthInfo(channel string, auth []byte) (err error)
package tinymq
"regexp"
"time"
@@ -46,6 +47,19 @@ const (
Closed
+func (t ConnectState) String() string {
+ case Disconnected:
+ return "Disconnected"
+ case Connected:
+ return "Connected"
+ case Closed:
+ return "Closed"
+ return fmt.Sprintf("Unknown ConnectState (%d)", t)
// 请求数据包
type RequestData struct {
Id uint16