var FermiWebSocketBridge = {};

// call from modal_collabo_profile.html
FermiWebSocketBridge.requestHostChange = function (loginID) {
  console.log(
    "peacekim:: FermiWebSocketBridge.requestHostChange loginID: " + loginID
  );
  fw.sendToMsg("others", "HOST_CHANGE_REQUEST", {
    loginId: loginID,
  });
};

FermiWebSocketBridge.shareFileHost = function (collaborationType) {
  console.log(
    "peacekim:: FermiWebSocketBridge.shareFileHost collaborationType: " +
      collaborationType
  );
  fw.sendToMsg("others", "SHARE_FILE_HOST", {
    collaborationType: collaborationType,
  });
};

FermiWebSocketBridge.hostChangeResponse = function () {
  console.log("peacekim:: FermiWebSocketBridge.hostChangeResponse");
  fw.sendToMsg("others", "HOST_CHANGE_RESPONSE", {
    isAndroid: deviceInfo.isAndroid(),
    isAble: deviceInfo.androidVersion >= ANDROID_SDK_VERSION.O,
    loginId: globalUserInfo.loginId,
  });
};

// PIP_END_REQUEST
FermiWebSocketBridge.pipEndRequest = function (loginID) {
  console.log(
    "peacekim:: FermiWebSocketBridge.pipEndRequest loginID: " + loginID
  );
  fw.sendToMsg("others", "PIP_END_REQUEST", {
    loginId: loginID,
  });
};

// HOST_REQUEST_REJECT
FermiWebSocketBridge.hostRequestReject = function (hostID) {
  console.log(
    "peacekim:: FermiWebSocketBridge.hostRequestReject hostID: " + hostID
  );
  fw.sendToMsg("others", "HOST_REQUEST_REJECT", {
    hostId: hostID,
  });
};

// HOST_REQUEST_DONE
FermiWebSocketBridge.hostRequestDone = function (hostID) {
  console.log(
    "peacekim:: FermiWebSocketBridge.hostRequestDone hostID: " + hostID
  );
  fw.sendToMsg("others", "HOST_REQUEST_DONE", {
    hostId: hostID,
  });
};

// GET_COLLABORATION_TYPE_RESPONSE
FermiWebSocketBridge.getCollaborationTypeResponse = function (loginID) {
  
  if (typeof meetingID == undefined) {
    var meetingID = 0;
  }

  console.log(
    "peacekim:: FermiWebSocketBridge.getCollaborationTypeResponse hostID: " +
      loginID +
      ", meetingID: " +
      meetingID
  );
  
  fw.sendToMsg("others", "GET_COLLABORATION_TYPE_RESPONSE", {
    loginId: loginID,
    collaborationType: globalUserInfo.collaborationType,
    newMeetingId: meetingID,
  });
};

// GET_COLLABORATION_TYPE
FermiWebSocketBridge.getCollaborationType = function () {
  console.log(
    "peacekim:: FermiWebSocketBridge.getCollaborationType globalUserInfo.loginId: " +
      globalUserInfo.loginId
  );
  fw.sendToMsg("others", "GET_COLLABORATION_TYPE", {
    loginId: globalUserInfo.loginId,
  });
};

// CAPTURE_REQUEST
FermiWebSocketBridge.captureRequest = function () {
  console.log(
    "peacekim:: FermiWebSocketBridge.captureRequest globalUserInfo.loginId: " +
      globalUserInfo.loginId
  );

  fw.sendToMsg("others", "CAPTURE_REQUEST", {
    name: globalUserInfo.loginId,
  });
};

// CHANGE_COLLABORATION
FermiWebSocketBridge.changeCollaboration = function (
  collaborationType,
  newMeetingID
) {
  console.log(
    "peacekim:: FermiWebSocketBridge.changeCollaboration collaborationType: " +
      collaborationType +
      ", newMeetingID: " +
      newMeetingID
  );
  fw.sendToMsg("others", "CHANGE_COLLABORATION", {
    collaborationType: collaborationType,
    newMeetingId: newMeetingID,
  });
};

// CHANGE_HOST_APPLY
FermiWebSocketBridge.changeHostApply = function () {
  console.log(
    "peacekim:: FermiWebSocketBridge.changeHostApply globalUserInfo.loginId: " +
      globalUserInfo.loginId
  );
  fw.sendToMsg("others", "CHANGE_HOST_APPLY", {
    hostId: globalUserInfo.loginId,
  });
};

FermiWebSocketBridge.hostUpdated = function () {
  fw.sendToMsg("others", "HOST_UPDATED", {});
};
