From fd9a93ad1999ff280bfd6b8b5d90a338973ef991 Mon Sep 17 00:00:00 2001 From: rszyma Date: Fri, 23 Feb 2024 17:38:39 +0100 Subject: [PATCH] tcp: update after protocol breaking change https://github.com/jtroo/kanata/commit/9d3d87b50fa80f857ce4cb97b82d6152cf8e9a5a introduced a proper `Error` response, but this breaks current kanata-tray code. After this change previous, as well as new kanata versions should work. --- runner/tcp_client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runner/tcp_client.go b/runner/tcp_client.go index 02b065a..c748fa6 100644 --- a/runner/tcp_client.go +++ b/runner/tcp_client.go @@ -69,7 +69,8 @@ func (c *KanataTcpClient) Connect(ctx context.Context, port int) error { scanner := bufio.NewScanner(c.conn) for scanner.Scan() { var msgBytes = scanner.Bytes() - if bytes.HasPrefix(msgBytes, []byte("you sent an invalid message")) { + // do not change the following condition (because of cross-version compability) + if bytes.Contains(msgBytes, []byte("you sent an invalid message")) { fmt.Printf("Kanata disconnected us because we supposedly sent an 'invalid message' (kanata version is too old?)\n") c.reconnect <- struct{}{} return