Is it possible to get the previous channel or point to point messages sent using Signalling API? - agora.io

I would like to use Agora Signalling SDK to create a chat app.
I am aware that I can use the onMessageChannelReceive and onMessageInstantReceive callbacks to receive messages that were sent.
Is it possible to get messages that were sent previously? If a user logouts and logs in back, is there a way to get the messages that were sent previously?

Currently the Agora Signaling SDK does not support persistent messages. There is a new Realtime Messaging SDK that is in beta that will have more robust features. I would recommend you reach out to the Agora.io team to get more information because I think it will help with your use case.

Related

Is there any api for stop all hosts broadcasting to audience in my channel?

Hi i building interactive live streaming app.
When i wish to leave channel i want to stop all hosts broadcasting to audience
also.Is there any api for that?
I used "leaveChannel" and "mute" apis but doesn't resolve my problem.
There are two ways to do this.
When the user leaves the channel, he can send a signal to the channel members through Agora RTM sdk. When the broadcasters receive this signal, they can call unpublish or mute to stop sending streams. Or they can call setClientRole to switch their role from broadcaster to audience.
RTM sdk quick start: https://docs.agora.io/en/Real-time-Messaging/messaging_android?platform=Android
When the user leaves the channel, he can call the "kicking-rule" RestFul API to specify who can send streams in the channel.
Kicking-rule API: https://docs.agora.io/en/rtc/restfulapi

Is gRPC suitable for push notification?

Currently I am using SignalR for push notification, but due to cost constrain looking for the new alternative. When I read about gRPC its mostly used for microservice communication. Will this gRPC is suitable for web push notification? is there any example I can find. Thanks.

ServiceStack Messaging API: Can it make a broadcast?

As I have previously mentioned, I am using ServiceStack Messaging API (IMessageQueueClient.Publish) as well as the more low-level IRedisClient.PublishMessage.
I use the Messaging API when I need a specific message/request to be processed by only one instance of a module/service, so even though I might have several modules running that all listens for MyRequest, only one service receives the message and processes it.
I use the IRedisClient.PublishMessage when I do a broadcast, a pub/sub situation, sending a request that everyone should receive that listens on that specific Redis channel.
However, I am in a situation where it would be useful to use the Messaging API, but do a broadcast, so that all instances that are listening to a specific message type, gets the message, not just the one.
(The reason for this is to streamline our usage of Redis and how we subscribe to events/request, but I will not get into details about this now. A little more background on this is here.)
Is there a "broadcast way" for the Messaging API?
No, the purpose of ServiceStack Messaging is simply to invoke ServiceStack Services via MQ. Any other MQ features is outside the purpose & scope of ServiceStack MQ, you'd need to instead develop against the MQ Provider APIs directly to access their broadcast features.
Server Events is a ServiceStack feature that supports broadcasting messages to subscribers of user-defined channels, but its a completely different implementation that serves a different use-case for sending "server push" real-time events over HTTP or gRPC, e.g. it doesn't use MQ brokers and pub/sub messages aren't persistent (i.e. only subscribers at time messages are sent will receive them).

REST API with active push notifications from server to client

