Detecting Printer State Change with Cups Api - c

Using the Cups c api I am able to see the state of a printer (such as paused, printing, jammed ect.) What I am trying to do now is to listen for, or lock against a change in a printer's state. Ultimately I want a live view of a printers state, but I don't want to have a delay loop spamming cups with printer attribute requests.
I have seen many functions and tags in the source code and documentation that hint towards some kind of event system, but I have been unable to figure out how to utilize it. Any help is welcome, even just pointing me towards the right function.
I used this example in my current implementation to get state information. http://cups-dev.easysw.narkive.com/9RO0OBnZ/how-to-get-printer-status-via-cups-api

It ends up this was a very complex question and involved a lot of work to figure out. The only sane way I found to listen for changes was to use the rss notification system. I would advise against attempting to make your own notification module, I wasted a week of my life trying that (I'm not even sure it is possible anymore). Use the Create-Printer-Subscription with a uri like rss://localhost:8000. You will of course need a listener waiting for the xml data.
I put up an a simple debugging tool I made with java/jna here. Select 2 to set up a subscription, you will need to listen for the data yourself though.

Related

Locking while front-end waits on response from backend

End users in our react application have the ability to make payments to loans via a pop up. The initial problem that we encountered is that users could click the pay button twice (or heaven forbid more than twice) and this would create multiple payments throwing our accounting into disarray. We thus implemented a sort of lock state that, when triggered to true, shows a loading gif displayed in a div with a simple tweak of the z-index. The state is passed down to the pop up from 2 components above. Every now and then I get an error message displaying that there is a possible memory leak. I assume this has something to do with my fix.
I'm just wondering, is there best practice on how to handle this sort of "locking" situation with react while waiting on some other external system to respond? I've tried to do this via the front-end but I'm not 100% convinced that it's the best and/or only solution.
If you need some code to better illustrate the scenario then let me know and I'll work on adding some examples.
Thanks in advance for your advice!
There's plenty of ways of doing this. You could even had multiple layers to the process. On top of layering the page using a z-indexed loading screen, you could also disable the button depending on some form of state change.
Also, the memory leak could be from you not disposing everything after the life cycle of a particular hook ends. I would suggest you look at using useEffect as a starting point. There's a good chance that either your modal or loading indicator is causing this. Often times, this can be fixed by adding a dependency array to useEffect. Obviously, I am making a lot of assumptions here.

how to implement rules and events for form tracking in adobe Launch?

I am new to adobe Analytics. I am trying to track form errors that are occurring when the user submitting the form without filling the required fields.
So here what I did was, passed form values to list prop to capture the values. But I am not getting how to implement events to track against these values.
Can anyone please help me with how to implement rules and events in the adobe launch for tracking?
Yes, there are a few ways to do it.
The recommended way is to ask the Front-end team to send an error event that Launch can listen to. It can be done in a few ways. It's considered the best practice to install the adobeDataLayer extension: https://experienceleague.adobe.com/docs/launch/using/extensions-ref/adobe-extension/acdl/overview.html?lang=en
The extension provides ability to use a dataLayer very similar to GTM. Very comfortable.
The other way to do it is ask the devs to send a simple JS customEvent with error details in the detail property of the event.
Launch can natively listen to JS events and gives access to the event object.
Finally, the worst kind of implementation, that should be mostly considered as a hack, is the become visible trigger:
you're supposed to detect the actual error message with this trigger. I suggest not using it since the enters viewport listener is a bit heavy. And it also depends on the DOM structure since you'll have to provide the CSS selector for the error message.
This is not all, surely. You can build your own settimeout polling logic to look for the errors manually, or ask devs to send direct calls, but those are even worse solutions, so I'm not elaborating on them.

Get full call stack of all of the relevant methods in Redux

I have a Redux app and I am using redux-dev-tools for its debugging primarily. Unfortunately its often not enough to debug and get clear vision of which methods call which. I am looking for a way to see all of the methods called from the point I change something on the screen to the point where the updates stop. What I want to see is just a set of the relevant methods called with their lines of codes in the app. redux-dev-tools just shows the dispatched actions and then changes in the state (trace - is useful but thats very little), but thats not enough for me: I want to know full call stack excluding what is done behind the scenes by the redux itself. Are there any tools for that? How would you approach the issue? The ideal case would be the generation of some kind of chart with the call stack and lines of codes.
I can have such a situation when an action is triggered, then asynchronous request runs, then half of the page gets updated and redrawn, then another request happens, etc. I want to know better the call stack in this case. Or imagine if a single button click causes several requests to run and multiple actions to be dispatched, etc. Its for overcomplicated cases. I need to have clear diagrams/methods for better debugging and optimization.

Getting the AudioCall in a Lync Conference via UCMA

I'm looking for a way to get a references to AudioCalls in existing conferences via a Lync UCMA application so that I can change the audio routing for participants of a conference without them having to join via a bot and setting up back-to-back calls.
Does anyone have any idea how this might be achieved?
MSDN
In order for a UCMA application to turn a call into a conference in this manner, however, it must be involved from the beginning. All of the messages that are passed back and forth between the two call participants in setting up the call must be routed through the UCMA application. This is because there is no way for a UCMA application to “intervene” in a two-party call where it is not a participant.
From my understanding a call to a conference is still a 2-way call, so this would be not possible. There are also some other posts on the topics of transfering calls from 1 conference to the other. One of them (i'm sure) states that when you transfer the call without a back-to-back to the other conference, you have no way of getting it back in again. So that underlines this would be not possible.
Edit - link
Now, keep in mind that this process is not repeatable. When you transfer the call using AudioVideoMcuSession.BeginTransfer, you are pulling it out of the back-to-back arrangement, and your application will no longer have a handle to the call. The Call object you have will go into the Terminated state and the caller will once again become a remote participant, completely out of your grasp.
(And PLZ let me know if i'm wrong :) )

Need ideas on retrieving data from a website

I'm stumped and need some ideas on how to do this or even whether it can be done at all.
I have a client who would like to build a website tailored to English-speaking travelers in a specific country (Thailand, in this case). The different modes of transportation (bus & train) have good web sites for providing their respective information. And both are very static in terms of the data they present (the schedules rarely change). Here's one of the sites I would need to get info from: train schedules The client wants to provide users the ability to search for a beginning and end location and determine, using the external website's information, how they can best get there, being provided a route with schedule times for the different modes of chosen transport.
Now, in my limited experience, I would think the way to do that would be to retrieve the original schedule info from the external site's server (via API or some other means) and retain the info in a database, which can be queried as needed. Our first thought was to contact the respective authorities to determine how/if this can be done, but this has proven to be problematic due to the language barrier, mainly.
My client suggested what is basically "screen scraping", but that sounds like it would be complicated at best, downloading the web page(s) and filtering through the HTML for relevant/necessary data to put into the database. My worry is that the info on these mainly static sites is so static, that the data isn't even kept in a database to build the page and the web page itself is updated (hard-coded) when something changes.
I could really use some help and suggestions here. Thanks!
Screen scraping is always problematic IMO as you are at the mercy of the person who wrote the page. If the content is static, then I think it would be easier to copy the data manually to your database. If you wanted to keep up to date with changes, you could then snapshot the page when you transcribe the info and run a job to periodically check whether the page has changed from the snapshot. When it does, it sends an email for you to update it.
The above method could also be used in conjunction with some sort of screen scaper which could fall back to a manual process if the page changes too drastically.
Ultimately, it is a case of how much effort (cost) is your client willing to bear for accuracy
I have done this for the following site: http://www.buscatchers.com/ so it's definitely more than doable! A key feature of a web scraping solution for travel sites is that it must send you emails if anything went wrong during the scraping process. On the site, I use a two day window so that I have two days to fix the code if the design changes. Only once or twice have I had to change my code, and it's very easy to do.
As for some examples. There is some simplified source code here: http://www.buscatchers.com/about/guide. The full source code for the project is here: https://github.com/nicodjimenez/bus_catchers. This should give you some ideas on how to get started.
I can tell that the data is dynamic, it's to well structured. It's not hard for someone who is familiar with xpath to scrape this site.

Resources