\doxysection{com.\+tritondigital.\+net.\+streaming.\+proxy.\+client.\+Client Class Reference}
\hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client}{}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client}\index{com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}}


Base class for any network client allowing connection to a stream.  


Inheritance diagram for com.\+tritondigital.\+net.\+streaming.\+proxy.\+client.\+Client\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client}
\end{center}
\end{figure}
\doxysubsubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
interface \mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_1_1DataReceivedListener}{Data\+Received\+Listener}}
\begin{DoxyCompactList}\small\item\em Interface definition for a callback to be invoked when new data is received from the stream. \end{DoxyCompactList}\item 
enum \mbox{\hyperlink{enumcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_1_1State}{State}}
\begin{DoxyCompactList}\small\item\em All different states in which the client can be. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_1_1StateChangedListener}{State\+Changed\+Listener}}
\begin{DoxyCompactList}\small\item\em Interface to be implemented in order to be notified about the important changes of state of the client. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ad6ca5711b4ae05fb58d2d76fcec92220}{set\+User\+Agent}} (String user\+Agent)
\begin{DoxyCompactList}\small\item\em Sets the User Agent used when connecting. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_aa9e5baaec2c4e5a22dcfbfaf4501028f}{connect}} (URI uri)
\begin{DoxyCompactList}\small\item\em Connects the client to the given URI and start streaming. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ac0a0ad5129cf08b54ef48d14ffaa01cb}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ac0a0ad5129cf08b54ef48d14ffaa01cb} 
void {\bfseries stop} ()
\begin{DoxyCompactList}\small\item\em Trigger the disconnection if already connected. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_aecdebac949aba4c5ff5aa06e80a7b885}{set\+Data\+Received\+Listener}} (\mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_1_1DataReceivedListener}{Data\+Received\+Listener}} listener)
\begin{DoxyCompactList}\small\item\em Sets the listener notified whenever a chunk of data is downloaded. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a8a83dd6bffda7d39d843d665a445d36d}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a8a83dd6bffda7d39d843d665a445d36d} 
void {\bfseries set\+State\+Changed\+Listener} (\mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_1_1StateChangedListener}{State\+Changed\+Listener}} state\+Changed\+Listener)
\begin{DoxyCompactList}\small\item\em Sets the listener to be notified about the various state change on the client. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a2aab9a14a3bb469538748f4edd71e4fd}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a2aab9a14a3bb469538748f4edd71e4fd} 
\mbox{\hyperlink{enumcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_1_1State}{State}} {\bfseries get\+State} ()
\begin{DoxyCompactList}\small\item\em Gets the current state of the client. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_af943a83aa3f2872ae1e896787441e04d}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_af943a83aa3f2872ae1e896787441e04d} 
Stream\+Container\+Decoder {\bfseries get\+Stream\+Container\+Decoder} ()
\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a094a5a897518b0a168925d157fab52ec}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a094a5a897518b0a168925d157fab52ec} 
void {\bfseries set\+Stream\+Container\+Decoder} (Stream\+Container\+Decoder stream\+Container\+Decoder)
\end{DoxyCompactItemize}
\doxysubsubsection*{Static Public Attributes}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a51334c7b9188d64755bb998dabcd668b}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a51334c7b9188d64755bb998dabcd668b} 
static final String {\bfseries TAG} = "{}Client"{}
\end{DoxyCompactItemize}
\doxysubsubsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
abstract void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ae5fa383e3605942863c72139cb198406}{start\+Connecting\+In\+Background}} ()
\begin{DoxyCompactList}\small\item\em Connects the client to the given URI and start streaming. \end{DoxyCompactList}\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ad6472fbb7bfb82d0ad5c634820d8100b}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ad6472fbb7bfb82d0ad5c634820d8100b} 
abstract void {\bfseries disconnect} ()
\begin{DoxyCompactList}\small\item\em Does the job of Stops connecting or disconnect. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a0a4a3d495c473483b14c783e2d675759}{on\+Connected}} ()
\begin{DoxyCompactList}\small\item\em Called when the child class connects to a server. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a0bc40358589a266ad985698e9bd1e350}{on\+Disconnected}} ()
\begin{DoxyCompactList}\small\item\em Called when the child class disconnected. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a806b760ed62b1ad7b9825d98fc6de531}{on\+Error}} (Error\+Detail error\+Detail)
\begin{DoxyCompactList}\small\item\em Called when the child class encounters an error. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_aaac4cdade357a57672e154e8316e4c4d}{on\+Message\+Received}} (byte\mbox{[}$\,$\mbox{]} buffer, int buffer\+Length)
\begin{DoxyCompactList}\small\item\em Called when the child class receives data. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a9efe63e97ed426045891cf3ea70774c0}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a9efe63e97ed426045891cf3ea70774c0} 
\mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_1_1DataReceivedListener}{Data\+Received\+Listener}} {\bfseries m\+Data\+Received\+Listener}
\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ad7aef339d9a38a677acc747e7e3209c7}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ad7aef339d9a38a677acc747e7e3209c7} 
Stream\+Container\+Decoder {\bfseries stream\+Container\+Decoder}
\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ab09b07deb6e8e18e4ee9d002ebb4ae56}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ab09b07deb6e8e18e4ee9d002ebb4ae56} 
URI {\bfseries m\+Uri}
\item 
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ac152f9b5fa0b1bac287f50c37262472f}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ac152f9b5fa0b1bac287f50c37262472f} 
String {\bfseries m\+User\+Agent} = "{}Triton\+Digital Streaming Proxy"{}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Base class for any network client allowing connection to a stream. 