Problem description
i am working on a Xamarin application that consumes a REST API written in Python flask.
The Xamarin application offers virtual shopping lists where user can collaborate on buying stuff they have on a shared list.
To improve the user experience, i want to be able to actively notify the user about finished items on the list.
Possible solutions:
Synchronous API polling from client side
Notifications are stored by the API in a relational database and have a flag indicating if the user received the notification already.
The API has an endpoint GET /users/:user_id/notifications/ that queries the database for notifications and returns a JSON response with those.
Advantages
fairly simple to implement
Problems
synchronous polling creates a huge amount of http requests
API service remains stateless, making a horizontal scaling with a loadbalancer easier
Websocket endpoint on the API
The API has an endpoint POST /users/:user_id/notifications/register which creates a websocket connection between client and API.
The connection is stored to a global array in which each entry maps a client id to a websocket connection.
When a new notification is created, the endpoint makes a lookup in the connection dictionary by comparing the owner id of the notification with the dictionary entries. The notification is sent to appropriate user through the websocket.
Notifications are stored in the database like in the first approach.
When a user calls the endpoint, a new websocket connection will be established first and upon success the API sends all unseen notifications from the database to the user.
Advantages
API can push notifications to clients asynchronously
Problems
When a user terminates the websocket connection his dictionary entry will persis
Retaining one websocket connection per user permanently adds additional overhead to the API
Horizontal scalability of the API is more difficult because the service is not stateless anymore (Websocket connection information saved in
RabbitMQ
The API uses a RabbitMQ service to send notifications to the client. Every client uses subscribes to his own notification queue to prevent the broadcasting of messages.
Advantages
API remains stateless
Problems
Notifications needs to be resend to the exchange when a user is offline
Amount of queues grows drastically
Additional costs for RabbitMQ service
High temporary load on the RabbitMQ service when many users come online in the same time
Final words
It would be interesting to hear the opinion of others.
I believe the active distribution of notifications from backen services to clients i a very common use case.
best,
D
I would use RabbitMQ and consume events forwarding them as push notifications. This will work while the user is not actively connected to the website and enhance the engagement with each user experience that will return to the website when notified for more information see How to setup basic web push notification functionality using a Flask backend or How to send push notifications to a browser in ASP.NET Core or Sending Notifications with Spring Boot, Angular, and Firebase Cloud Messaging this way the RabbitMQ will not wait until the user is back online. If the user is online you can forward the notification directly to the Xamarin application via WebSockets and a load balancer like NGINX that can handle many WebSockets in an optimized way.
Synchronous API polling from the client-side is the less preferred way since it overloads the webserver with requests while nothing was changed.
I don't think the scalability of WebSocket is a problem. You can scale up easily with pub/sub. The hotspot of long connections is a kind of serious problem.
For one-way communication, I would suggest Server sent event. In the end, it usually depends on what your team is confident with.
I can recommend on a different approach for API that provides JSON which is called GraphQL
It supports subscriptions capabilities that are pushed by the GraphQL API Server (using web sockets)
GraphQL is considered today to be better than RESTful API since its very flexible and you can get exactly the data you need with one query.

Allow Existing API to to bridge with Pusher and allow preprocessing of payloads before transmission

I’m currently working on bidirectional communication between some IoT sensors and a mobile app using Pusher channels.
I have been able to get Pusher working on the IoT nodes using the Arduino library and also in my React Native app.
However, I’ve hit a bit of a roadblock. My IoT sensors aren’t capable of producing JSON payloads and arrays (they broadcast batches of 30 readings at 30 second intervals) due to memory constraints. Each reading can be up to 60 characters in length unprocessed and a full payload being sent every 30s would be at least 1800 bytes, then there’s the header data (Auth token and session data for the sensor’s context).
I do not want to parse this hex data on my React Native app (as some comes from proprietary sensors where the protocol cannot be risked being divulged) so need it to happen on my ExpressJS API (currently handles the authentication and historic data retrieval) before it enters Pusher and pings the React Native app.
My questions:
If the sensor made a POST request to my Express API in which the route performed the processing from hex into nice JSON (with full text values!) - can I use the Pusher client to get this data into the correct channel? Instead of having the sensor talk straight to Pusher?
Is there a way to bridge the Pusher service through my API so that the React Native app “points” to my API for the updates instead of directly to Pusher?
Here is the architecture that I’m trying to achieve - hoping those of you who have experience with Pusher can tell me if this is possible:
I’ve seen the “pusher-http-node” server library but there’s no tangible description of why this would be used.
Really hoping I don’t need to go down the MQTT route and have my own micro service (something I’ve wanted to avoid given the costs and scalability concerns).
DevRel at Pusher here.
To answer your questions:
That setup makes sense. Your Express API can preprocess each sensor event before sending them to the Channels service - you'd use the Node SDK on the server. That preprocessing can include putting it in the correct format, and sending to the correct channel.
For the difference between SDKs:
The pusher-http-node SDK is designed to run on servers, and can send messages to any channels you want.
It also holds your private keys - something that your React
Native client SDK doesn't.
Server SDK doesn't implement subscriptions.
The pusher-js client SDK that you use in the React Native apps on the other hand can only subscribe or send client events.
Your client applications should connect to Pusher Channels service so they can receive realtime updates. Channels serves as the transport here. Your Express API should use pusher-http-node to send these events to Pusher Channels.
So, to summarise:
Have your IOT sensors communicate raw data to your Express API
In your Express API do the preprocessing of these raw events, turning them into something your React Native apps can understand and use
In your Express API use the pusher-http-node library (server SDK) to send these processed events to Pusher Channels service
In your React Native apps use the pusher-js library (client SDK) to connect to Channels service and subscribe to the events your Express API is sending.
I hope this clarifies it a bit!