Reputation: 47
Is it possible to achieve an online real-time notification system based (small scale)website which implements PHP ratchet websockets?
Locallly on my machine I start my PHP server using command prompt, but how could this be done for a hosted website?
As i will not be able start and maintain a server 24X7 for all remote clients, how would this actually work?(I dont have enough knowledge in this area)
Am i missing out on something?
Upvotes: 2
Views: 163
Reputation: 496
Try the below code for notification feature:
<script>
if(typeof(EventSource) !== "undefined")
{
var source = new EventSource("demo_sse.php");
source.onmessage = function(event) {
notification(event.data);
};
}
</script>
And ofcourse you will need demo_sse.php which will be useful for fetching and storing data to the database.
Upvotes: 1