Any child of this class should provide functionality to stream from a source and notify its listener whenever new data becomes available.

The listener receives the stream data, but not the response header) and is responsible for interpreting and decoding this data. The received data is not modified of buffered. The listener is responsible for determining if the data is complete and should cumulate incomplete chunks in order to use them when enough data was received.

Child classes should correctly set the state to avoid having inconsistent behaviours in the proxy. Each state update method should be called at the appropriate time\+: on\+Connected, on\+Disconnected, on\+Error and on\+Message\+Received. It should implement the connection mechanism, make sure that the connection runs in a separate thread (method start\+Connecting\+In\+Background) and that it can be disconnected easily (method disconnect).

The connection and transfer are all done in a background thread. 

\doxysubsection{Member Function Documentation}
\Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_aa9e5baaec2c4e5a22dcfbfaf4501028f}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_aa9e5baaec2c4e5a22dcfbfaf4501028f} 
\index{com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}!connect@{connect}}
\index{connect@{connect}!com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}}
\doxysubsubsection{\texorpdfstring{connect()}{connect()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+client.\+Client.\+connect (\begin{DoxyParamCaption}\item[{URI}]{uri }\end{DoxyParamCaption})}



Connects the client to the given URI and start streaming. 

This call is asynchronous, it starts the connection process in a secondary thread and return immediately. If the URI is not supported, an error is returned and the listener is notified. If there is an error or a timeout during the connection, the listener is also notified. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a0a4a3d495c473483b14c783e2d675759}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a0a4a3d495c473483b14c783e2d675759} 
\index{com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}!onConnected@{onConnected}}
\index{onConnected@{onConnected}!com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}}
\doxysubsubsection{\texorpdfstring{onConnected()}{onConnected()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+client.\+Client.\+on\+Connected (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}}



Called when the child class connects to a server. 

When it is safe (thread synchronisation), the internal state is changed. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a0bc40358589a266ad985698e9bd1e350}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a0bc40358589a266ad985698e9bd1e350} 
\index{com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}!onDisconnected@{onDisconnected}}
\index{onDisconnected@{onDisconnected}!com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}}
\doxysubsubsection{\texorpdfstring{onDisconnected()}{onDisconnected()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+client.\+Client.\+on\+Disconnected (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}}



Called when the child class disconnected. 

When it is safe (thread synchronisation), the internal state is changed. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a806b760ed62b1ad7b9825d98fc6de531}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_a806b760ed62b1ad7b9825d98fc6de531} 
\index{com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}!onError@{onError}}
\index{onError@{onError}!com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}}
\doxysubsubsection{\texorpdfstring{onError()}{onError()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+client.\+Client.\+on\+Error (\begin{DoxyParamCaption}\item[{Error\+Detail}]{error\+Detail }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}}



Called when the child class encounters an error. 

When it is safe (thread synchronisation), the internal state is changed. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_aaac4cdade357a57672e154e8316e4c4d}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_aaac4cdade357a57672e154e8316e4c4d} 
\index{com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}!onMessageReceived@{onMessageReceived}}
\index{onMessageReceived@{onMessageReceived}!com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}}
\doxysubsubsection{\texorpdfstring{onMessageReceived()}{onMessageReceived()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+client.\+Client.\+on\+Message\+Received (\begin{DoxyParamCaption}\item[{byte\mbox{[}$\,$\mbox{]}}]{buffer,  }\item[{int}]{buffer\+Length }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}}



Called when the child class receives data. 

When it is safe (thread synchronisation), the message is posted to the listener. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_aecdebac949aba4c5ff5aa06e80a7b885}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_aecdebac949aba4c5ff5aa06e80a7b885} 
\index{com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}!setDataReceivedListener@{setDataReceivedListener}}
\index{setDataReceivedListener@{setDataReceivedListener}!com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}}
\doxysubsubsection{\texorpdfstring{setDataReceivedListener()}{setDataReceivedListener()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+client.\+Client.\+set\+Data\+Received\+Listener (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{interfacecom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_1_1DataReceivedListener}{Data\+Received\+Listener}}}]{listener }\end{DoxyParamCaption})}



