Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send_json will hang forever with incomplete data #14

Open
killown opened this issue Sep 5, 2024 · 0 comments
Open

send_json will hang forever with incomplete data #14

killown opened this issue Sep 5, 2024 · 0 comments

Comments

@killown
Copy link
Contributor

killown commented Sep 5, 2024

from wayfire import WayfireSocket
import json as js
from wayfire.core.template import get_msg_template

def send_json_with_incomplete_data(msg):
    if 'method' not in msg:
        raise Exception("Malformed json request: missing method!")

    data = js.dumps(msg).encode("utf8")
    header = len(data).to_bytes(4, byteorder="little")

    # Send header
    sock.client.send(header)

    # Simulate incomplete data transmission
    incomplete_data = data[:len(data) // 2]  # Send only half of the data
    sock.client.send(incomplete_data)

    while True:
        response = sock.read_message()
        if 'event' in response:
            sock.pending_events.append(response)
            continue

        return response
send_json_with_incomplete_data(get_msg_template("window-rules/list-views"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant