Flash and background data exchange methods

Source: Internet
Author: User
Tags connect socket versions client flv file wsdl linux
Background | data

  Related articles: Flash and background data exchange method finishing

Personally feel WebService data access speed, second only to remoting, but WebService is a general-purpose interface, General Service-side technology are supported!
Advantages of WebService:
1.WebService interface support is more extensive (java,asp.net,php,coldfusion-I use the following examples);
2.WebService is a general-purpose interface, so the service-side write interface, not limited to flash use, other programs can also be called, "Kill both birds"!
3.WebService, like remoting, supports a variety of data types!
4. In addition to supporting the remoting interface, FMS also supports the WebService interface today:
Disadvantages of WebService:
Flash client to is no problem, flash development tools on its own (Webserviceconnector components), but although most of the server support this interface technology, but in addition to ColdFusion generation WebService convenience, The other implementations are quite complicated!

//=======================================;
Flash client code;
For code that is not familiar, you can use the Webserviceconnector component directly and set it up.
My main point here is to write code to invoke the WebService method.
Of course, the premise is that you want to put the Webserviceconnector component into the library, otherwise the class can not be referenced.
//=======================================;
Stop ();
Reference WebService class;
Import Mx.services.WebService;
Defines the path of the webservice;
var ws_url:string = http://localhost:8500/klstudio/myservice.cfc?wsdl;
Define the WebService object;
var ws:webservice = new WebService (Ws_url);
Call the WebService method;
var callobject = ws.getsting ("Kinglong");
Sets the return result object;
Callobject.onresult = function (Result) {
Trace ("Result:" +result);
}
If the call error returns information (this is optional);
Callobject.onfault = function (fault) {
Trace ("Fault:" +fault.faultstring);
}

Note: If the return result is a dataset, then each field name is capitalized, regardless of whether your server is capitalized!================================================================
Server-side method definition (I still take coldfusion component for example, other versions please refer to the connection provided above)
================================================================

<!---file name is MYSERVICE.CFC--->
<cfcomponent displayname= "My Services" >
<!---defines the GetString method, you need to set access to remote, otherwise webservice cannot call this method--->
<cffunction name= "getString" access= "remote" returntype= "string" >
<cfargument name= "Name" type= "string" required= "true" >
<cfset myresult = arguments.name & ", welcome!" >
<cfreturn myresult>
</cffunction>
</cfcomponent>

When you call, just add "? wsdl" to the back of the CFC path. :)

Four, Xmlsocket
This is the last of the four methods of Loadvars (XML), flash remoting, Webservice, Xmlsocket, Also let everyone waiting (unexpectedly several articles in the online very popular, and one of them sent me an e-mail, see me this last one, haha, still quite gratified.) To reprint I want to declare, first of these articles are welcome to reprint, but to explain the author of the article, as well as the original article, I found that some sites reproduced, even the author did not write or write the wrong. This will affect my future writing article mood, hereby explain!). Now it's time to turn to the chase! The
Xmlsocket is mainly used for instant messaging with the server, and the current application areas are mainly flash text chat and flash online games.
Xmlsocket Benefits:
1, can and server-side instant communication;
2, flash player 5.0 above the version of the built-in classes, do not need to install additional components or plug-ins;
3, Because Xmlsocket is the equivalent of a socket client, so the general middleware support (such as Java,. NET, and so on)
Xmlsocket:
1, Xmlsocket can only pass strings or XML-formatted text, a single data type,
2, Xmlsocket server-side development, you need to know more about the socket technology to do, Fortunately, there are off-the-shelf software on the web (Business xmlsocket server  have unity, fortress, open source xmlsocket server  have oregano  Multiuser server),
3, and the Xmlsocket 80 port and Flash security policy issues ...

This is the top four (Loadvars (XML), Flash Remoting, Webservice, xmlsocket) supplement, I did not take into account, because flashcom (FMS) is mainly used in streaming media technology, Today to thank danger put forward, oh, today is a good mood, on the synthesis!
Flashcom (FMS) is mainly used for streaming media communication with the server, the current application field is the Flash streaming media playback ,Flash live broadcast ,Flash video audio chat ,Flash video Conferencing ,Flash online games and so on.

Flashcom's operating environment (FMS operating Environment ):
1. Windows operating system: Windows Server or Windows NT 4.0 Server (SP6);
2, Linux operating system: Red Hat Linux 7.3 or 8.0;
3, the server CPU is Pentium III MHz or higher (the recommended value is two Pentium 4 CPU);
4, the server's memory is 256M RAM or higher (the recommended value is 512M).

Advantages of flashcom (FMS) :
1, to achieve real-time video audio communication (of course, it also supports text communication);
2, to be able to stream the media synchronized playback (also called live broadcast online);
3. Able to record video audio through Flash Player (more than 6.0 versions) without the need of other clients;
4, can realize the control between the client implementation (such as meeting moderator permissions).

Disadvantages of flashcom (FMS) :
1, flashcom (FMS) Server software is mm company 's products, need to spend money to buy (a small amount of input), fortunately there is now a perfect open source project-RED5;
2, by the streaming media server software, so the

//=======================================;
Flash client (for example, with a simple online recording video)
//=======================================;
Stop ();
var nc:netconnection = new Netconnection ();
var Ns:netstream;
var Cam:camera = Camera.get ();
var mic:microphone = Microphone.get ();
Preview the local webcam video;
Video_box.attachvideo (CAM);
Initialization of NetStream;
function Initnetstream (): Void {
NS = new NetStream (NC);
Set a buffer time of 2 seconds;
Ns.setbuffertime (2);
Use NetStream to load video and audio objects;
Ns.attachvideo (CAM);
Ns.attachaudio (MIC);
NetStream state information;
Ns.onstatus = function (info:object) {
Trace ("Ns.onstatus:" +info.code);
};
}
Recording video audio;
function Recordstream () {
Ns.publish ("Kinglong", "record");
}
Stop recording;
function Stopstream () {
Ns.close ();
}
Delete video audio files;
function Deletestream () {
Nc.call ("Clearstream", NULL, "Kinglong");
}
Netconnection state information;
Nc.onstatus = function (info:object) {
Trace ("Nc.onstatus:" +info.code);
Switch (info.code) {
Case "NetConnection.Connect.Success":
Initnetstream ();
Break
}
};
Connecting flashcom servers
Nc.connect ("rtmp:/" + "Recordstream");

//=======================================;
Flashcom (FMS) service-side code
Save the following code as a MAIN.ASC file (this filename is fixed) and create a recordstream directory (corresponding to the "Recodstream" of the client) in the Flashcom applications directory. And put the MAIN.ASC in this directory.

//=======================================;
Application.onappstart = function () {
}
Application.onappstop = function () {
}
Application.onconnect = function (client) {
Application.acceptconnection (client);
}
Application.ondisconnect = function (client) {
}
//=======================================;
Gets the flv file time length;
function Getstreamlength (name) {
return stream.length (name);;
}
//=======================================;
Delete flv file;
function Clearstream (name) {
Trace ("Clearstream (" +name+); ");
var stream = Stream.get (name);
return Stream.clear ();
}
//=======================================;
Set Client.prototype;
//=======================================;
Client.prototype.getStreamLength = Getstreamlength;
Client.prototype.clearStream = Clearstream;

add to FMS official Chinese website Related data address :http://www.macromedia.com/cn/software/flashmediaserver/productinfo/pricing/



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.