Copy link to clipboard
Copied
Hello everybody,
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
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.
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
Copy link to clipboard
Copied
there are some, like this project
GitHub - yurydelendik/rtmp.js: Real Time Message Protocol (RTMP) messaging library in JavaScript
also maybe a substitute of AMS
rtmfp and spidermonkey module support · Issue #168 · illuspas/Node-Media-Server · GitHub
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..
Copy link to clipboard
Copied
I've been looking for a solution like this for months ... Can I see your example?
Copy link to clipboard
Copied
Was years for me
So there are two key files in node media server to look at:
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
Copy link to clipboard
Copied
Thank you. I can have an example like you did on node js to connect to Amf.
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..
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?
Copy link to clipboard
Copied
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