//------------------------------------------------------------------------------
void MobiCoreDriverDaemon::processCloseSession(
    Connection  *connection
) {
	do
	{
		// Read entire command data
		mcDrvCmdCloseSessionPayload_t  cmdCloseSessionPayload;
		uint32_t rlen = connection->readData(
							&cmdCloseSessionPayload,
							sizeof(cmdCloseSessionPayload));
		if (rlen != sizeof(cmdCloseSessionPayload))
		{
			LOG_E("processCloseSession(): CloseSessionPayload length error: %d",rlen);
			writeResult(connection, MC_DRV_RSP_PAYLOAD_LENGTH_ERROR);
			break;
		}

		// Device required
		MobiCoreDevice *device = (MobiCoreDevice *) (connection->connectionData);
		if (NULL == device)
		{
			LOG_E("processCloseSession(): device is NULL");
			writeResult(connection, MC_DRV_RSP_DEVICE_NOT_OPENED);
			break;
		}

		device->closeSession(
					connection,
					cmdCloseSessionPayload.sessionId);

		// there is no payload
		writeResult(connection, MC_DRV_RSP_OK);

	} while (false);
}
//------------------------------------------------------------------------------
void MobiCoreDriverDaemon::processCloseSession(Connection *connection)
{
    MC_DRV_CMD_CLOSE_SESSION_struct cmdCloseSession;
    RECV_PAYLOAD_FROM_CLIENT(connection, &cmdCloseSession)

    // Device required
    MobiCoreDevice *device = (MobiCoreDevice *) (connection->connectionData);
    CHECK_DEVICE(device, connection);

    mcResult_t ret = device->closeSession(connection, cmdCloseSession.sessionId);

    // there is no payload
    writeResult(connection, ret);
}