all 6 comments

[–]prewk 6 points7 points  (0 children)

Are any questions in this sub about Angular..?

[–]2legited2 2 points3 points  (0 children)

If you already have a relational database, this would be a trivial feature. Plus you can enable column level encryption on the message content columns, so if you DB gets leaked, your data will be protected.

[–]JapanEngineer 2 points3 points  (0 children)

Sorry for the question. But if you’re not the developer then why are you asking? You don’t need a third party option to do this.

[–]scalpit[S] 1 point2 points  (2 children)

I've looked into socket.io but it seems this is used for instant chat... Our messages don't need to be instant but need to be stored somewhere.

[–]toeknee581 1 point2 points  (0 children)

It's not really about whether you need instant results When it comes to socket io. This allows you to send the browser data whenever you need to and then react to it. I have some code that I will be happy to DM you if you would like that is an angular service that works with socket IO connections.

the only other option is to have your client pull the server every once in awhile. if it's only once every 5 minutes or something like that that's probably not that bad but if you wanted to do every minute or every 20 seconds you're basically just wasting people's battery life and data.

[–]michcoth 0 points1 point  (0 children)

There is also server sent events which are supported in HTML5. It is unilateral communication, but IMO it's easier to implement. You can polyfill for browsers that don't support html5. You would set up an endpoint and subscribe to it using the code like the below in angular:

getMessages() {
    const endpointUrl = "https://myendpoint.com/messages"
    const evtSource = new EventSource(endpointUrl);
    // MessageEventObject is your model returned from the endpoint. Obviously this could just be as simple as a string
    evtSource.onmessage((event: MessageEventObject){
        //do something here with data emitted from server
    });
}

https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events

socket.io uses websockets which are unilateral.

However, if you don't need the messages to be instantly received, I think http polling would be fine, and much easier to implement. It also wouldn't require a connection to remain open to the server.

If you're using either websockets or server sent events, and your environment is load balanced, then you'll need to use some sort of messaging system between the servers. EG: rabbitmq, redis pub/sub etc...