handleResponse method

void handleResponse(
  1. WSMessage message
)

Implementation

void handleResponse(WSMessage message) {
  // don't print every clock update
  if (message.data['action'] != 'clockCurrentTimes') {
    print('Remote Message Handler...');
    print(message.toJsonString());
  }

  // we received data, so mark the connection as connected
  if (!connected) status = ProConnectionStatus.connected;

  // process data for this class instance
  var data = message.data;
  var action = data['action'];
  switch (action) {
    case "authenticate":
      handleAuthenticate(data);
      break;

    // this populates the library with a list of items containing path and name
    case "libraryRequest":
      handleLibraryRequest(data);
      break;

    // this populates the playlist with playlist items
    case "playlistRequestAll":
      handlePlaylistRequestAll(data);
      break;

    // is also the response for presentationRequest
    case "presentationCurrent":
      handlePresentationCurrent(data);
      break;

    case "presentationSlideIndex":
      handlePresentationSlideIndex(data);
      break;

    // returned from triggerSlideIndex
    case "presentationTriggerIndex":
      handlePresentationTriggerIndex(data);
      break;

    case 'clockRequest':
      handleClockRequest(data);
      break;

    case 'clockCurrentTimes':
      handleClockCurrentTimes(data);
      break;

    case 'clockStartStop':
      handleClockStartStop(data);
      break;

    case 'messageRequest':
      handleMessageRequest(data);
      break;

    case 'messageSend':
      handleMessageSend(data);
      break;

    case 'messageHide':
      handleMessageHide(data);
      break;

    case 'audioRequest':
      handleAudioRequest(data);
      break;

    case 'audioCurrentSong':
    case 'audioTriggered':
      handleAudioCurrentSong(data);
      break;

    case 'audioPlayPause':
      handleAudioPlayPause(data);
      break;
    case 'clearText':
    case 'clearProps':
    case 'clearVideo':
    case 'clearAnnouncements':
    case 'clearMessages':
      break;
    default:
      print('$action is not supported yet');
  }

  completeAction(action);
  notify();
  emit(action);
}