How-to reject a RTMP/HLS/RTSP client connections

A quick question that I see repetitively is on how to reject a RTMP, HLS, and/or RTSP client based connections.  To do so, you can have a look at the following:

For RTMP:

sendClientOnStatusError((IClient)client, "NetStream.Play.Failed", "This client was rejected");
client.shutdownClient();

For HLS:

(IHTTPStreamerSession)httpSession.rejectSession();

For RTSP:

(RTPSession)rtpSession.rejectSession();

To see this in context, you might do the following:

public class RejectConnections extends ModuleBase {

	public void play(IClient client, RequestFunction function, AMFDataList params) {
		sendClientOnStatusError(client, "NetStream.Play.Failed", "Client has been rejected");
                client.shutdownClient();
	}

	public void onHTTPSessionCreate(IHTTPStreamerSession httpSession) {
		httpSession.rejectSession();
	}

	public void onRTPSessionCreate(RTPSession rtpSession) {
		rtpSession.rejectSession();
	}
}

Comments are closed.