@Override public void onProtocolMessageReceived(ProtocolMessage msg) { SdlSession session = findSessionById(msg.getSessionID()); if (session != null) { session.onProtocolMessageReceived(msg); } }
@Override public void onProtocolSessionNACKed( SessionType sessionType, byte sessionID, byte version, String correlationID) { for (SdlSession session : listenerList) { session.onProtocolSessionNACKed(sessionType, sessionID, version, correlationID); } }
@Override public void onProtocolSessionEnded( SessionType sessionType, byte sessionID, String correlationID) { SdlSession session = findSessionById(sessionID); if (session != null) { session.onProtocolSessionEnded(sessionType, sessionID, correlationID); } }
private SdlSession findSessionById(byte id) { for (SdlSession listener : listenerList) { if (listener.getSessionId() == id) { return listener; } } return null; }
@Override public void onProtocolSessionStarted( SessionType sessionType, byte sessionID, byte version, String correlationID) { for (SdlSession session : listenerList) { if (session.getSessionId() == 0 || sessionType == SessionType.NAV) { session.onProtocolSessionStarted(sessionType, sessionID, version, correlationID); break; // FIXME: need changes on SDL side, as the sessionID is devided by SDL. } } }
@Override public void onTransportError(String info, Exception e) { SdlSession mySession = null; for (int z = 0; z < listenerList.size(); z++) { mySession = listenerList.get(0); if (mySession == null) continue; mySession.onTransportError(info, e); } }
@Override public void onTransportConnected() { synchronized (PROTOCOL_REFERENCE_LOCK) { if (_protocol != null) { for (SdlSession s : listenerList) { if (s.getSessionId() == 0) { startHandShake(); } } } } }
public void unregisterSession(SdlSession registerListener) { synchronized (SESSION_LOCK) { listenerList.remove(registerListener); closeConnection(listenerList.size() == 0, registerListener.getSessionId()); } }
@Override public void onHeartbeatTimedOut(byte sessionID) { for (SdlSession session : listenerList) { session.onHeartbeatTimedOut(sessionID); } }
@Override public void onProtocolError(String info, Exception e) { for (SdlSession session : listenerList) { session.onProtocolError(info, e); } }
@Override public void onTransportDisconnected(String info) { for (SdlSession session : listenerList) { session.onTransportDisconnected(info); } }
public void sendHeartbeat(SdlSession mySession) { if (_protocol != null && mySession != null) _protocol.SendHeartBeat(mySession.getSessionId()); }