Using APE with PHP - php

I'm a little confused on how APE (Ajax Push Engine) works.
How do you know which connection to push to, making sure the user is correct, from a PHP application?
Is it a Apache extension? Independent server? ETc...
Some explanations would be awesome, thanks!

APE uses a independent HTTP/Comet server that allows, for example, long-polling. It needs some configuration made to the Apache server running beside it. It uses as server-side javascript framework for the development of modules.
On the client side of things it uses a javascript framework that receives information sent by the APE server, handles data, and send back the users requests.
When the page is loaded a new client is created with var client = new APE.Client(); and from then on the client is connected to the server.
More information here

Regarding 1)
You cannot "push to a user" directly.
What you can do from PHP is called "inline push".
Basically you need to call a command FROM PHP on the APE server, passing the information that you want to post ALONG with som information for the APE server WHOM to push the data to.
This requires you to keep track of your logged in users on the APE server (preferably via username/login).
APE itself does not have any information about the login of connected users, you need to create some functions to do so.
A blog post that around that topic can be found here:
http://www.xosofox.de/2010/10/ape-user-handling/

Related

PHP websocket realtime updates on multiple devices

I am trying to implement a very simple self-hosted (docker) pubsub client update system using websockets or SSE for my PHP application.
I would like that a specific javascript action on my website triggers a php server-side update (via ajax) which should then lead to an update to all subscribed devices for the particular channel/topic. The subscribed devices should use javascript listening to one channel each.
Do you know any simple PHP ws libraries which are capable of that? Can SSE be triggered in that way and also utilize channels? How about in-built PHP socket function? Ideally I would like to stick to PHP solution in order not to deal with translations and in-between REST APIs.
After researching this for days and going through solutions like RabbitMQ, Redis, Kafka, RatchetPHP, ZeroMQ, socket.io, RPC, SSE and etc I am completely lost. I need some guidance on which way to go.
Among all possible solutions here is how I would do it:
Install a web socket server, preferably implemented in PHP, on you Linux system.
Your web clients register with the server and listen for messages like broadcast from the server.
Your ajax script registers also with the server and sends a broadcast to the server if all work is done.
The server passes the broadcast to all registered clients.
You could use my implementation of such a web socket server that comes with all the needed client
libraries for JavaScript as well as for PHP that implement broadcast and feedback.
See https://github.com/napengam/phpWebSocketServer

How do I use a server for mobile application?

I recently started to do development in the Haxe language with OpenFL (AS3 background).
But I have never worked on an app that communicates with a server - or never done any programming for servers for that matter!
I have to make a mobile app (for which I intend to use Haxe) where the new user creates an account on the server, and thus also interact withe other user accounts in a desired way.
So could someone guide me in the right direction to approach this situation? I'm guessing I will need to use PHP or ruby etc.
or can I use Haxe to program on the server? are there any good libraries that also provide security while making facility for user accounts? Is AWS or Google app engine something I can use?
check this simple but complete tutorial by filtreck
http://mromecki.fr/blog/post/haxite-writing-entire-website-using-haxe
You will want to create normal web pages that you can host on the server which will retrieve the needed information.
After having uploaded these, use a type of webview in the application to load the pages and retrieve this information.
You can write your server in Haxe if you want, and if you use a platform that supports it you could use TCP and haxe.remoting to pass data between the client and the server.
haxe.remoting is intended to make calling haxe function in a server from a client easier so that may be what you want.
If you don't feel confortable with using TCP you could do as Max wrote, just make some HTTP API (you can do this too in haxe) and do normal HTTP request from the client.

Need to develop a PHP - Jabber based chat

I was trying to develop a web based chat system using PHP. I created one with the combination of jQuery and PHP but this setup is using lot of network bandwidth as it is continuously sending / receiving data to check whether a new message has been received or not (currently every 1 second). So I need to develop a system that will automatically display the message once a message is received from the other end without the need of sending a request to the server to see if there is a new message received.
I read in many places that this can be done using Jabber. I am really new to this jabber technology, so any help creating a new Jabber based chat using PHP will be greatly appreciated.
Jabber (also known as XMPP) is more of a protocol, so it's not really the solution you're looking for.
HTML 5 web sockets are a great new technology to achieve this. Rather than polling to see if there are any messages, the server can "push" new messages to the browser.
The client side code is JavaScript. The server side can be anything implementing the web socket protocol. There are probably some PHP libraries to write the server side code, but I have written a few Ruby web socket servers using EventMachine and em-websocket.

Chat room app on Android without openfire

I plan to use asmack lib for a chatroom app on android, however, I just want to use PHP as server scripts with mysql as backend database server. I hope I can find a way to build it without openfire, is it possible? Any suggestions to implement them?
You can use whatever server you want. asmack is a client library that communicates via XMPP, which is language agnostic. Select any server you would like and your client should work fine.
Your comments about whether OpenFire has a PHP api though are somewhat confusing, do you want an OpenFire server or not? The language the server is written in is irrelevant to your client app.

Transferring data from one server to another in php

I want to transfer 10 user details from my server database to another server.The other server can call a php page (in my sever) which can supply the needed 10 user details.This should happen in such a way that a user using the site must not understand that the data is coming from another server.
I will recommend using WebService for this purpose. In the Server A (provider) you will code this webservice to serve the users as requested by server B(consumer), So you will be able to consume the services provided by A at any time and being transparent for the USER.
References:
WebService
XML-RPC
SOAP
You can implement JSON-RPC server and client.

Categories