Can a phone respond with some data to a FCM message? - firebase

I can't seem to find any option for a phone to reply with a response to the caller via FCM. Is this possible?

You're probably looking for Upstream Mesaaging. Note that you'd need an XMPP server protocol instead of the normal HTTP server protocol for sending Downstream messages.

Related

How can I make server query some data from client via grpc?

I am using grpc for client/server communication since it supports bidirectional streaming. I have read some doc relates to that: https://grpc.io/docs/what-is-grpc/introduction/
It supports:
A simple RPC where the client request to server to receive a response
A server-side streaming RPC where the client sends a request to the server and gets a stream to read a sequence of messages back.
A client-side streaming RPC where the client writes a sequence of messages and sends them to the server, again using a provided stream
I have a case that to let server to send a query request to client to receive a response. The bi-directional is only used in streaming case not request-response case.
I couldn't find any way to support that pattern. Is this supported by grpc?
The initiator of a request is by definition the client.
To address your need:
the code currently functioning only as a gRPC server must also implement a gRPC client; and
the code currently functioning only as a gRPC client must also implement a gRPC server.

Mixing websockets and http

When speaking from a conceptual point of view, is it standard practice to mix WebSockets and HTTP requests when making a chat application (or any application that requires real-time communication between devices)?
Imagine a scenario with a client and a server in a chat app. What would be the best approach for connecting and sending data between the client and the server? Would it be using sockets for both sending and receiving or HTTP requests for sending (so the client would get a response and then know if the message was received), and then using WebSocket for only receiving new messages?
No this is not standard practice.
If you need real-time communication between client and server you normally just use a websocket connection and keep that one open. The client can send messages to the server and receive messages through the same connection.
Using HTTP requests for sending messages to the server and receiving new messages via websocket seems odd and just adds unnecessary complexity.
Now if your server has some endpoints to subscribe for real-time data e.g. a chat room and endpoints for getting information you don't necessary want to subscribe to e.g. information about a certain user, than you can use the appropriate protocol for each endpoint

How to send http request from server to user's device

I have a question regarding http requests and responses.
I know that I can send a request to a server from my device (I can build and send a GET request to http://google.com for example). But what if I am Google and I want to send a request from the server to the user's device? How do I do that?
I understand that when the server receives a request, it can answer it, but in this case I want the server to send the request to the user's device. Just like WhatsApp does when you receive a new message.
Thanks for the help!
There are several options for sending information from the server to a client:
Push notifications - depends on the platform you are using
Constructing a Websocket connection that allows bi-directional communication
I'm sure there are more options but those are the two that come up to my mind right away.
It really depends on your application use case. For example, a chat application would like to have a socket open between it and the server so it can update frequently on new messages, etc. On the other had some simple Calendar applications might want to use push notifications to send reminders on certain dates and times.

grpc - Invert Request/Response flow: server requests, clients responds

As explained in the grpc overview, the default flow is that a client connects to the server and sends requests, to which the server responds adequately (well, hopefully).
I'm interested in using grpc for a new project, but the flow must be inverted. I want the client to answer questions. But it can't be the server since it'll be hidden behind firewalls and may not listen on ports.
The flow I need is:
Server is listening as usual
Client connects to the server as usual
From then on, the server asks questions (sends requests), and the client answers them, and not the other way around as is usual.
Is there a way to do that with grpc? It can involve network configuration on the server side, but none is possible on the client side.
gRPC natively supports bi-directional streaming. And what you need can be achieved by that.
Client connects to server, wait to read server message (questions)
Server asks questions (sends messages to client)
Client replies (sends messages to server)

Is it possible to send information from web server to client with out request?

HTTP is a request-reply type protocol. Is it possible to send information from the server to client with out the client explicitly making the request ? If, possible, then how can the client listen that information ?
Thank you.
yes there is a way. its called websockets.
look here for some nice examples:
http://www.websocket.org/demos.html

Resources