A very important feature of the system is that the stream can be shared among multiple servers.
With this function, we can distribute the streams on the source server to other servers. These servers that obtain the streams can also be used as new source servers. This function is a bit like an FMS cluster.
We all know that using the WMP plug-in can obtain the streaming media address on the Internet to create a network TV station. In fact, using flash and FMS can also be achieved.
Collect TV signals on a server, and then pub the collected stream to an app with an IP address of 127.0.0.1 (Suppose it is a tvset). Assume that the stream is named "cctv1 ",
In this way, the FP Client Connected to the server can easily obtain the stream. However, if the number of connections is large, the server may be overloaded and traffic distribution needs to be considered.
There are at least two kinds of shunting solutions. One is to use the proxy server, and the other is to share the stream among multiple servers.
So how can we distribute the stream?
This first source server does not need to do anything. It is only responsible for receiving and pub TV signals. We need to find another server, which is used in the FMS.ProgramIn Main. ASC, write the followingCode:
// Executed when the program starts
Application. onappstart = function (){
This. mync = new netconnection ();
This. mync. onstatus = nc_onstatus;
This. mync. Connect ("rtmp: // address of the first source server/tvset ");
};
Function nc_onstatus (Info ){
Switch (info. Code ){
Case "netconnection. Connect. Success ":
Application. mystream = stream. Get ("cctv1 ");
Application. mystream. onstatus = ns_onstatus;
If (application. mystream ){
Application. mystream. Play ("cctv1",-2,-1, false, application. mync );
}
Trace ("connection successful! ");
Break;
Case "netconnection. Connect. Failed ":
Trace ("connection failed! ");
Break;
Case "netconnection. Connect. Rejected ":
Trace ("connection failed! ");
Break;
}
}
Function ns_onstatus (Info ){
Trace (info. Code );
}
In this way, the new server obtains the same stream as the first source server.
When the client is connected again, it does not have to connect to the first source server and connect to the new source server. The new source server can be one or multiple, in this way, the burden on the first source server will be minimized.