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

Events from non-widgets. #87

Open
lighth7015 opened this issue Jul 23, 2016 · 6 comments
Open

Events from non-widgets. #87

lighth7015 opened this issue Jul 23, 2016 · 6 comments

Comments

@lighth7015
Copy link

Hi,

I'm looking at implementing a networking layer in the sample application, however I'm not sure how to integrate it with the rest of TB, such that my TB application can reliably receive packets as they are picked up by my networking stack.

@codecat
Copy link
Contributor

codecat commented Jul 23, 2016

I'm not entirely sure what you mean with this, do you want to send TB events over the network and have them get handled remotely?

@lighth7015
Copy link
Author

lighth7015 commented Jul 23, 2016

Apologies for not being clearer. I plan to implement two separate networking classes (CNetworkTransport and CPacketIO), to encrypt (or decrypt) a packet format that I've developed transparently. I need to notify my TB application when I'm ready for it to handle a decrypted packet received via CNetworkTransport.

@codecat
Copy link
Contributor

codecat commented Jul 23, 2016

Right, so I'm guessing what you actually want to know is whether TB is thread-safe, or how to make sure it works properly across threads?

@lighth7015
Copy link
Author

lighth7015 commented Jul 23, 2016

Actually, I was planning on using select(3) or WaitForMultipleObjects() for timeouts to let it all run inside the same thread. But I would have to use semaphores if I was planning on cross-thread access, I would assume. :p

@codecat
Copy link
Contributor

codecat commented Jul 24, 2016

So, to come back to this question, if you want to send a custom event to some widget, you just find the widget and call InvokeEvent() on it. For custom events, it's suggested you use EVENT_TYPE_CUSTOM as the event type after inheriting from TBWidgetEvent if needed (take a look at how TBWidgetEventFileDrop does it, except use EVENT_TYPE_CUSTOM instead of EVENT_TYPE_FILE_DROP). You can use ref_id as an extra identifier for your event.

Well, I don't know what kind of events you want to send to widgets, but I don't really see the point in manually sending click events, so I'm assuming you mean custom events.

Also, from what I can see in the source, this is not thread-safe, so you should make sure you're on the same thread as TB is operating on.

@lighth7015
Copy link
Author

Yeah, that's why I'm going to be using select(3) (POSIX) and WaitForMultipleObjects() (Windows) to ensure the application remains responsive.

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

2 participants