Skip to content

Plugin Unicast API

플러그인 간 1:1 메시지 통신을 위한 인터페이스를 제공해요. 특정 플러그인을 대상으로 메시지를 전송하거나, 다른 플러그인으로부터 메시지를 수신할 수 있어요.

Methods

send

지정한 플러그인으로 메시지를 전송해요.

ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';

posPluginSdk.pluginUnicast.send(message, to);
파라미터타입설명
messageT전송할 메시지
tostring메시지를 수신할 플러그인 이름

플러그인 정보가 아직 초기화되지 않은 시점에 send를 호출해도 내부 버퍼에 저장되어, 초기화 완료 후 자동으로 전송돼요.

listen

다른 플러그인으로부터 메시지를 수신할 콜백을 등록해요.

ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';

posPluginSdk.pluginUnicast.listen('message', (message, from) => {
  console.log('발신 플러그인:', from);
  console.log('수신 메시지:', message);
});
파라미터타입설명
event'message'이벤트 종류 (현재 'message'만 지원)
callback(message: T, from: string) => void메시지 수신 시 호출될 콜백

사용 예시

플러그인 A → 플러그인 B 메시지 전송

플러그인 A (송신)

ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';

posPluginSdk.pluginUnicast.send({ orderId: '12345', status: 'ready' }, 'plugin-b');

플러그인 B (수신)

ts
import { posPluginSdk } from '@tossplace/pos-plugin-sdk';

posPluginSdk.pluginUnicast.listen('message', (message, from) => {
  console.log(`${from}로부터 메시지 수신:`, message);
  // { orderId: '12345', status: 'ready' }
});