Skip to content

Commit 9635658

Browse files
author
Lapp
committed
app/client: refactored code, added condition in data entry check
1 parent 5648253 commit 9635658

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cmd/app/client/main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ func main() {
2828
logrus.Fatal(err)
2929
}
3030

31-
id := string(msg)
32-
3331
client := jsonrpc.NewClient(ws.UnderlyingConn())
3432
defer client.Close()
3533

34+
id := string(msg)
3635
go getUnreadMessages(id, client)
3736

3837
fmt.Println(
@@ -56,7 +55,7 @@ func main() {
5655
fmt.Println("Ваш id:", id)
5756
default:
5857
sending := strings.Split(text, " %$4^b ")
59-
if len(sending) == 0 {
58+
if len(sending) == 0 || len(sending) > 2 {
6059
logrus.Error("Неккоректный формат входных данных")
6160
continue
6261
}
@@ -75,7 +74,9 @@ func getUnreadMessages(id string, client *rpc.Client) {
7574
var result *[]string
7675
if err := client.Call("Handler.GetMessages", args, &result); err != nil {
7776
logrus.Fatal(err)
78-
} else if len(*result) != 0 {
77+
}
78+
79+
if len(*result) != 0 {
7980
for _, msg := range *result {
8081
logrus.Println(msg)
8182
}

0 commit comments

Comments
 (0)