I'm trying to build a simple VB.NET/Express 2012 windows application that will be able to receive a POST or JSON object with two parameters:
an XML document
an array or object of parameters
It will get its data from a front-end through JavaScript. That on itself makes a query to the back-end getting the needed info and will then trigger a print task on the local machine where this software is running using a local port to 'talk' to the local application.
I'm just looking for the components to use or some simple examples. Preferably I'd like to run a background TCP listening service that works on it's own (possibly a threaded task inside the application) and fires an event when needed.
Please, remember that it has to be made on the Express version of Visual Studio. I do not have all the extended possibilities the regular Studio has.
All the help is appreciated.
BTW, I've found This thread and this one, but they don't seem to going in the direction I'm wanting to go, as in that they run a continuous loop that seems to disable any and all other input or interaction unless you quit (kill) the application.
[edit]
I'm not creating a web application/server - I'm using a PHP solution for that. It's supposed to be a sort-of printserver.
[/edit]
Related
I've developed an application that I would like to use meteor.js for real time updates (I want to enhance but not change my program, for example when a user adds a comments make it update in real-time ) . Problem is meteor.js uses node.js (so javascript as server-side code). I use LAMP stack, Is it possible to get PHP to feed data into meteor.js from mysql.
Meteor is more than just an 'interactive webapplication'-builder or javascript framework. The idea is to have only one programming language (besides HTML/CSS for markup) to do all the work. Basically it creates a 'remote server' (in the clients browser) it can push data to and at the same time it publishes various API's to the users system. The data passed through these API's / connections has a specific structure which has to be adhered at all time.
Meteor is built around NodeJS, which makes it hard (if not impossible) to run it without this backend. Sure you can try to mimic the backend using PHP, but it would be a waste of time. Reading your question you'll be better of using a javascript framework like jQuery or Prototype. Unlike Meteor you will need to do the AJAX calls (POST & CallBack) yourself, but you can actually decide which backend you want to use yourself (including PHP / MySQL).
If you want to do this anyway you need to check the Meteor & NodeJS source code to see what the minimum requirements are to make Meteor run under PHP. The PHP stack has to interpret the commands Meteor sends and receivers, but this won't be an easy task.
You can use comet (or reverse ajax) for realtime updates.
Trying to marry node.js with PHP doesn't sound like a worthwhile path to go down. If someone insisted on using a system like Meteor.js, yet with a PHP back-end, it would make more sense to look at AngularJS which is mainly the client side.
Of course, that is different technology stack. If someone really insisted on the blending, one could consider using server side sockets to interact with PHP Web services; and/or use mongodb and/or mysql-node to interact with the same databases.
I released a meteorite package that interacts with a Wordpress site that has the Wordpress JSON API. A quick fix. For now.
Comes with a backend call that will return the raw data, or a publication that stores the posts using their id's instead of a randomly generated mongoid. And some basic templates to get you started including a Session variable that keeps track of the currently selected post.
I'm working on it a lot more and will eventually have a version that directly makes mysql calls from node so you won't need php or Wordpress; just the ability to access the mysql database (which can be remote, with the appropriate configuration, or on the same machine).
I am using nodeJs and the express, express-handlebars and mqtt packages.
I am recently trying to update a table which shows the content of the current temperature outside and inside. This table is only a part of the website making it worth striving to just update this particular talbe each second.
Therefore, using does not seem like the right answer for me and also harms the ability to set settings and click on a link.
I have already tried using the Query .load function which indeed works but does not work properly together with express-handelbars. Instead of the content transmitted to my server via MQTT, {{temperatureInside}} and {{temperatureOutside}} is shown on the website.
Any ideas how to solve this problem?
In the case that you want the table to be updated automatically, that means you need the server to tell the front end that there is new data. This is not possible with standard HTTP requests, which is why some clever person built Websockets (WSS protocol). Using Node, a the library I use for this is socket.io
socket.io has code that needs to be both imported on the front end (tells your client how to talk through WSS) and required on the Node side (npm install socket.io --save)
From there, you can set up custom events that both your server and client understand. I'll leave you to go through the docs, but socket.io would certainly do the trick for you. I've used it in many similar circumstances.
I'm trying to wrap my head around how Electron (formerly Atom Shell) works.
I'm coming from a traditional, MVC-style web application where a Browser is calling a Controller Action through a Routing System, the Controller then fetches data from a store (File System, Data Base, ...) and renders a View, which is sent back to the Browser. Some Actions may be sending back JSON instead, as they are called through JavaScript/AJAX instead of the Browser actually navigating to them.
I want to create that, but as a Cross-Platform Desktop Application. I know that Atom Shell combines both a Chromium-Browser and a Node.js/v8 runtime, but I'm not sure how they would communicate.
I guess I could run a full on web server (basically, some Node.js HTTP Middleware like Express), but that creates a network-reachable server (which might also trip up firewalls) - one of the reasons I want to make a desktop app is precisely to avoid running a real server. Basically like the MVP/MVVM pattern in a "normal" desktop app.
Can someone give me a few starting points for what I'm trying to do? How would the browser talk to the node runtime (the "Client" as they call it?) to tell it "Hey, fetch my the record with ID 12345" and would the Client return rendered HTML, or would the browser just get a blob of JSON back and render it through a JavaScript templating engine?
Electron doesn't seem to use Node.js as a web server but merely as an environment to run background JavaScript code, this code can use node modules to access the system. At the same time Chromium provides a user interface for the app, it displays regular web pages that run usual sandboxed JavaScript. Both are being embedded by the Electron executable, the former directly (Node.js can be built as a static library), the latter via libchromiumcontent. In a way, Node.js is the controller part of the application whereas Chromium is the view.
Typically, the concept used for web pages here is that of single-page applications: a web page represents one application window and as such it stays around as long as this window is visible (often for the entire lifetime of the application). Whenever it needs to display something different it requests data from the background code running in Node.js, just like AJAX applications request data from the server. The page itself is not reloaded, usually JavaScript templating will be used to update contents.
There isn't really a server/client relationship here however, the communication can actually go both ways. Both sides can use the ipc module to send messages to each other (main process, renderer). These messages can have any arguments attached to them, these don't need to be encoded explicitly (typically this is implemented by using JSON internally to encode parameters, I didn't verify whether that's the case with Electron). Internally, that message passing is implemented via platform-specific IPC mechanisms, using libuv to be exact.
We implemented fully functional nodejs server & angular UI with sqlite3, sequelize ORM using
*. https://github.com/theallmightyjohnmanning/electron-express
Some of the Projects helped us lot:
Framework: https://github.com/angular-fullstack/generator-angular-fullstack
Windows Packaging: electron-packager": "github:electron-userland/electron-packager"
Creating Shortcuts and Auto Update: "electron-squirrel-startup": "^1.0.0",
Creating Release Installer: "electron-winstaller": "^2.3.4",
I would like to setup a web server on my HTPC that I can use to handle various tasks such as changing the default audio output or adjusting the display to output to only one screen without having to actually touch the machine.
While I understand the actual programming may be difficult itself, my main focus is learning how one can go about handling various events. I have initially set up a IIS server and created a site to handle all the events on my HTPC. The site is only accessible through the intranet and knowledge of the specific port. Ideally, the solution would be that you access the HTPC local ip address with the specified port and are presented with options(buttons) to either set default audio device, display etc. (This will probably involve some html programming but it is feasible to leverage a java script or is asp.net the language I should write in)
Any help would be appreciative as I know its possible to set up a server to handle events/requests - I just don't know where to begin or what to start reading up on.
if it can be done via the command line, generally it can be done via asp (on the server).
you need to give the application pool that the website will be running under permissions on your computer to be able to carry out the tasks (if you're lazy and don't care about security make it run as you)
you then simple need to write a process that starts up either a cmd process or powershell instance in the button click event handler.
For powershell, i've followed Jeff Murrs example in the past and had success.
For command line processes it is similar but you use System.Diagnostics.Process.
This should be enough for you to research and hopefully get something
I'm developing a web application with Symfony2. I need to create a push notifications sysmte (like Facebook). When an user publish something, I need some of another users receive a notification.
I saw that Node.js it's the easiest manner to do this. But, I did some simple examples and all works fine, but I don't know how can I integrate this node.js application with my Symfony2 application, or really with a PHP application.
Anybody can help me?
Thanks in advance!
Please note that you've not given enough details, so I will respond as a front-end developer and not as a mobile developer
Integrating NodeJS and PHP (in general) is not a good way since you need to launch both servers separatly, create the websocket server in JS while your application is in PHP and finally create a request (GET or POST) from your PHP to you JS server. Well, a big mess, so I'll expose my solution here under.
Quick insight for mobile apps. Well, technically, there's no easy way. You can use the Push "protocol" (http://www.wikiwand.com/en/Push_technology) with NotificationPusher (https://github.com/Ph3nol/NotificationPusher). I didn't used it before so I can't help you with it.
In general.
Most of the time when people thinks of Push, long polling will do the trick. For starters it means that the request is made client-side and the server don't send data & close connection until there's new data.
How do you implement this ?!?
Basically, you change the max_execution_time using ini_set or set_time_limit to a very long time for the current script and launch a loop (like a do..while) with a sleep and the check to your data inside. From your Javascript just make an Ajax call, for example with jquery: $.get. Just remember to remove the timeout and stay in asynchronous mode.
The only drawback of this solution is that you will always have a connection opened to your server which will consume a bit more of battery on a mobile device. If you have multiple types of data to receive do not hesitate to merge the calls and publish a type in your response data, since most of the browsers allows only 2 or 3 simultaneous connections to the same server.
I sounds like your describing WebSockets.
Take a look at Socket.io, its a module for node.js.
Also there is a example at GitHub https://github.com/Automattic/socket.io/tree/master/examples/chat
Interesting files for you should be the index.js and the public/main.js.
You can see the example live at http://socket.io/demos/chat/