Member Avatar for Member #13457

Currently i am building a message queue program which
one is sending a message to another party.
lets say ABC sending a message to DEF

if ABC sends a msg out using message queue, it stores at the msg queue manager, once the msg stored in,i want the server side to detect the message and automatically alert DEF that he receives a msg. alert for example: pop up windows and etc...

i understand by using javascript : <server>

but how it works?

thank you

Dani AI

Generated

Short answer: a web server cannot reliably force a browser to open a window on a remote machine. As implied, you need client-side code that either keeps a live channel open so the server can push events, or uses the browser's push APIs so notifications arrive even when the page is not active. 's move to client-side checks works, but there are more robust options for real-time delivery.

Common, practical choices today:

  • WebSockets: a persistent, bidirectional socket ideal for chat-style delivery. The server listens to your message-queue and forwards new messages to the correct socket connection.
  • Server-Sent Events (EventSource): a simpler, one-way stream from server to client for live updates.
  • Web Push + Service Worker: use this when you need OS-level notifications while the page is closed; it requires subscription and permission from the user.

Small client-side sketches:

const ws = new WebSocket('wss://example.com/ws?token=USER_TOKEN');
ws.onmessage = e => {
  // show an in-page alert or trigger a Notification
};

Service-worker notification example:

self.registration.showNotification('New message', { body: 'You have a message' });

Implementation tips and cautions: map connected users to socket IDs on the server so the queue can route messages, authenticate connections (short-lived tokens), always use TLS (wss/https), persist undelivered messages for offline users, and handle reconnect/backoff. Browsers tend to block programmatic pop-up windows; prefer the Notification API or an in-page modal instead. For scaling, fan out queue messages through a broker (Redis/RabbitMQ) to your WebSocket cluster rather than trying to reach browsers directly from the queue process.

Recommended Answers

All 4 Replies

Could you be more specific?

Member Avatar for Member #13457

actually i want the server-side to trigger open a new windows on the client-side.

do you think its possible?

thank you

Http is conectionless, so you will need to use client side javascript. Use the setTimeOut function to poll the server by sending an ajax request using the XMLHttpRequest object available in most script enabled browsers, or new ActiveXObject("Microsoft.XMLHTTP") in IE browsers.

Member Avatar for Member #13457

oic, thank you...
now i've figured it out to use AJAX.
thank you
and sorry for the trouble
:p

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.