這是目前為止最難的了吧~~
[url=http://www.nshen.net/blog/attachments/200602/25_152648_csc.rar]

要直接看原文件的點這里:[/url]
整理后就幾行代碼不過多解釋
[1b]客戶端呼叫服務器[/1b]
fla:
//客戶端呼叫server端msgfromclient函數,并將返回值trace出來
mync = new NetConnection();
mync.connect("rtmp://localhost/connect");
//返回值
var resObj = new Object();
resObj.onResult = function(val):Void {
??trace("val"+val);
};
mync.call("msgfromclient", resObj, "第一個call");
服務器端代碼是放在main.asc里的,你可以到你的application下的你的目錄下建一個main.asc,寫代碼
main.asc:
//要把函數定義到Client上!!
application.onConnect = function(client) {
??/* 在這里定義也可以,在Client.prototype里定義也可以
??client.msgfromclient=function(what){
????trace(what+"進來了")
?var aa="呼叫成功并返回結果"
????return aa
????}
??*/
application.acceptConnection(client);
};
Client.prototype.msgfromclient=function(what){
??trace(what+"進來了")
?var aa="呼叫成功并返回結果"
????return aa
??
??}
[1b]服務器端呼叫客戶端[/1b]
fla:
//server呼叫client端
//要把函數定義到nc上!!
//
mync = new NetConnection();
mync.onStatus = function(info) {
??if (info.code == "NetConnection.Connect.Success") {
????trace("連接成功");
??}
};
mync.connect("rtmp://localhost/connect");
mync.msgfromserver = function(msg) {
??trace(msg);
};
main.asc:
application.onConnect = function(client) {
application.acceptConnection(client);
client.call("msgfromserver",null,"服務器叫你啊")
};服務器端很少要求客戶端返回值,如果一定要返回,一本書上是這么寫的,沒細看
// Define a class that just stores the client ID.
AreYouOkResultHandler = function (clientID) {
?this.clientID = clientID;
};
// Handle the result of calling areYouOk( ).
AreYouOkResultHandler.onResult = function (val) {
?trace("Client " + this.clientID + " returned " + val);
};
application.pingClient = function (clientObj, clientID) {
?// Invoke a message on the client.
?clientObj.call("areYouOk", new AreYouOkResultHandler(clientID));
};
[最后編輯于 N神, at 2006-02-25 15:27:21]
本文轉自:http://www.5uflash.com/flashjiaocheng/Fmsjiaocheng/2280.html
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
