public abstract class BaseSdlSession extends Object implements ISdlProtocol, ISecurityInitializedListener
| Modifier and Type | Field and Description |
|---|---|
protected VideoStreamingParameters |
acceptedVideoParams |
protected VideoStreamingParameters |
desiredVideoParams |
protected CopyOnWriteArrayList<SessionType> |
encryptedServices |
protected SdlProtocolBase |
sdlProtocol |
protected SdlSecurityBase |
sdlSecurity |
protected HashMap<SessionType,CopyOnWriteArrayList<ISdlServiceListener>> |
serviceListeners |
protected int |
sessionId |
protected ISdlSessionListener |
sessionListener |
protected BaseTransportConfig |
transportConfig |
| Constructor and Description |
|---|
BaseSdlSession(ISdlSessionListener listener,
BaseTransportConfig config) |
| Modifier and Type | Method and Description |
|---|---|
void |
addServiceListener(SessionType serviceType,
ISdlServiceListener sdlServiceListener) |
void |
close() |
void |
endService(SessionType serviceType) |
protected SystemInfo |
extractSystemInfo(SdlPacket packet)
Extracts the SystemInfo out of a packet
|
VideoStreamingParameters |
getAcceptedVideoParams() |
List<TransportRecord> |
getActiveTransports()
Retrieves list of the active transports
|
TransportType |
getCurrentTransportType() |
VideoStreamingParameters |
getDesiredVideoParams()
Returns the currently set desired video streaming parameters.
|
boolean |
getIsConnected() |
int |
getMtu() |
long |
getMtu(SessionType type) |
Version |
getProtocolVersion()
Get the current protocol version used by this session
|
protected abstract SdlProtocolBase |
getSdlProtocolImplementation() |
SdlSecurityBase |
getSdlSecurity()
A method that should be implemented by the hosting class of the SdlProtocol instance that will
return the currently being used security library if any.
|
HashMap<SessionType,CopyOnWriteArrayList<ISdlServiceListener>> |
getServiceListeners() |
int |
getSessionId()
Method that the protocol layer will use to obtain the session ID
|
BaseTransportConfig |
getTransportConfig() |
boolean |
isServiceProtected(SessionType sType) |
boolean |
isTransportForServiceAvailable(SessionType sessionType)
Check to see if a transport is available to start/use the supplied service.
|
void |
onAuthTokenReceived(String authToken)
A callback to indicate the SDL connected device has supplied an authentication token to this
application.
|
void |
onProtocolError(String info,
Exception e)
Called to indicate that a protocol error was detected in received data.
|
void |
onProtocolMessageReceived(ProtocolMessage msg)
Called to indicate that a complete message (RPC, BULK, etc.) has been received.
|
void |
onSecurityInitialized() |
abstract void |
onServiceEnded(SdlPacket packet,
SessionType sessionType,
int sessionID)
This will get called when a service has ended
|
abstract void |
onServiceError(SdlPacket packet,
SessionType sessionType,
int sessionID,
String error)
If there is an error with starting or stopping the service or any other error this method
will be called.
|
abstract void |
onServiceStarted(SdlPacket packet,
SessionType sessionType,
int sessionID,
Version version,
boolean isEncrypted)
Called to indicate that a service has been started
|
void |
onTransportDisconnected(String info,
boolean altTransportAvailable,
BaseTransportConfig transportConfig)
Called when a transport disconnects
|
protected void |
processControlService(ProtocolMessage msg) |
boolean |
removeServiceListener(SessionType serviceType,
ISdlServiceListener sdlServiceListener) |
void |
sendMessage(ProtocolMessage msg) |
void |
setAcceptedVideoParams(VideoStreamingParameters params)
A callback that will be called when the video service has been successfully started and the
streaming parameters have been negotiated.
|
void |
setDesiredVideoParams(VideoStreamingParameters params) |
void |
setSdlSecurity(SdlSecurityBase sec) |
void |
shutdown(String info)
A request made by the protocol layer to shutdown the layers above it.
|
void |
startService(SessionType serviceType,
boolean isEncrypted) |
void |
startSession() |
protected final SdlProtocolBase sdlProtocol
protected final BaseTransportConfig transportConfig
protected ISdlSessionListener sessionListener
protected SdlSecurityBase sdlSecurity
protected VideoStreamingParameters desiredVideoParams
protected VideoStreamingParameters acceptedVideoParams
protected int sessionId
protected HashMap<SessionType,CopyOnWriteArrayList<ISdlServiceListener>> serviceListeners
protected final CopyOnWriteArrayList<SessionType> encryptedServices
public BaseSdlSession(ISdlSessionListener listener, BaseTransportConfig config)
protected abstract SdlProtocolBase getSdlProtocolImplementation()
public int getMtu()
public long getMtu(SessionType type)
public void close()
public void startService(SessionType serviceType, boolean isEncrypted)
public void endService(SessionType serviceType)
public void startSession()
throws SdlException
SdlExceptionpublic void sendMessage(ProtocolMessage msg)
public TransportType getCurrentTransportType()
public boolean getIsConnected()
public Version getProtocolVersion()
public BaseTransportConfig getTransportConfig()
public void setSdlSecurity(SdlSecurityBase sec)
protected void processControlService(ProtocolMessage msg)
protected SystemInfo extractSystemInfo(SdlPacket packet)
packet - should be a StartServiceACK for the RPC servicepublic boolean isServiceProtected(SessionType sType)
public void addServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener)
public boolean removeServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener)
public HashMap<SessionType,CopyOnWriteArrayList<ISdlServiceListener>> getServiceListeners()
public void setDesiredVideoParams(VideoStreamingParameters params)
public VideoStreamingParameters getAcceptedVideoParams()
public void onProtocolMessageReceived(ProtocolMessage msg)
ISdlProtocolonProtocolMessageReceived in interface ISdlProtocolmsg - the message that was receivedpublic abstract void onServiceStarted(SdlPacket packet, SessionType sessionType, int sessionID, Version version, boolean isEncrypted)
ISdlProtocolonServiceStarted in interface ISdlProtocolpacket - the control packet StartServiceACK received from the connected devicesessionType - the service type that has been startedsessionID - the session ID that this service has been started onversion - the protocol version used for this session and serviceisEncrypted - if the service is encryptedpublic abstract void onServiceEnded(SdlPacket packet, SessionType sessionType, int sessionID)
ISdlProtocolonServiceEnded in interface ISdlProtocolpacket - the packet received that ended this servicesessionType - the service type that has endedsessionID - the id of the session that this service was operating onpublic abstract void onServiceError(SdlPacket packet, SessionType sessionType, int sessionID, String error)
ISdlProtocolonServiceError in interface ISdlProtocolpacket - if there is a packet that caused this error it will be included, however this
can be null.sessionType - the service type that experienced the errorsessionID - the session ID that this service was associated witherror - a human readable string of the errorpublic void onProtocolError(String info, Exception e)
ISdlProtocolonProtocolError in interface ISdlProtocolinfo - a human readable string of the errore - the exception if one occurredpublic int getSessionId()
ISdlProtocolgetSessionId in interface ISdlProtocolpublic void shutdown(String info)
ISdlProtocolshutdown in interface ISdlProtocolinfo - human readable string on why the shutdown should occurpublic void onTransportDisconnected(String info, boolean altTransportAvailable, BaseTransportConfig transportConfig)
ISdlProtocolonTransportDisconnected in interface ISdlProtocolinfo - a human readable string including information on the disconnected transportaltTransportAvailable - a boolean flag indicating if there is another transport that can
be used to connect with the SDL enabled device.transportConfig - the previously supplied transport configpublic SdlSecurityBase getSdlSecurity()
ISdlProtocolgetSdlSecurity in interface ISdlProtocolpublic VideoStreamingParameters getDesiredVideoParams()
getDesiredVideoParams in interface ISdlProtocolpublic void setAcceptedVideoParams(VideoStreamingParameters params)
ISdlProtocolsetAcceptedVideoParams in interface ISdlProtocolparams - the negotiated and accepted video parameters that should be used
to stream to the SDL enabled device.public void onAuthTokenReceived(String authToken)
ISdlProtocolonAuthTokenReceived in interface ISdlProtocolpublic void onSecurityInitialized()
onSecurityInitialized in interface ISecurityInitializedListenerpublic boolean isTransportForServiceAvailable(SessionType sessionType)
sessionType - the session that should be checked for transport availability@Nullable public List<TransportRecord> getActiveTransports()