This commit is contained in:
TsMask
2023-08-21 11:02:58 +08:00
parent 788f01674a
commit 4a3e6d7d67
26 changed files with 664 additions and 50 deletions

View File

@@ -11,11 +11,10 @@ type MsgBody struct {
RawData []byte
MsgName string
Msg map[string]string
Keys []string
}
// Decode
// reqLoginAlarm;user=yiy;key=qw#$@;type=msg
//reqLoginAlarm;user=yiy;key=qw#$@;type=msg
func (o *MsgBody) Decode() error {
multi := strings.Split(string(o.RawData), ";")
if len(multi) < 1 {
@@ -32,12 +31,12 @@ func (o *MsgBody) Decode() error {
}
// Pack
// reqLoginAlarm;user=yiy;key=qw#$@;type=msg
//reqLoginAlarm;user=yiy;key=qw#$@;type=msg
func (o *MsgBody) Pack() error {
var multi []string
multi = append(multi, o.MsgName)
for _, key := range o.Keys {
item := fmt.Sprintf("%s=%s", key, o.Msg[key])
for i, v := range o.Msg {
item := fmt.Sprintf("%s=%s", i, v)
multi = append(multi, item)
}
raw := strings.Join(multi, ";")