What is the differce between Streams and Sockets in Flutter? - flutter

Guys what is the difference between Streams and Sockets in Flutter and when to use them?
I'm going to use Flutter in mobile app(iOS/Android) and the app is going to receive continuous flow of data coming from server, so now I'm confuced what to choose for this purpose.
*Note that performance is important.

Sockets is a real time technology related to server side which enables your back-end to push data to your client side without the need for continuous polling your server.
Streams in flutter is an object that hold reference to changing data that you can tap into it and react to the change.
these are two different concepts but they normally combined together to give you the reactive behavior wanted for your app.
hope that help you.

Related

In socket.io, can the listener act as the emitter at the same time?

In my problem, I need to send some data from several devices to a centralized server. Then I need to view these received data in a UI from the centralized server.
I have sent data from a client to a server using socket.io methods and it worked. Now I want to send the data in the server to a UI. Can I use sockets for that? If so, is it possible and is it good to code in a way that server act as the listner and the emmiter at the same time? If this approach is not good, please provide your suggesions.

Flutter How to update data in real time?

I am using rest apis for getting data but i want to update it in real time, I can't use firebase for the same. please suggest me any better way also calling api again and again is not good idea to achieve it.
For real time you need to use a real time database with a sdk for subscribe to it (like Firebase) or you can use socket.io to stream your data from a standard backend, socket.io is a library to abstract the WebSocket connections.
If you use node for backend i suggest you to read this topic on Nestjs https://docs.nestjs.com/websockets/gateways

Using mediasoup server from flutter dart client with no mediasoup-client

I want to use mediasoup server from flutter app for two use cases.
Send stream to server to record on the server side (preferring ffmpeg).
One on one or small groups up to 4 live video chats.
I would like to start with the simple option which is single stream sent to server, and for that I want to use https://github.com/ethand91/mediasoup3-record-demo as reference.
My problem is that mediasoup is not using standard offer and answer flow as I know and used to when implementing webRTC clients and in all mediasoup examples they use mediasoup-client that in fact using rtpCapabilities instead of the commonly used SDP format.
I did find this good intention repo: https://github.com/cloudwebrtc/flutter-mediasoup-client
But so far it looks like intention only.
So my question is, what's the flow I should use in order to privide the client side application with SDP, or how can I get SDP format from mediasoup transport and router rtpCapabilities.
Also, if I build the SDP myself, what should be the flow?
client-> connect ->server
server-> create-transport ->client
client-> connect-transport ->server
server-> create-producer(router rtpParameters translated to sdp offer) ->client
client-> produce(sdp answerr translated to producer rtpParameters) ->server
Does it make sense?
Any different approach also will be appreciated.
Thanks.
Use the mediasoup forum if you want authors of mediasoup to answer. We do not use Stack Overflow:
https://mediasoup.discourse.group
I started to implement it myself:
https://github.com/tan-tan-kanarek/flutter-mediasoup-client
I find that the dart webRtc stream is not giving me all the info I need regarding encoding and tracks separation.
Help will be appreciated.
Mate, you need walk through on mediasoup... you can start with javascript basics and move on to flutter as basic just works on all platform
this youtube channel is very useful on mediasoup Amir

How should I implement bi-directional networking between an iPhone application and an Objective-C server-side application?

I'm looking for advice on the best way to implement some kind of bi-directional communication between a "server-side" application, written in Objective-C and running on a mac, and a client application running on an iPhone.
To cut a long story short, I'm adapting an existing library for use in a client-server environment. The library (which runs on the server) is basically a search engine which provides periodic results, and additionally can provide updates for any of those results at a later date. In an ideal world therefore I would be able to achieve the following with my hypothetical networking solution:
Start queries on the server.
Have the server "push" results to the client as they arrive.
Have the server "push" updates to individual results to the client as they arrive.
If I was writing this client to run on another Mac, I might well look at using Distributed Objects to mask the fact that the server was actually running remotely, but DO is not available on an iPhone.
If I was writing a more generic client-server application I would probably look at using HTTP to provide some kind of RESTful interface to searches, but this solution does not lend itself well to asynchronous updates and additionally what I am proposing does not fit well with the "stateless" tennet of REST: I would have to model my protocol so I "created" a search resource that I could subsequently query the state of and I would have to poll for updates to it.
One suggestion someone made was to make use of something like BLIP to provide me with a two-way pipe between the client and the server and implement my own "proxy" type objects for the server-side resources that knew how to fetch data from the server and additionally were addressable so that the server could push updates to them. Whilst BLIP provides the low-level messaging framework needed to communicate bi-directionally it still leaves me with a few questions:
How will I manage the lifetime of the objects on the server? I can have a message type that "creates" a search object, but when should that object be destroyed?
How well with this perform on an iPhone: if I have a persistent connection to the server will this drain the batteries too fast? This question is also pertinent in the HTTP world: most async updates are done using a COMET type hack which again requires a persistent connection.
So right now I'm still completely unsure what the best way to go is: I've done a lot of searching and reading but have not settled on any solution. I'm asking here on SO because I'm sure that there are many of you out there who have already solved this problem.
How have you gone about achieving real-time bidirectional networking between the iPhone and an Objective-C server-side app?

How to push data to variety of different client types in near real time?

We need is to push sports data to a number of different client types such as ajax/javascript, flash, .NET and Mac/iPhone. Data updates need to only be near-real time with delays of several seconds being acceptable.
How to best accomplish this?
The best solution (if we're talking .NET) seem to be to use WCF and streaming http. The client makes the first http connection to the server at port 80, the connection is then kept open with a streaming response that never ends. (And if it does it reconnects).
Here's a sample that demonstrates this: Streaming XML.
The solution to pushing through firewalls: Keeping connections open in IIS
I would go with XML. XML is widely supported on all platforms and has lots of libraries and tools available for it. And since it's text, there are no issues when you pass it between platforms.
I know JSON is another alternative, but I'm not familiar enough with it to know whether or not to recommend it in this case.