deepstream io (개발자를 위한 작동 방식)
실시간 서버는 데이터에 즉각적으로 반응하도록 설계되어 모든 사용자 상호 작용이나 시스템 이벤트에 즉각적으로 대응합니다. 지연을 유발하는 기존의 요청-응답 서버와 달리, 실시간 [서버는](https://en.wikipedia.org/wiki/Server_(computing) 기술과 프로토콜을 사용하여 지속적인 정보 교환과 즉각적인 업데이트를 보장합니다. 실시간 서버는 메시징 시스템, 온라인 게임, 금융 거래 플랫폼, 협업 도구 등 실시간 통신이 필요한 여러 애플리케이션에 필수적이기 때문입니다. 이 글에서는 오픈 실시간 서버인 DeepStream과 IronPDF 사용하여 PDF를 생성하는 방법을 알아보겠습니다.
deepstream.io 는 데이터 동기화 및 다대다 메시징을 위한 확장 가능한 실시간 서버입니다. 이 소프트웨어는 데이터를 손쉽게 처리하고 매우 낮은 지연 시간으로 여러 클라이언트를 동기화할 수 있으며 바이너리 데이터 전송을 지원합니다. deepstream.io는 다른 로드 밸런싱 및 로드 밸런싱 솔루션 뒤에 배치되도록 설계되었으며, 데이터를 효율적으로 동기화하고 리소스 파일을 최신 상태로 유지하는 방법을 제공합니다. 따라서 실시간으로 데이터를 업데이트하고 확장 가능한 서버 솔루션을 찾는 애플리케이션에 매우 적합합니다.

개발자는 deepstream.io를 구현함으로써 처음부터 시작할 필요 없이 실시간 업데이트, 협업 애플리케이션 및 대화형 환경을 손쉽게 만들 수 있습니다. 이 시스템은 높은 부하와 효율적인 확장을 위해 설계되었으므로, 동시 접속이 많은 애플리케이션에 가장 적합한 소프트웨어입니다. deepstream.io는 유연성이 뛰어나 여러 가지 방식으로 여러분의 스택에 완벽한 추가 요소가 될 수 있습니다. 이 플랫폼은 사용자가 실시간으로 반응형 웹 및 모바일 앱을 제작할 수 있도록 완벽한 솔루션을 제공합니다.
새로운 Node.js 디렉토리를 생성하려면 콘솔에 다음 명령어를 입력하세요.
mkdir deepstream-project
cd deepstream-project
npm init -ymkdir deepstream-project
cd deepstream-project
npm init -ydeepstream.io 패키지를 설치하세요
우선 deepstream.io를 설치해야 합니다. NPM을 사용하여 설치하거나 공식 웹사이트에서 바이너리 파일을 다운로드할 수 있습니다.
npm install @deepstream/servernpm install @deepstream/serverdeepstream.io의 기본 설정
const { Deepstream } = require('@deepstream/server');
// Create a new Deepstream server instance
const server = new Deepstream({});
// Start the server to listen for client connections
server.start();const { Deepstream } = require('@deepstream/server');
// Create a new Deepstream server instance
const server = new Deepstream({});
// Start the server to listen for client connections
server.start();위 코드 스니펫은 Node.js에서 @deepstream/server 패키지를 사용하여 deepstream.io 서버를 설정하고 시작하는 방법을 보여줍니다. 먼저 패키지에서 Deepstream 클래스를 가져온 다음 새 인스턴스를 생성합니다. server.start()를 호출하면 서버가 시작되고 실시간 데이터 바인딩, 메시징, 또는 프레즌스 백엔드 서비스를 처리하기 위해 들어오는 연결을 받을 준비가 됩니다.
딥스트림과 클라이언트 연결하기
const { DeepstreamClient } = require('@deepstream/client');
// Connect to a local deepstream server
const client = new DeepstreamClient('127.0.0.1:6020');
// Log in to the server without credentials (suitable for servers without authentication)
client.login(null);const { DeepstreamClient } = require('@deepstream/client');
// Connect to a local deepstream server
const client = new DeepstreamClient('127.0.0.1:6020');
// Log in to the server without credentials (suitable for servers without authentication)
client.login(null);위 코드는 @deepstream/client 라이브러리를 사용하여 deepstream에 연결하는 방법을 보여줍니다. 이 스크립트는 DeepstreamClient 클래스를 가져와 인스턴스를 생성하며, 로컬 IP 주소 127.0.0.1의 포트 6020에서 실행 중인 deepstream 서버에 연결합니다. 인증 없이 로그인하며, 이는 서버가 인증을 사용하지 않거나 테스트 케이스에 사용될 경우 충분합니다. 이 설정은 실시간 데이터 동기화 및 통신이 가능한 클라이언트를 초기화합니다.
서버 노드와의 연결이 설정되면 아래와 유사한 메시지가 서버 콘솔에 나타납니다.

deepstream.io에서 리스너 사용하기
다음은 DeepStream의 핵심 개념 중 하나인 리스너를 생성하는 데 사용할 수 있는 샘플 코드입니다.
const { DeepstreamClient } = require("@deepstream/client");
// Connect to the Deepstream server
const client = new DeepstreamClient("127.0.0.1:6020");
// Log in to the server
client.login(null, (success, clientData) => {
if (success) {
const event = client.event;
// Publish a custom event
event.publish("custom-event", { message: "Hello, Deepstream!" });
}
});const { DeepstreamClient } = require("@deepstream/client");
// Connect to the Deepstream server
const client = new DeepstreamClient("127.0.0.1:6020");
// Log in to the server
client.login(null, (success, clientData) => {
if (success) {
const event = client.event;
// Publish a custom event
event.publish("custom-event", { message: "Hello, Deepstream!" });
}
});위 코드에서 클라이언트는 @deepstream/client 라이브러리를 사용하여 127.0.0.1:6020에 호스팅된 deepstream 서버에 로그인합니다. 인증에 성공하면, "custom-event"라는 이름의 사용자 정의 이벤트를 { message: "Hello, Deepstream!" } 페이로드와 함께 게시합니다.
IronPDF 소개합니다
IronPDF 매우 강력한 Node.js 패키지로, PDF 문서를 생성, 편집, 변환 및 수정하는 데 사용할 수 있습니다. 이는 PDF 관련 프로그래밍 기반 프로세스의 대부분에서 사용되는 도구이며, 기존 PDF 수정 및 HTML을 PDF로 변환하는 등의 백엔드 프로세스에도 사용됩니다. PDF를 동적으로 생성하고 처리해야 하는 애플리케이션에서 IronPDF 매우 유용합니다. 이 프로그램은 사용자 친화적이고 유연한 방식으로 고품질 PDF 문서를 생성할 수 있도록 해줍니다.

IronPDF 패키지를 설치하세요
npm을 사용하여 Node.js IronPDF 기능을 활성화하는 패키지를 다운로드하고 설치하세요.
npm install @ironsoftware/ironpdfnpm install @ironsoftware/ironpdfPDF 생성 기능
IronPDF 사용하여 PDF를 생성하는 함수를 만드세요:
const IronPdf = require('@ironsoftware/ironpdf');
const { PdfDocument } = IronPdf;
// Set IronPDF configuration, replacing 'YOUR_LICENSE_KEY' with your actual license key
const config = IronPdf.IronPdfGlobalConfig;
config.setConfig({ licenseKey: 'YOUR_LICENSE_KEY' });
async function generatePDF(title, content) {
try {
// Generate PDF from HTML content
const pdf = await PdfDocument.fromHtml(`<html><body><h1>${title}</h1><p>${content}</p></body></html>`);
return await pdf.saveAsBuffer();
} catch (error) {
console.error('Error generating PDF:', error);
throw error;
}
}
module.exports = generatePDF;const IronPdf = require('@ironsoftware/ironpdf');
const { PdfDocument } = IronPdf;
// Set IronPDF configuration, replacing 'YOUR_LICENSE_KEY' with your actual license key
const config = IronPdf.IronPdfGlobalConfig;
config.setConfig({ licenseKey: 'YOUR_LICENSE_KEY' });
async function generatePDF(title, content) {
try {
// Generate PDF from HTML content
const pdf = await PdfDocument.fromHtml(`<html><body><h1>${title}</h1><p>${content}</p></body></html>`);
return await pdf.saveAsBuffer();
} catch (error) {
console.error('Error generating PDF:', error);
throw error;
}
}
module.exports = generatePDF;Deepstream 클라이언트 설정
실시간으로 데이터를 수신하고 해당 데이터를 기반으로 PDF를 생성하는 JavaScript 스크립트를 작성하세요.
const { DeepstreamClient } = require('@deepstream/client');
const generatePDF = require('./generatePdf'); // Path to your PDF generation function
// Connect to the Deepstream server
const client = new DeepstreamClient('127.0.0.1:6020');
// Log in to the server
client.login(null, async (success) => {
if (success) {
console.log('Deepstream connected successfully');
// Listen for a custom event to trigger PDF generation
const event = client.event;
event.subscribe('generate-pdf', async (data) => {
const { title, content } = data;
if (!title || !content) {
console.error('Missing title or content for PDF generation');
return;
}
try {
// Generate the PDF
const pdfBuffer = await generatePDF(title, content);
// Handle the PDF buffer (e.g., save to file, send over network)
console.log('PDF generated successfully');
// Example: Save PDF to a file (optional)
const fs = require('fs');
fs.writeFileSync('generated.pdf', pdfBuffer);
} catch (error) {
console.error('Error generating PDF:', error);
}
});
} else {
console.error('Failed to connect to Deepstream');
}
});const { DeepstreamClient } = require('@deepstream/client');
const generatePDF = require('./generatePdf'); // Path to your PDF generation function
// Connect to the Deepstream server
const client = new DeepstreamClient('127.0.0.1:6020');
// Log in to the server
client.login(null, async (success) => {
if (success) {
console.log('Deepstream connected successfully');
// Listen for a custom event to trigger PDF generation
const event = client.event;
event.subscribe('generate-pdf', async (data) => {
const { title, content } = data;
if (!title || !content) {
console.error('Missing title or content for PDF generation');
return;
}
try {
// Generate the PDF
const pdfBuffer = await generatePDF(title, content);
// Handle the PDF buffer (e.g., save to file, send over network)
console.log('PDF generated successfully');
// Example: Save PDF to a file (optional)
const fs = require('fs');
fs.writeFileSync('generated.pdf', pdfBuffer);
} catch (error) {
console.error('Error generating PDF:', error);
}
});
} else {
console.error('Failed to connect to Deepstream');
}
});PDF 생성을 트리거하는 게시 이벤트
이벤트를 게시하여 다른 JavaScript 파일이나 애플리케이션의 일부에서 PDF 생성을 트리거할 수 있습니다.
const { DeepstreamClient } = require('@deepstream/client');
// Connect to the Deepstream server
const client = new DeepstreamClient('127.0.0.1:6020');
// Log in to the server
client.login(null, () => {
const event = client.event;
// Publish a custom event with title and content
event.publish('generate-pdf', {
title: 'Sample PDF Title',
content: 'This is the content of the PDF document.'
});
});const { DeepstreamClient } = require('@deepstream/client');
// Connect to the Deepstream server
const client = new DeepstreamClient('127.0.0.1:6020');
// Log in to the server
client.login(null, () => {
const event = client.event;
// Publish a custom event with title and content
event.publish('generate-pdf', {
title: 'Sample PDF Title',
content: 'This is the content of the PDF document.'
});
});Deepstream.io는 실시간 이벤트를 수신하여 PDF 생성을 트리거하는 방식으로 구현됩니다. generatePDF 함수는 IronPDF를 사용하여 Deepstream.io 이벤트의 데이터를 기반으로 PDF 문서를 생성합니다. DeepstreamClient는 이러한 이벤트에 구독하여 관련 이벤트가 게시되면 PDF 생성 함수를 호출합니다. 이러한 통합을 통해 이벤트 발생, 요청 또는 데이터 변경에 따라 실시간으로 PDF를 동적으로 생성할 수 있습니다.

라이선스
워터마크 없이 코드가 컴파일되고 작동하려면 라이선스 키가 필요합니다. 평가판 라이선스를 원하시는 개발자분들은 여기에서 등록하실 수 있습니다. 발급받기 위해 신용카드를 제시할 필요는 없습니다. 무료 체험판에 가입하려면 이메일 주소만 입력하면 됩니다.
결론
deepstream.io와 IronPDF 를 결합하면 가장 강력한 실시간 데이터 처리 및 동적 문서 생성 솔루션 중 하나를 구현할 수 있습니다. deepstream.io는 변경 사항을 동기화하고 모든 이벤트를 실시간으로 기록하므로 데이터 변경 사항에 즉시 대응할 수 있습니다. IronPDF 전문가 수준의 문서를 신속하게 생성할 수 있는 강력한 기능을 제공합니다. 이 통합을 통해 애플리케이션은 실시간 데이터 변경 시뿐만 아니라 사용자가 애플리케이션과 상호 작용할 때마다 자동으로 PDF 문서를 생성하고 처리할 수 있습니다.
보고서 생성, 송장 발행 또는 기타 모든 유형의 문서 작성에 있어 deepstream.io와 IronPDF 의 통합은 워크플로우를 간소화하고 반응형 문서를 생성하며 실시간 정보를 통해 애플리케이션을 효율적이고 최신 상태로 유지할 수 있도록 지원합니다. 이 조합은 실시간 문서 생성 및 관리 지원이 필요한 민첩하고 데이터 기반이며 반응성이 뛰어난 애플리케이션에 가장 적합합니다.
Iron Software 에서 제공하는 라이브러리를 사용하면 Windows, Android, MAC, Linux 등 다양한 운영 체제, 브라우저 및 플랫폼용 프로그램을 빠르고 쉽게 만들 수 있습니다.










