Red5 video chat tutorial AS3 - streaming

Where can I find working examples of a video chat application based on AS3 and Red5?
I'm having trouble to understand how to attach a user stream to another user and vice-versa. Can someone point to a simple example or provider some sample code?

Here is a link to a SimpleChat demo project from Red5: http://www.red5.org/downloads/simpledemos/
Anyway just to give you a basic concept:
Assuming that you have a chat application, you will have a single ID for each user, right? So lets suppose a scenario where user A start streaming the mic/cam to user B:
//start streaming the mic and camera
nsPub = new NetStream ( netConnection );
nsPub.attachAudio(Microphone.getMicrophone());
nsPub.attachCamera(Camera.getCamera());
nsPub.publish('A');
//need to send a command to user B to notify him that user A started streaming,
//this command can be sent by a SharedObject or invoking a remote method, that will
//invoke a client method in B
//code to receive the mic/cam streaming from user A
nsCli = new NetStream ( netConnection );
videoCompoment.attachNetStream( nsCli );
nsCli.play('A');

Related

Background notifications using Ionic like a mortal

I have been trying for several months to implement an app that receives notifications whose content I want to be stored in the database of my application. I am using the Firebase Messagging plugin and I am receiving the notifications correctly, both in Foreground and in Background.
However, in the background I am unable to execute my callback without the need to press the notification explicitly by the user. Likewise, there is no way to increase the badge of the application when it is not open.
Now, I do not understand how applications like WhatsApp, Telegram and any other application that is not made by mere mortals work. How is it possible that they can get the data in backgroud, manage the badges, synchronize messages, etc? Being that, supposedly the services like Firebase are limited in background. Even with plugins like Background Mode my application is suspended by Android when the user closes it.
The code that I am currently using to handle notifications is the following:
// In foreground (WORKS)
this.firebaseMessaging.onMessage().subscribe((notificacion) => {
// Insert in DB
...
});
// In background (DOESN'T WORK)
this.firebaseMessaging.onBackgroundMessage().subscribe((notificacion) => {
// Insert in DB
...
});
What alternative is left? The only thing that occurs to me is to use notifications in Foreground and background only as a warning. So every time I open the application I'll have to call a message synchronization callback with the server (with badge management included).
If someone has some better way, I would greatly appreciate it if you throw a little light on the subject.
From already thank you very much
Ok, after more than a year I think it's time to close this question. I solved the problem this way:
Suppose I need to get a list of messages. This action is made by a function called getMessages()
When a new message is created in the backend, I send a push notification through Firebase service.
If the push notification is received in foreground I refresh call the method directly:
this.firebaseMessaging.onMessage().subscribe((notificacion) => {
getMessages();
});
If the push notification is received in background and the user taps on it there isn't a problem as it's supported by the plugin:
this.firebaseMessaging.onBackgroundMessage().subscribe((notificacion) => {
getMessages();
});
If the push notification is received in background but the user DOES NOT tap on it and opens the app in another way than the notification, we need to excecute the corresponing function when the app is opened in app.component.ts file:
this.platform.ready().then(() => {
getMessages();
// Extra stuff like this.statusBar.styleDefault(); or this.splashScreen.hide();
});
That way all the cases are considered! You should keep in mind that apps like Whatsapp or Telegram are developed in official technologies like Java or Kotlin which not only have official native plugins, also its code are excecuted natively and not in a limited browser as Cordova or Capacitor frameworks do

conv.user.storage value not saving across sessions when invoking via speech

