Netconnect object for FCS Programming

Source: Internet
Author: User
Object Introduction
If you want to transmit the local video or sound to other clients, the Flash video must be online to the Flash COM server. The online method is to connect to the Flash com application in the specified path through the connect () method of the netconnect object.
Flashcom uses the rtmp protocol to share and transmit your data, sound, and video.

Object Property:
Isconnected connection?
The URL of the URI connection. You can use the following method:
• Rtmp: // www.mycompany.com/mymaindirectory/groupchatapp/helpdesk
• Rtmpt:/sharedwhiteboardapp/june2002
• Rtmp: 1234/chatapp/room_name

For example, if you want to connect to the chat program of vchat and enter room room1, you can write as follows: 1: // create an online object
2: client_nc = new netconnect ();
3: // connect to the application entity
4: client_nc.connect ('rtmp: // mywebsite.com/vchat/room1 ');

You can enter the default room without specifying the room name.
For detailed connection syntax, refer to my previous note: Connection example.

The netconnect object does not support HTTP, so the connection method similar to the following is incorrect:

  1. myConn.connect('http://www.mydomain.com/myfile.php?id= 0001') ;

In addition, the flash COM server does not support any direct remote call methods such as geturl or loadvars. That is to say, the server cannot exchange data with the background program, you must use the call method to call the client method or flashremote (or open-source phpobject ).

Remote Call
If you want to call a method or command on the remote server, you can use the call method. The format of this method is as follows: 1: Call (method name, the object that receives the returned value (null if not ), [parameter 1, parameter 2,...])
2: // The parameter list is the parameter that needs to be passed to the server method. If the parameter is redundant, it will be ignored by the server.

Like many objects, the netconnect object has an onstatus event to accept the returned information.
The following is a common syntax: 1: client_nc.onstatus = function (Info ){
2: // program code for processing status information
3 :};

The type of status information is recorded in the Level Attribute of the information object, and its value is
Status
Warning warning
Error
The information is recorded in the Code attribute of the object. In the netconnect object, you can refer to the following sample program to output the returned information: 01: client_nc.onstatus = function (Info ){
02: trace ('information type: '+ info. Level + newline +' Information Content: '+ info. Code );
03: Switch (info. Code ){
04: Case 'netconnection. Connect. SUCCESS ':
05: trace ('Online successful! ');
06: break;
07: Case 'netconnection. Connect. failed ':
08: trace ('Online failed! ');
09: break;
10: Case 'netconnection. Connect. Closed ':
11: trace ('Online disconnection! ');
12: break;
13 :}
14 :};

Save logs
If needed, you can record the connection log: 1: client_nc.onstatus = function (Info)
2 :{
3: _ root. log + = 'Recording stream status./N ';
4: _ root. log + = 'event: '+ info. Code +'/N ';
5: _ root. log + = 'Type: '+ info. Level +'/N ';
6: _ root. log + = 'message: '+ info. Description +'/N ';
7 :}

Close connection
To close the connection, use the close () method. The following code stops the data stream object and closes connection 1: function disconnect (){
2: // stops publishing the stream.
3: srcstream. Close ();
4: // deletes the source stream connection.
5: connection. Close ();
6 :}

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.