I want to make connection to FMS (flash media server) in my android application.
Please suggest if there is any way to get connected to FMS via RTMP.
Have you had a look at the NetConnection class? It establishes an RTMP connection to a RTMP-capable server.
Establishing a connection is easy:
var nc:NetConnection = new NetConnection();
// Listen for the netstatus event
nc.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
// Connect to your server
nc.connect("IP_GOES_HERE");
function onStatus(e:NetStatusEvent):void
{
if (e.info.code == "NetConnection.Connect.Success")
{
// Connection has been established
}
}
Looks like you don't want to do it in Flash but in Java. There is one library I know off that implements RTMP on the client side which is Flazr.
Related
I am trying to establish a socket connection between an Android and a UWP application over WiFiDirect. UWP application advertise itself enabling others to discover it. Android app search for available WiFiDirect device and connect with the UWP application.
I am successful in initialising and connecting over WiFiDirect between Android and UWP. But I am confused about creating Socket connection after WiFiDirect connection is made. More specifically I am hesitant on which side should i create ServerSocket and client-socket.
In Android side i have seen example of creating ServerSocket if the device is group-owner and vice-versa. But in UWP side I am not sure which one should i create.
Android side code to create socket:-
override fun onConnectionInfoAvailable(info: WifiP2pInfo?) {
if (info!!.groupFormed && info.isGroupOwner) {
// Creating ServerSocket
}
else if (info.groupFormed) {
// Creating Client Socket
}
}
On UWP side after connection request is received my sample code:-
private async void Listener_ConnectionRequestedAsync(
WiFiDirectConnectionListener sender,
WiFiDirectConnectionRequestedEventArgs args)
{
WiFiDirectConnectionRequest request = args.GetConnectionRequest();
WiFiDirectDevice _device = await WiFiDirectDevice.FromIdAsync(request.DeviceInformation.Id);
var endPoints = _device.GetConnectionEndpointPairs();
EndpointPair firstEndpoint = endPoints[0];
// Which socket connection should i create
// StreamSocket or StreamSocketListener
}
I have tried a hack in UWP which seems to work but I am not confident about it
if (firstEndpoint.LocalHostName.CanonicalName.EndsWith("1"))
{
// creating server socket
// StreamSocketListener and waiting for incoming connection
}
else
{
//Creating client socket
// StreamSocket and connecting with remote host
}
How should i decide create socket connection type in UWP side? Please provide the fundamental concept that i am missing here.
I have a really huge place in which what I need is that people can chat with each other. I would place WiFi router to cover the whole place but, due to the high amount of people, I can't provide an internet connection through that network. Which technology should I use? I've been reading about AllJoyn but I don't know if that would help me. Also, because of the amount of people (over 75,000) I can't setup a server to handle the service, per connection, 1 devices will have to be the host and the other one will have to be the client. Thanks
If you want to create your own application you could use something like Signalr and Xamarin using their SignalR component.
Taken from the Quick Usage on the component page:
// Connect to the server
var hubConnection = new HubConnection("http://server.com/");
// Create a proxy to the 'ChatHub' SignalR Hub
var chatHubProxy = hubConnection.CreateHubProxy("ChatHub");
// Wire up a handler for the 'UpdateChatMessage' for the server
// to be called on our client
chatHubProxy.On<string>("UpdateChatMessage", message =>
text.Text += string.Format("Received Msg: {0}\r\n", message));
// Start the connection
await hubConnection.Start();
// Invoke the 'UpdateNick' method on the server
await chatHubProxy.Invoke("UpdateNick", "JohnDoe");
Alternatively there are applications out there that likely do what you want already. For example http://beebeep.sourceforge.net/
I am new to WebRTC native framework.
I was able to get the WebRTC source and run the demo Android application based on http://andrii.sergiienko.me/?go=all/building-webrtc-demo-for-android/enter link description here.
I was able to send/receive Audio and Video between two Android devices on the same local network.
Is there any way to send a small JSON payload in this peer connection?
I tried looking for it in the source and I only found support to send Video and Audio.
Thank you.
Your are looking for WebRTC DataChannels.
WebRTC's RTCDataChannel API is used to transfer data directly from one peer to another. This is great for sending data between two browsers(Peers) for activities like communication, gaming, or file transfer and slew of other functionalities.
It is an Alternative For WebSockets:
This is a great alternative to WebSockets because no central server is involved and transmission is usually faster and there is no bottleneck. You can of course mitigate the failover of P2P transfer by having a hooks which activates Websockets based communication if P2P data-channel communication fails.
Code for Reference:
The events defined are called when you wish to send a message of when a message is received (including error handling). This code should be running in both the browsers. Instead of sending "Hello World" you just need to send your JSON String.
var peerConnection = new RTCPeerConnection();
// Establish your peer connection using your signaling channel here
var dataChannel =
peerConnection.createDataChannel("myLabel", dataChannelOptions);
dataChannel.onerror = function (error) {
console.log("Data Channel Error:", error);
};
dataChannel.onmessage = function (event) {
console.log("Got Data Channel Message:", event.data);
};
dataChannel.onopen = function () {
dataChannel.send("Hello World!");
};
dataChannel.onclose = function () {
console.log("The Data Channel is Closed");
};
The dataChannel object is created from an already established peer connection. It can be created before or after signaling happens. You then pass in a label to distinguish this channel from others and a set of optional configuration settings:
var dataChannelOptions = {
ordered: false, // do not guarantee order
maxRetransmitTime: 3000, // in milliseconds
};
For more details check out the links provided.
Examples:
Link to official documentation: DataChannels in WebRTC
Link to a file Trasfer example using WebRTC Data Channels.
File Transfer
Link to popular Use Cases for WebRTC Data Channels
Use Cases
I've read the discussion, and now I am working on my own simple Android firewall. Here is the algorithm they used.
The discussion
I was able to forward packets. If I remember correctly I just needed to read the TCP header and open another socket to that destination and send it headerless.
So now I need to write data to my Wi-Fi or 3G network interface if I understand them correctly. How to do that?
I solved it. I only needed to protect the socket which I'd like to use to send data directly to the server without using the TUN device.
Socket socket = socket = SocketChannel.open().socket();
if (!protect(socket)) {
Log.e(Constants.TAG, "Failed to protect the socket");
}
The documentation
I need to trnasfer data from one android device to another device over wifi network?
If one device is willing to perform access-point like functionality as part of a portable hotspot, and you select that as a wirelss network on the other, you may achieve a network connection between the two that can be used for custom traffic. Though there are ways the hotspot could be implemented where that would not work. Also of concern, the "client" device will now be sending all of its network traffic through the hotspot device, including not just foreground apps but anything it decides to do in the background.
First you need to know to which device you want to transfer the data over network like to mobile device to pc. Suppose you are trying to send data you need will a continuous socket connection using a thread ... the back end device should accept the socket connection and accept the stream....
consider the frist device as client which will write the stream
Runnable action = new Runnable() {
public void run() {
//create your connection
while (true){
//write your stream here
}
}
};
new Thread(action).start();
and server side the device will open the stream and read it continuously
now in the write your stream code use link the and integrate like the example
Click here!