Send message to thin clients trough angularJS - javascript

I have a web application developed with angularJS. There is a form where workplace accidents are saved to the database. When a new record is saved I need to send information to all the computers on the network. Most of them are thin clients related to a terminal server. My web application won't be running ot the clients. Only an alert/message should be shown there, like "New accident was recorded.".
I couldn't find which technology should I use. Any suggestions please?
Thank you in advance!
Regards

There has to be server part of the application that takes care of saving data to database. In that function which saves data, at the end you could create a mailing list of target users (or predefined group of receivers) and create a mail that will be sent with message you want em to receive.
Popping message boxes on network computers is far from any practical solution.
So you don't need any special technology, you already have all you need.

Thanks for the answer Mladen!
I already have a function sending mail to some predefined users. But there are a lot of client machines in which can't send/receive mails... So I have to warn them in some other way.
I'm researching now node.js child_process spawn in order to run command prompt. But couldn't figure out yet how to use node.js.
Thank you again!
Edit: For those who search a similar solution:
With the following line I managed to pop up a message on my computer from javaScript:
java.lang.Runtime.getRuntime().exec("cmd /c msg userID msg_text");
But that is not exactly what I need. I will write here again when I find the solution.

Related

Application web: message sending

I am developing a web application where several clients can send messages to each other, it would be like instant messaging without strong real-time constraint.
To illustrate the situation, let's imagine a classroom where students are on a web page and can send messages to their teacher who is on another web page displaying all the messages.
The teacher can answer questions and therefore the pages of the students who have received answers must update with the respective answer.
The first research of solution are unsuccessful because it turns around form and installation of specific library.
What is the easiest solution to implement?
For information, I am developing with javascript, php and mysql; I have no possibility to modify the server part nor to install libraries.
Thank you.
LG

Sending HTTP messages to a specific client connection/web session using cURL/NodeJs scripts with SSEs

Hi so first I apologize if my query may seem unclear, it’s first trying to do what I’m doing and I haven’t full idea around the intricacies and lingo lol.
So basically I’m running a NodeJs web server with React handling my front end. I’ve got Express to help manipulate user sessions and I just came by Server-Sent-Events as a way to send one-way messages(which is what I need to do). So far I’m able to send updates and messages via cURL on the terminal and running JS scripts, however these updates/messages go to every active client session but I want/need to be able to send these messages to specific active client sessions/connections.
Example: 5 client connections are established (session IDs A,B,C,D,E), now I want to send an alert message to session E only and manually.
I’m still green with NodeJs/Express and the concept of SSEs however I’m learning as I go for this pet project.
Send help
What you want is how SSE works. It is a dedicated connection between a client and a server process.
however these updates/messages go to every active client session
If that is what you see then your node script is running the exact same code for each client.
I think your question might be higher up - how to organize the data messaging? That is too big a topic for a single StackOverflow question, because it will depend on so many factors specific to your use case.
But one way would be to have an SQL database, with one record for each user. The node script polls that database table and if the record for the current user changes, it sends the new data to them. Then to send data to user E, you just edit the database record for user E.

Electron SQL security

I have a rather noob question that I can't seem to find the answer for. So I've heard that all electron apps can be turned into source code and then manipulated. So that leads me to my next question. If I'm connecting to a SQL database then what is keeping people from viewing source code, going in and doing whatever they want to the db? I mean once they see the source code the username and password are right there...Sorry if this is a silly question but I'm thinking of making something on electron that needs decent security. I've also heard php cannot be used. So... Any suggestions would be appreciated. I'm just wondering because Discord, whatsapp and such seem to do it somehow, but how?
Thanks!
Well, any information in any application can be reverse engineered, so I would suggest to not hardcode database passwords or any other critical credentials.
I assume Slack, Discord and others don't hardcode their DB passwords in app. Their desktop app don't "talk" directly to database, it's talking with some server-side application. You as a user have to provide credentials to your account. Communication is done through API which implies various restrictions based on your user privileges. This server-side application decides what you can and what you cannot do and translates your requests into DB operations.
So using those apps you don't go even near to their DB passwords.
If you want to do client application which should be able to do some operations on DB, I would suggest the same, split this application into two parts: ClientApp and ServerApp.

Html5 desktop notification php/mysql

hello as described from the title above , I have a website where users enter their datas to the database so what I'm looking for now is when a data is inserted to the database for each user he will receive a desktop notification just like the one of facebook , I know how html5 desktop notifications works but I don't know how to make it work for each user when new data is inserted to database, Please I need someone to guide me.
thanks
You can do it with COMET Programming or Socket Programming. My choice would be Comet Programming because it's easier than Sockets. Now what you are going to do is just you will change a files last edit time, believe or not that's all. The algorithm is easy, you will create a php file for this purpose everyone will connect this file via Javascript and you will get your results when anyone inserts data.
You can check Comet Programming here :
http://www.zeitoun.net/articles/comet_and_php/start
By the way Facebook is still using COMET Programming for every notification,time-line operations and message operations.Also Gmail using it for Live Mail System.

Implementing web chat, how do I get typing status?

Can someone illustrate how I can get typing status of the other party with JavaScript?
UPDATE
Can someone recommend a one-to-one open source chatting application, preferably written in PHP? I only found open source chatting rooms which are for chatting among all onliners, but I just need a one-to-one chatting.
Here are a list of PHP-based open-source instant messaging software.
Some of those might be relevant for you.
For example, if you had an text area #chat then you could use this code to attach the event:
document.getElementById('chat').addEventListener('keydown', FUNCTION HERE, false);
See http streaming and some ready solutions here: http://ajaxpatterns.org/HTTP_Streaming
this is how google talk does it. And there are ready php or c++ solutions
It was quie a discovery for me!
This is an update to reflect the significant change in the OP's question:
Google Chat and Facebook both use XMPP(jabber) servers, as do most companies I know of that have internal instant messaging.
The nice part about XMPP is that you get all of the "is typing" and other presence-based information without having to roll-your-own in javascript (bear in mind, you will still need to use javascript to pass XMPP requests back to the server, but XMPP has most of the features you'd need already built in).
Check out OpenFire. It's a great XMPP server, totally open source, and they have a web-based version of their Spark client that is pretty nice.
Or you could get a PHP library for XMPP (there are a few). But you'd still need to have the XMPP server running in the background for PHP to work with.
Here's a list of XMPP libraries for PHP from XMPP.org:
Eiffel
JAXL
Lightr
Missus
xmpphp
Or, if you want to keep things mostly browser-side, they also have a list of libraries for javascript:
dojox.xmpp
js.io
JSJaC
strophe.js
xmpp4gwt
xmpp4js
I made a small chat application a while ago, and the only way to do it is to frequently check for new entries in the chat database and fetch anything newer than the last displayed message. At the same time as all that, you can check to see if the user's input is empty. If it is, do nothing. If it isn't, enter a status code into the database beside that user's name. If anyone has that status in the database when you're fetching information about new messages and who is online, you should display the 'user is typing' message. I hope that makes sense...let me know if it isn't.
For User1: If you save the chat message on each key-press to the database, with a status: sent=false and update the last updated date.
For User2: you could pole periodically for the presence of a message where sent=false and use the last updated to update user is typing message. if the lastupdated date is more than a say ten seconds you could remove the message as that person may have stopped typing. This will allow User2 to see User1 typing, stopping and continueing again.
Ideally polling for this information will be part of an existing call to the database to reduce additional overhead.

Categories

Resources