Sets the listener notified whenever a chunk of data is downloaded. 

It is strongly discouraged to change the listener when a connection or a download is in progress as there is no way to know which of the new or the old listener will receive the callback during the transition. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ad6ca5711b4ae05fb58d2d76fcec92220}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ad6ca5711b4ae05fb58d2d76fcec92220} 
\index{com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}!setUserAgent@{setUserAgent}}
\index{setUserAgent@{setUserAgent}!com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}}
\doxysubsubsection{\texorpdfstring{setUserAgent()}{setUserAgent()}}
{\footnotesize\ttfamily void com.\+tritondigital.\+net.\+streaming.\+proxy.\+client.\+Client.\+set\+User\+Agent (\begin{DoxyParamCaption}\item[{String}]{user\+Agent }\end{DoxyParamCaption})}



Sets the User Agent used when connecting. 

Does nothing if set after the {\ttfamily connect} was called. \Hypertarget{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ae5fa383e3605942863c72139cb198406}\label{classcom_1_1tritondigital_1_1net_1_1streaming_1_1proxy_1_1client_1_1Client_ae5fa383e3605942863c72139cb198406} 
\index{com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}!startConnectingInBackground@{startConnectingInBackground}}
\index{startConnectingInBackground@{startConnectingInBackground}!com.tritondigital.net.streaming.proxy.client.Client@{com.tritondigital.net.streaming.proxy.client.Client}}
\doxysubsubsection{\texorpdfstring{startConnectingInBackground()}{startConnectingInBackground()}}
{\footnotesize\ttfamily abstract void com.\+tritondigital.\+net.\+streaming.\+proxy.\+client.\+Client.\+start\+Connecting\+In\+Background (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [abstract]}, {\ttfamily [protected]}}



Connects the client to the given URI and start streaming. 

This call is asynchronous, it starts the connection process in a secondary thread and return immediately. If the URI is not supported, an error is returned and the listener is notified. If there is an error or a timeout during the connection, the listener is also notified. 

The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
streamingproxy/src/main/java/com/tritondigital/net/streaming/proxy/client/Client.\+java\end{DoxyCompactItemize}
