server sent events - One client to update them all - php

Alright, so here is what I am trying to achieve. I have a custom built Point of Sale done in VB.net. What I want to add now is a customer facing android tablet that shows the reciept as it's entered into the Point of Sale.
Brainstorming how to do this I came up with the idea to use a php hosted script (no problem as the POS has a mysql-php web backend on a local server) that would use server sent events to update the tablet. The issue I'm facing is I'm not sure how to update the server (and thus the tablet) from another client (this one being the Point of Sale).
I can't seem to find any examples other than clocks for server sent events, does anyone have a link to something similar or perhaps a better solution than what I came up with?
I had considered using an app like idisplay and just extending that way, but it doesn't support windows 8 which is what the POS is running. I also considered websockets, but I don't have a firm enough grasp of that to get it up and running. I could make an app for the tablet, but I don't really want to do that, most of my background with app development is on iOS and I don't personally like java as a development language.
EDIT 1: Alright, so I'm understanding better how I would need to make this work.
So far I have it working where I can input a $_GET variable to change the value and the next time an update is pushed it works properly. I just need to verify there's new or different data before it pushes the data.
Is there a better example than this http://www.html5rocks.com/en/tutorials/eventsource/basics/ concerning how to push updates on demand to the listening clients?

Related

local website connect to wordpress online

Long time reader first time asker, if my question is silly or missing info or miss titled lemme know and I'll fix it.
Okay, so I'm working at a community center for the next 8 weeks as a tech help assistant, I'm also a CS student.
They have a web application that is quite old running locally on an iis server (version 7). It's for keeping track of their members, events and registration It's written in asp.net and is using and Access database. They also have a wordpress website (php, mysql, apache) for advertising events and sharing information about what's going on in the community.
What they would like is to link their wordpress to the local application. I've been racking my brain about if this is even possible or not. I'm leaning towards not possible because the local application and shouldn't be outward facing as it has sensitive data on it and was not designed to be secure in the face of would-be hackers.
The only solution that I could think of is create a "walled off" section of the computer hosting the local application. Also an outward facing port that accepts incoming data from the wordpress site that is then passed onto the access database as an update (increasing a counter for the amount of people registered to a program). It needs to be possible for a file to have some kind of global (from the web) executable permissions and have all the other files on the localhost computer locked down from this global permission.
We would also need to be able to get 2 boolean values from the local app for the wordpress site. This is for if the program/camp/whatever is full and if the update was unsuccessful in the event of something going wrong. I'm just not sure if something like that is even possible and where to start with that. The most important thing is that it's secure.
If a secure API could work I have time to create something like that.
I don't have enough time to upgrade their local system to make it safe enough to be online because I have to run tech help sessions. I know that is the most realistic option.
Thanks very much
What they would like is to link their wordpress to the local
application. I've been racking my brain about if this is even possible
or not. I'm leaning towards not possible because the local application
and shouldn't be outward facing as it has sensitive data on it and was
not designed to be secure in the face of would-be hackers.
I think you've hit the nail on the head right there. It looks like you have a decent understanding of the situation but not of their internal app. The fact is that it's hard to scope something like this without getting in and getting details. Step 1 would be to see if you can talk to whoever it is that built the thing and get their feedback. It might be secure enough to expose some sort of connection.
Really there's not enough information here to determine a good answer, and you should be wary of anyone that says it's secure. There are a ton of factors that go into web security.
You might be able to throw together a basic RESTful API with authentication to send only to the wordpress site's IP. But if it's sharing the IP that information can be consumed by third parties so you'll have to decide if that is an okay risk.
I wouldn't try and expose everything and partition with apache. A basic RESTful API with authentication would be best at first glance IMO. That way you only show consumable data and limit what can be used.

Which Ratchet Component to Use

Brief Explanation...
I started working with Ratchet about 6 hours ago so my question my be a little basic... I have an existing website that has a big counter in the middle of one of the pages. The counter represents how many people have signed up to a particular form.
I would like this counter to update immediately whenever a person signs up to the website. In other words, there must be a web socket set up in order to be alerted when a new person has signed up to the site.
My Question
Before I go ahead and attempt to write the code, I would like to know which Ratchet component I should be using. I have gone through the introductions and tutorials and I think I should be using the WAMP Component but I am not 100% sure, and it is also the only tutorial I wasn't able to get working...
In short, which Ratchet Component should I use to update a counter on a website?
It really depends on what you are trying to accomplish
here's what you need to put in mind:
if you are trying to do a simple websocket application that targets simple 1 server to 1 client communication it is good to use the MessageComponentInterface.
but if you like to do a websocket application that would allow you to send from 1 server to multiple clients it is easier to accomplish this with a WAMP Component.
Your decision would depend on what your application requires.