I am trying to use the conv.user.storage to save information across sessions for my user, namely I want to give him an ID.
When I invoke my action via keyboard, it will save my user storage ID fine, and when I run the action again from my developer console, it will console.log the saved ID in the session.
However, when I invoke the action via speech, it will not save the storage value for the next session.
const generateRandomId = require('uuid/v4');
app.intent('Default Welcome Intent',(conv) =>{
if(conv.user.storage["id"] ==undefined){
conv.user.storage.id = generateRandomId();
}
console.log(conv.user.storage.id);
conv.close(`your user id is ${conv.user.storage.id});
});
so this intent will generate a new value every time for conv.user.storage.id when using the action via speech with my google home device, I want it to be the same every time, this is so I can save my user ID in the database to track their highscore.
EDIT
This is also occurs when I try to track the ID using conv.user.id, so when i use my action with keyboard it will always be the same ID of:
ABwppHGgFSnon5unUNjikof_5G-m_8lldEd_LIokoqYlOsCSFm96--UHDJ_GOHHo6hFOQUZVoMTT6TvfT_edklKbaPm
whereas the id which is produced by conv.user.id when using the app via speech is just a bunch of numbers like this:
1539765602273384238765

Retrieve Dailymotion Games chat messages

I would like to retrieve Dailymotion Games chat messages using their API, but the official documentation is not very clear on this point => https://faq.dailymotion.com/hc/en-us/articles/203886473-Dailymotion-live-API-for-developers
I tried to use the API to retrieve comments of a video with my live video id (endpoint => https://api.dailymotion.com/video/[LIVE_VIDEO_ID]/comments), but it doesn't return any chat messages...
Do you know if it's possible?
Ok, I've searched a little bit more and I found a more elegant way to do that avoiding the scraping method.
In fact the embed chat page (returned by the chat_embed_url) use EventSource to get notified when a new message arrived.
With this good NPM package, I've been able to retrieve chat messages in only 5 lines:
var EventSource = require('eventsource');
var url = 'http://dmchat.dailymotion.com/rooms/[USERNAME]-[CHANNEL_ID]';
var es = new EventSource(url);
es.addEventListener('message', function (e) {
console.log(e.data);
});
A comment on a video is different from the chat feature, this is why chat messages don't appear in comments.
You can't get individual chat messages so far, but you can get the chat embed code on two different ways:
using the Dailymotion API, you can request the chat_embed_html or chat_embed_url fields on the video object
or you can get it directly from the video pages on dailymotion games, by clicking on the settings icon below the chat, and click "copy embed code"

iphone how to capture simple login/logout event from web to native

I am developing iPhone application which loads login page of my website. I am able to load my login page using phonegap/childbrowser. I am newbie to JS, Phonegap.
How do my native/phonegap application should handle logout and login event has performed on the webpage? Please guide me how to know user has logged out.
Also is it possible to add support for Push Notification in phonegap/childbrowser application ? How?
So far have seen facebook login-logout questions around but hard to understand and couldnt simulate similar approach.
does your whole app run using the childbrowser? If so why not just have the login log out as piece of your app?
Also if you have to use the childbrowser best bet is to set up a locationchange event and if the location equals a login success page then append some arguments and store those using localstorage.
example -
client_browser.onLocationChange = function(loc){
locationchange(loc);
};
function locationchange(loc){
if(loc.indexOf("http://www.example.com/success?login=true&user=foo") > -1){
var user = loc.match(/user=(.*)$/)[1]; // grab user info
localStorage.setItem('login','true'); // set login as true
localStorage.setItem('user',user); // set username
}
}
that will save to your app locally that the user is logged in and their username, which you can use later if you need to use the childbrowser by passing that in the url you open and on the server side you'll have to look for those arguments.
to log out just open the childbrowser and send a logout argument
www.example.com/logout?user=foo
and in your localStorage
localStorage.setItem('login','false');
Honestly this is kind of a vague question, it would really help to understand why you're wanting to do this in the childBrowser vs your app...

Access Facebook albums from a flash app

I want to create a flash Facebook application in which, after pressing a button, the user will be able to browse his/her photo albums and choose a photo. How should i do that? What will be the code under the button to gain authentication from any user using this application?
Thanks.
I am currently writing a facebook application for a university assignment that will allow the user to do everything you can do in facebook, but via the flash player window. You will need a few basic things happening in order to do it.
User log in and authentication - this must be done via Facebook - using OAuth authentication, and meeting all of facebook's security policies
register the application with facebook
Use the Graph API (facebook's developer's toolkit) to get the necessary functions that will communicate with facebook via flash.
In Flash itself you will use a bunch of URLRequest functions to send out to FB for information, then you will need to retrieve that data responses and store them to variables (extracting data with a few lines of code is easy, something like this;
//initialise variables
public var photoURL:String;
var Request:URLRequest = new URLRequest("http://www.whatever the url for the graph api service you are using which is founf from FB");
//that ^^ will send off a request for the url, you then want to use the returned data by registering an event handler like this below
functionName.addEventListener(onComplete, completeHandler);
functionName(event, EVENT)
{
var loader:URLLoader = new URLLoader(Request);
var data:XML = new XMLData(load.loader); //i think this is right but not 100% sure, fiddle with it
//then you want to extract the data that is returned, for example, extracting xml data from a rest request works by hitting data from the xml by specifying a path to the object you want. an example of xml is this <rsp stat="ok"><photos ......more code="morecode"><photo url="url of photo"></photo</photos> so you can hit the url in that example like this;
photoURL = data.photos.photo.#url; //this line will grab the photo url for you, allowing you to dynamically create an array and assign photos to the flash stage according to the url you get
}
this is fairly advanced stuff and I am assuming that you have some decent knowledge on AS3, XML, and the FB API, if you need more help just reply