Advice on building a server connected android app - javascript

I'm creating a personal project, an Android application, where user sign ins via a server are essentially. Also users will be able to share important "updates" in both a data stream that all users can have access to, and potentially down the line a data stream that will be specific to local users.
Unfortunately I have basically no idea of how to implement the server for this application. I'm confident that I'll be able to create a solution though, I just need to be pointed in the right direction. Are there any existing servers/api's that I could access that will allow me to handle my "connected" tasks? If I were to make a server myself for this application where should I start?

If you have absolutely no experience with server side coding, you should start with PHP and MySQL to create a simple API for your app.
For getting started download the XAMPP bundle that has everything you need.
SQL and PHP are fairly easy for beginners. On the client(Android) side use Volley as it is simple to understand.
However if you want to get started with Node.js, your server can be up in a few minutes with express.js

Related

Can database work be done with PHP instead of MongoDB in METEOR? [duplicate]

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).

How would I create a real-time chat using PHP, AJAX and AngularJS?

Is there any simple way to make a real-time private messaging website without having to use node.js & socket.io?
I'm not asking for the code, I just want to get some sort of starting point since I really have no idea how to do it.
You can use Ajax Jquery & HTML to make a chat.
Here is one I found on Github, this might help you to learn how to make one using these coding langugaes.
Github link: https://github.com/Frug/AJAX-Chat
Why do not you want to use sockets? You will be obliged to make requests every second(you say real-time chat) and it will be hard for the sever. How about if more than 100, 1000 or 5000 users are chating ?
You better use socket.io because it avoids this kind of overloading
Writing a chat application with popular web applications stacks like LAMP (PHP) has traditionally been very hard. It involves polling the server for changes, keeping track of timestamps, and it’s a lot slower than it should be.
Sockets have traditionally been the solution around which most realtime chat systems are architected, providing a bi-directional communication channel between a client and a server.
This means that the server can push messages to clients. Whenever you write a chat message, the idea is that the server will get it and push it to all other connected clients.

Send data from web to a local server

I am working on a home automation hub -- a Raspberry Pi running locally that displays weather info, controls my lights, etc. It is "networked" (and I use that term loosely) to a website via a shared MongoDB. Both the site and the hub are running Node.js/Express servers.
Essentially, I am looking to be able to enter text into a field on my website and then display it on my hub.
I'm struggling to figure out how to pass data between them. I can think of a couple ways that might get it done, but the only way I know I could get working is to implement some sort of Mongo watcher/listener to watch for changes on a specific collection. Essentially, you enter the text into the site, that updates the document in Mongo, the watcher informs the locally-running hub, which then fetches and displays the new content.
This seems hacky. Is there a better way? Is this something socket.io could manage? Maybe I'm overthinking it? Help!
You can use Socket.io, WebSocket or TCP socket to connect the two servers together and communicate that way. Or you can use a queue system like ZeroMQ or RabbitMQ and communicate that way. Or you can even make an HTTP request from one server to the other one every time you want it to grab new data - or you could even sent that data right in the request.
It would be much easier if you used Redis that supports pub/sub, see:
https://redis.io/topics/pubsub
or CouchDB that supports the changes feed:
http://docs.couchdb.org/en/2.0.0/api/database/changes.html
or RethinkDB that supports changefeeds:
https://rethinkdb.com/docs/changefeeds/javascript/
I don't think Mongo supports anything like that.

Integrate Node.js with Symfony2 or PHP

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/

Advantages JavaScript+HTML5 over XAMP on a local computer

I have this idea of developing an application (or a companion application to another web based application) on a client. My initial idea was to run it on a XAMP stack on the client. Although this is perfectly feasible, I was thinking of a more compact approach using javascipt+html5 (with web storage / indexed db). I think that not running a web and database server would allow my application to become less resource-intensive. Any ideas please.
What are you trying to accomplish with your app? Keep in mind if someone clears the cache, they can delete all the data that was in the local storage.
As to "resource intensive", is this personal resources (like paying for a server)? I rarely would advise anyone in making an app that is client side only with no server side backup, unless it's something you only need to use on one computer.
I think you are forgetting one thing, you still need a web server to serve the HTML and javascript to the client.
However could create a Adobe AIR app using javascript and sqlite.
http://www.adobe.com/devnet/air/articles/getting_started_air_js.html

Categories

Resources