Skip to content

Commit

Permalink
Close conn while json syntax error
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Aug 13, 2021
1 parent 9e5003a commit d7649cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/service/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (h *Handler) Handle() {
err := json.Unmarshal([]byte(pa.Json), &pack)
if err != nil {
h.CheckJSONSyntaxErr(err)
h.Dispose()
continue
}
util.DebugMsg("Handler", "PackTest:0: int:"+strconv.Itoa(pack.Integer)+" msg:"+pack.Msg)
Expand All @@ -79,6 +80,7 @@ func (h *Handler) Handle() {
err := json.Unmarshal([]byte(pa.Json), &pack)
if err != nil {
h.CheckJSONSyntaxErr(err)
h.Dispose()
continue
}
if h.Status != ESTABLISHED {
Expand All @@ -102,6 +104,7 @@ func (h *Handler) Handle() {
err := json.Unmarshal([]byte(pa.Json), &pack)
if err != nil {
h.CheckJSONSyntaxErr(err)
h.Dispose()
continue
}
if h.Status != LOGINED {
Expand Down Expand Up @@ -131,6 +134,7 @@ func (h *Handler) Handle() {
err := json.Unmarshal([]byte(pa.Json), &pack)
if err != nil {
h.CheckJSONSyntaxErr(err)
h.Dispose()
continue
}
if h.Status != LOGINED {
Expand All @@ -157,6 +161,7 @@ func (h *Handler) Handle() {
err := json.Unmarshal([]byte(pa.Json), &pack)
if err != nil {
h.CheckJSONSyntaxErr(err)
h.Dispose()
continue
}

Expand All @@ -179,6 +184,7 @@ func (h *Handler) Handle() {
err := json.Unmarshal([]byte(pa.Json), &pack)
if err != nil {
h.CheckJSONSyntaxErr(err)
h.Dispose()
continue
}
if h.Status != LOGINED {
Expand Down Expand Up @@ -207,6 +213,7 @@ func (h *Handler) Handle() {
err := json.Unmarshal([]byte(pa.Json), &pack)
if err != nil {
h.CheckJSONSyntaxErr(err)
h.Dispose()
continue
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/Const.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package util

var DebugMode = false

const ProtocolVersion = 1003 //0.4
const ProtocolVersion = 1004 //0.5

0 comments on commit d7649cc

Please sign in to comment.