What would be the most appropriate way to make a real-time web app that works on PHP (Apache web server)?
The idea of web application is to let two users at the same time edit same HTML form which is regularly saved to MySQL DB.
I am thinking about AngularJS + Laravel approach with lots of AJAX requests, but maybe there is more appropriate way to do this (maybe WebSockets)?
There are no requirements for browser compatibility except that it would work on latest version of Chrome.
Basically, if you want a real-time web application your best bet would be WebSockets.
It is event driven so the client doesn't has to pull for updates, the server push them.
Otherwise, the client would have to constantly pull updates from a REST API.
A quick search on Google led me to Ratchet which is a PHP websockets.
Good luck!
Related
I am working on a chrome extension which has to store data of its user. For that I am using a hosted server which is running a mysql database. But currently any addition or change in data fires a request to the hosted server.
Chrome extension provides chrome.storage.local API which is suitable to store data upto 5mb. I want to take advantage of this storage API to reduce number of requests to my hosted server by using it as a temporary storage.
I am planning to use chrome.storage.onChanged.addListener and chrome.storage.local.getBytesInUse to check if data stored crosses a certain threshold value and then only fire an ajax request to the remote server to save the data. Upon successful response, the old data in chrome.storage will be flushed off.
But there are chances of losing some new data which is created during the process of request/response cycle from the server.
How can I prevent any loss of data? Is there any alternative solution to this optimization problem of reducing number of requests to the remote server from the extension?
Thanks.
This isn't really a question about chrome extensions. It's more about persistent databases that work offline and synchronize intelligently. Which happens to be a very hard problem to do right.
The easiest solution is to use chrome.storage.sync. That buys you persistence for free with the caveat of limited storage. You should definitely see if this is feasible before trying other options.
Otherwise, I recommend looking into 3rd party options before rolling your own solution. You might have heard of progressive web apps, which work offline, and sync when internet is available.
An article about the advantages of progressive web apps
Google Tutorial
PouchDB, a well regarded web database that works offline and syncs to other databases
Look into those. It'll be well worth the trouble. otherwise you'll just end up building hacks on top of hacks trying to get syncing to work.
... one last thing... make sure to add your remote database's URL to your manifest's permissions.
I'm attempting to make a Web app that needs to communicate to a program written in C Sharp. But I can't find a good form of communication. What I need is if a user clicks something on the Web app, it will notify the C Sharp program. Also, if an event happens on the C Sharp program, it needs to alert the Web app. Both of these are going to be running on the same machine.
Right now I'm mainly focusing on the C Sharp program just periodically "asking" what the status of the Web app is.
I've tried using POST requests to the Web app and I've had a bit of success with this but I don't know how to essentially store and update a "status" on the Web App. For example, C Sharp program sends a POST/GET request asking for the status, the Web app responds with "nothing has changed" or some sort of status code. I don't know how to keep track of that status.
I've attempted using Web Sockets but I don't think it is going to be possible on the C Sharp side. However, I'm definitely open to suggestions on how this might work.
I've looked into using the ReST architectural style but I'm having a hard time understanding how I would implement it. I'm using mainly AJAX on an apache server and most of the ReST examples I saw used IIS.
One way I've been successful with this is a horrible workaround. I use 3 files to store contents, status of Web app, and status of C Sharp program. But this requires me constantly fetching files, reading them, writing a new one, and uploading it.
Sorry if this question is poorly formed, I'm obviously new to a lot of this and this is my first SO post. Also, I'd include example code but I'm posting this from my tablet so it's not accessible right now.
If they are on the same machine, you can use 'pipes' (Unix), local sockets or file handlers.
These are all types of IO objects both applications can 'listen' to without exposing themselves to the network and without blocking while they are 'waiting' for data..
... But this will limit your scalability.
Another option is to use a Pub/Sub service such as Redis. This is a better option than websockets, because you can have multiple C# apps listening to multiple web apps on a centralized data source.
It uses the same IO concept (using sockets) behind an abstraction layer coupled with a database - it's very effective.
Good luck!
I implemented something similar to this. I needed a desktop application to listen for api calls from the browser. I ultimately decided to implement a "web connector" which can either be created as part of the application OR installed as a service.
Here is a good example: https://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener(v=vs.110).aspx
I have a web application which does downloads of some reports in differents pages in my app, I retrieves the report's data from an external API, I am using AJAX call to get this data. As expected, if the user change the page while the report is being generated the user will not be able to download it, the HTTP request is supposed to be canceled.
There are some solutions in my mind for this problem:
I can open a popup to request the report and keep it open;
I can leave the whole app inside an IFRAME and request the report out of the page;
Or I can change the way how to download the reports doing a queue(Just an idea, does not matter now)...
Is there an alternative way to do that?
Would be possible to keep the HTTP request even when the user change the page?
My scenario is in front-end side(javascript) I don't have access to any back-end. But if there is no way in front-end side, I would like to hear from you any idea.
use onbeforeunload to warn the user that if he navigates away from the page the download will be cancelled
ASP.NET SignalR
ASP.NET SignalR is a new library for ASP.NET developers that makes it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.
You may have heard of WebSockets, a new HTML5 API that enables bi-directional communication between the browser and server. SignalR will use WebSockets under the covers when it's available, and gracefully fallback to other techniques and technologies when it isn't, while your application code stays the same.
SignalR also provides a very simple, high-level API for doing server to client RPC (call JavaScript functions in your clients' browsers from server-side .NET code) in your ASP.NET application, as well as adding useful hooks for connection management, e.g. connect/disconnect events, grouping connections, authorization.
http://signalr.net/
This was the solution my team found out. It's working fine. Our case is only for ASP.NET. But as the own text says, "You may have heard of WebSockets, a new HTML5 API that enables bi-directional...". So, now we can do that.
I have just used the NotifyIcon class in a windows application and I think it is really handy. I'm predominantly a web developer so I just wanted to find out if there is anything similar to this for a website.
The website I want to incorporate this into has a Ticket Management module where users can capture tickets/problems and then get responses to these tickets from my client's employees who handle the ticket.
Obviously I realize that the notification or pop up will need to be shown in the page, but is there a way to put a timer on the specific page, or even the Master page (maybe javascript or JQuery), to poll the database every few minutes and check for recently modified tickets and let the logged in user know that a ticket has been updated?
Thanks in advance.
If you need the client to keep an open connection to the server and poll it, I think Signal R will be your best bet for integrating into an .NET project. It is on Nuget but source is at https://github.com/SignalR/SignalR.
I would recommend familiarizing yourself with Node.js.
Node.js is a strong tool that aids in leveraging javascript as a real-time server management tool.
After you've gotten yourself familiarized with the Node.js setup, you'll want to grab Socket.io. Socket.io provides suppport for the long-polling technique by leveraging against your websocket created by Node.js. Here, we can manage the conditions at which we serve data. This is a huge tool on the developers side in battling against 2 HTTPD ports.
How can a web application store a very large amount of data client-side? (I'm talking concretely about allowing a capacity of some millions of records).
What I want to do here is to allow research of these records offline.
All of the users are using Chrome.
I was opting for indexedDb until I read that with about 400k records, it is almost unusable.
Then there is the Web SQL, but it had been deprecated.
I was then thinking that my last option would be to install a web server like apache with small script locally that would interact with my web application and store the records in a DB like MySQL. With AJAX I could access my script in localhost, but then there is the cross-domain problem.
I ran out of ideas
Update: clarification->
The main web application is running on a distant server. It has to be on a server as the application is used by several people at different locations (it is shared), and need to be accessed by smartphone, etc. The last idea was to install a web application locally (on all of the user's computer), that would interact with that distant web application to fetch the records from it and store them locally. Anyway it wouldn't work because of cross-domain issues I guess.
I see few alternatives:
don't you actually need a desktop application. I know, I know it is so 1990's...
installing a local web server and accessing your application via web browser is an option as well. But this is dangerously close to point 1.
you might consider developing a Java applet and permitting it to use the file system