GithubHelp home page GithubHelp logo

Comments (6)

jtroo avatar jtroo commented on August 18, 2024 1

I did a little bit of hacking around to expose the names of the layers to the main struct, but ideally I think it would be nice to have a vec of parsed layers made available in the main struct which you could access a .name member of as a String

Combining the layer strings and layer names into a single struct would be good since they are currently Vecs of the same length. Nothing needs the fully parsed layer at this time, but it can be added later if needed.

pub struct LayerInfo {
    pub name: String,
    pub cfg_text: String,
}

I would also move the TCP client handling code out of check_handle_layer_change and instead write the EventNotification to a channel, with a separate thread listening on the channel writing to the TCP clients. The fn check_handle_layer_change is part of the processing loop that handles and writes OS events, so it would be good to keep the TCP writing out of that loop.

from kanata.

jtroo avatar jtroo commented on August 18, 2024

First cut of outputs that would be sent:

  • layer change
  • custom event (single string only)

from kanata.

LGUG2Z avatar LGUG2Z commented on August 18, 2024

Is there a preference for the communication protocol that should be used and how/where receivers should be configured? I was thinking that one or more local TCP server addresses could be passed to kanata as command-line options on startup but I wanted to open it up for discussion before I start hacking around.

from kanata.

jtroo avatar jtroo commented on August 18, 2024

I have no preference for protocol as long as it's a commonly used one.

Rather than taking a command line option, perhaps it would be better to put it into the configuration file? I don't imagine a user would want to change it frequently, though I could be mistaken in this. I don't have a strong preference either way though.

from kanata.

LGUG2Z avatar LGUG2Z commented on August 18, 2024

I have just thrown together something minimally functioning on a branch here. I'm currently starting the binary with a --port flag which is otherwise given a random default value.

Using a basic TCP client in Python, I'm able to receive events:

import socket

client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)

ip=socket.gethostbyname("localhost")
port=9999
address=(ip,port)
client.connect(address)
while True:
    data = client.recv(1024)
    print(data.decode("utf-8"))
{"LayerChange":{"old":"ff","new":"qwerty"}}
{"LayerChange":{"old":"qwerty","new":"ff"}}
{"LayerChange":{"old":"ff","new":"qwerty"}}
{"LayerChange":{"old":"qwerty","new":"ff"}}
{"LayerChange":{"old":"ff","new":"qwerty"}}
{"LayerChange":{"old":"qwerty","new":"ff"}}

For this initial implementation I'm serializing the events as JSON with serde_json and sending them as bytes to be decoded on the client side; I'm not sure if there are any other serialization formats you'd be interested in for this functionality.

I did a little bit of hacking around to expose the names of the layers to the main struct, but ideally I think it would be nice to have a vec of parsed layers made available in the main struct which you could access a .name member of as a String.

It's still pretty rough so take a look and let me know what you'd like me to change and how to fit in better with the rest of the codebase.

from kanata.

LGUG2Z avatar LGUG2Z commented on August 18, 2024

I've updated what I have on my branch, I'll open a PR so that you can annotate the changes with any further comments directly.

from kanata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.