Web Application on Computer Data with PHP/MySQL

I want to make a computer storage (online) Web Application with PHP/MySQL... I mean where we can keep all the data of computer and all its configuration, up-gradation, problem occured, solved problems and alerts for warranty expires..
Can any one give me the example link where i can gain some idea (The example can be on any platform). I just want to go thru its work-ability..
I gone thru google, but nothing worth..
This company does something like that in their software. It is called asset management. It appears to be done using PHP and Ajax as far as I can tell. I suggest researching Ajax for more info as you will need real-time tracking, i would think. http://www.dapperdesk.com/hd/logina.php

Can a server notify iOS/Android app about changes whitout the users being aware?

I am new in mobile development and I have a project to do and I spent the whole past days searching for solution to a problem until I got lost so I hope I can find the final answer here.
I have a server (php & MySQL DB) and developing a mobile app in iOS + Android that retrieve data from the server. The mobile app should take the data from the server in the first run and save it in the phone so whenever it run again it take the stored data.
The server should notify the app "without the user being aware" whenever a change made so that the app can go and update the data immediately.
I thought about using webservice (probably REST with RestKit) or applying sort of timestamps on the server records, which are all not the problem.
My problem is that I can't find a way to let the server itself notify the app about the changes whenever a change happen and allowing the app then to update the new data. I thought about using push notifications but - specially in iOS - it can't be hidden from the users.
So is there a possible way to do it? is it complex? does it worth? other suggestions?
As I said I am new so maybe my thinking wrong so sorry in that case, and I searched through the questions and couldn't figure out an answer for my question.
Can you explain what you are trying to do?
The classic idiom here would be to update the data when the application is started (you can use the cached version is it's still up-to-date and if the user has no connection)
Why update the data if the user is not aware of it?
At least in iOS, a solution would be to use Apple Push Notifications. If you don't want to be intrusive and want it to be as transparent as possible, you can define what kind of "notifications" signals you want, like this:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
As for the background process, I don't think you would be able to do that. Apple is very strict in what you can do in background (not background thread, but background as a working process while you are not in the application). What I would advise, would be using a notification badge, so the user would know that there is something new, and when he entered the application you could start your update.
I have to agree with Yase:
Why update the data if the user is not aware of it?.
You should always make it as user friendly as possible. Not letting your user know that the application might consume resources is bad, in my opinion. Imagine that you are updating 2mb of information and the user is on 3G...
I'm not sure if I am following your question right but it sounds like you want the server to be aware that changes have been made and then notify the user of those changes.
Why not run a cron job to check the server on whatever timed cycle you want and then either send a push notification to the user (on iOS)
iOS Push Notificaton Tutorial
I've little Android experience but it seems stickier to do push notifications on those devices. (I'm sure someone will correct me on that soon enough though : D )
This might help:
Android Push Notifications
It is not possible on iOS without the user being aware of the app - the only way you can update the application data from server side is if...
...the application is open and you are holding a tcp connection open
...you send a push message (so that the user opens the application)
In both cases the user is aware of that the application is running. What you can do is that you update the data in the background while the user is using the app. You can use push messages to make the user open the app. But that's it.
On Android there may be some more possibilities if you let the application run a background service, however don't forget that users will remove your app if it is draining batteries etc.
For application data update you should check the version of your data on server. The best way for this is to make your app to ask your server every time user launches the application: user launches app -> app asks server if there is new data in RESTful API style -> server response that yes/no -> if there is new data, application loads it to the device.

PHP AMQ library encrypted credentials over WAN

I'm working on a project where we have jobs submitted via a web interface (backend is PHP), and those are to appear in a queue (rabbitmq backend) on a server across the WAN. I have the PHP producer working fine, without any kind of authentication or encryption.
I'm currently working on implementing some kind of authentication (we don't want anyone submitting jobs to our server all willy nilly).
However, I can't find a way in any of the PHP libraries to use SSL [I partially have it working on the server, but can't get the client]. I want to avoid someone being able to traffic sniff and get our credentials, and possibly submit jobs.
The jobs being passed are just IDs that relate to a database, so they're not sensitive, just the credentials are.
Is there something I'm missing? Is there an undocumented feature in any of these libraries? Is there one I may have not tried? The one I tried, and currently am using, is the one via PECL (php-amqp I believe).
After even more continuous research, I found another (newer) library, that may be of help.
https://github.com/BraveSirRobin/amqphp
I would still love other input, from others more experienced with AMQ and PHP

Categories