• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

How to connect javascript client to ams (rtmp and shared objects)

New Here ,
Feb 08, 2019 Feb 08, 2019

Copy link to clipboard

Copied

Hello everybody,

  • in 2008 I created an online card game: a flash client and a flash media server.
  • In 2010, I bought a rtmp library for objective c (from the midnight coders) and developped the ipad client
  • in 2012, I bought a new version of fms (5)

This was just to highlight that I already invested a lot of time and money in ams.

So now, as Flash is rarer and rarer in the browsers, I would like to rebuild a game client in javascript: but it seems that no javascript library are existing yet (I would be ready to buy one..), so what are my options ?

I am not using any streaming functionality but my game is using a rtmp connection and shared objects..

Should I look into building a gateway, on the server, node.js-socket.io discussing with ams, for instance (it that is possible..), and my javascript would do a standard socket connection to the socket.io ?

I need guidance to understand where I should be invested my (little spare) time

Thanks!

Cyril

Views

2.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 23, 2019 Feb 23, 2019

Copy link to clipboard

Copied

I don't see any issue you can connect directly you js client to ams as the protocol is rtmp.

just do it like it was a flash client.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2019 Feb 23, 2019

Copy link to clipboard

Copied

Hi Robert,

I wish it was that simple

Flash had rtmp support built in: I never found any rtmp library for javascript... maybe you know one ?

Best

Cyril

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 23, 2019 Feb 23, 2019

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2019 Feb 23, 2019

Copy link to clipboard

Copied

Yup, I went for the rtmp client of your second link and spent several hours last week to understand and adapt it, so far I managed the handshake with my ams and bidirectional remote method invocation with parameters, which is theoritcally enough for me but if I think I will invest some more time trying to implement the shared objects..

so the current archi would be ams <-[rtmp]-> node.js <-[websocket]-> javascript client..

Now I am wondering if I could reuse what I already did and / or your first link and see if I could remove node from the picture, using rtmpt..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 04, 2019 Mar 04, 2019

Copy link to clipboard

Copied

I've been looking for a solution like this for months ... Can I see your example?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2019 Mar 04, 2019

Copy link to clipboard

Copied

Was years for me

So there are two key files in node media server to look at:

  1. Node-Media-Server/node_rtmp_client.js at master · illuspas/Node-Media-Server · GitHub
    • had to change a little bit  rtmpSendConnect -> add the instance name to both app and tcUrl params
  2. Node-Media-Server/node_core_amf.js at master · illuspas/Node-Media-Server · GitHub
    • any method you want to call on the server OR you want the server being able to call from the js client should have a "signature"in the json object rtmpCmdCode (line 939)

Then I managed to call this method on the server:

Client.prototype.testJS = function (cmdObj, info){

     trace("testJS received from :"+this.nick);

     trace("cmdObj.myString:"+cmdObj.myString);

     trace("cmdObj.myNumber:"+cmdObj.myNumber);

     trace("cmdObj.myArray:"+cmdObj.myArray);

     //trace("obj:"+obj);

}

With this code from file 1:

rtmpTestJS() {

     let opt = {

            cmd: 'testJS',

            transId: 0,

            info: "pouet pouet",

            cmdObj: {

               myString: "Excellent!",

               myNumber: 777,

               myArray: [1,2,3,4]

            }

        };

     this.sendInvokeMessage(this.streamId, opt);

}

And from the server this code:

var cmdObj=new Object();

cmdObj.string="A string";

cmdObj.number=69;

cmdObj.array=[5,6,7,8];

client.call("testFMS",null,cmdObj);

Will trigger a specific case from the rtmpInvokeHandler of file 1:

case 'testFMS':

     let obj = invokeMessage.cmdObj;

     Logger.log('rtmpInvokeHandler MESSAGE FROM AMS-> STRING:', obj.string);

     Logger.log('rtmpInvokeHandler MESSAGE FROM AMS-> NUMBER:', obj.number);

     Logger.log('rtmpInvokeHandler MESSAGE FROM AMS-> ARRAY:', obj.array);

break;

Hopefully, I am not using too much shared objects, and that is enough for me, but I am quite sure the basis is there, an that with some (could be a lot, depending of your luck / insipiration) reverse engineering, shared objects support could be achieved, but I don't have the time / patience to do it... and this part of the rtmp protocol is not well documented, and it is very difficult to find examples..

hope this will help you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 04, 2019 Mar 04, 2019

Copy link to clipboard

Copied

Thank you. I can have an example like you did on node js to connect to Amf.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2019 Mar 04, 2019

Copy link to clipboard

Copied

this is what I tried to describe in my previous answer: you need to download GitHub - illuspas/Node-Media-Server: A Node.js implementation of RTMP/HTTP-FLV/WS-FLV/HLS/DASH/MP4 M...

Change the two aformentioned files according to your requirements and then run:

node test_rtmp_client.js

To see if you manage to connect... once you have the connection and the bi directional remote method invocation working, then you can extract the required files / packages from nms, and adapt them..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 04, 2019 Mar 04, 2019

Copy link to clipboard

Copied

Excuse me so much if I ask again. In as3 when I connect I do this way: nc = new NetConnection (); nc.connect ("rtmp: // localhost / example", parameter1, parameter2); ... ... How can I pass parameters during the connection?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2019 Mar 04, 2019

Copy link to clipboard

Copied

LATEST

Yup, so, if you download nms, you'll see in this file Node-Media-Server/test_rtmp_client.js at master · illuspas/Node-Media-Server · GitHub the connection is happening there:

let rc = new NodeRtmpClient('rtmp://192.168.0.10/live/stream');

Then if go look into the code you'll reach the rtmpSendConnect method from this file Node-Media-Server/node_rtmp_client.js at master · illuspas/Node-Media-Server · GitHub 

which is where you need to do the adaptation I adivsed two posts ago

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines