TsgcWSAPIServer_WebPush › 메서드 › BroadcastNotification
내부 Subscriptions 목록에 현재 보유된 모든 구독에 동일한 알림을 보냅니다.
procedure BroadcastNotification(const aMessage : TsgcWebPushMessage);
| Name | Type | 설명 |
|---|---|---|
aMessage | const TsgcWebPushMessage | AsJSON을 통해 한 번 직렬화되어 각 구독에 재사용되는 구조화된 알림(Title/Body/Icon/Url)입니다. |
잠금 하에 스레드 안전 Subscriptions 목록을 반복하고 각 항목에 대해 SendNotification을 호출합니다. 전송이 실패하면 OnWebPushSendNotificationException이 발생하고, Remove가 True(기본값)로 반환되면 구독이 목록에서 자동으로 삭제됩니다. 푸시 서비스의 404/410 응답을 정리하는 데 이상적입니다.
var
oMessage: TsgcWebPushMessage;
begin
oMessage := TsgcWebPushMessage.Create;
try
oMessage.Title := 'eSeGeCe Notification';
oMessage.Body := 'New version released!!!';
oMessage.Icon := 'https://www.esegece.com/images/esegece_logo_small.png';
oMessage.Url := 'https://www.esegece.com';
sgcWSAPIServer_WebPush1.BroadcastNotification(oMessage);
finally
oMessage.Free;
end;
end;
procedure BroadcastNotification(const aMessage: string);
| Name | Type | 설명 |
|---|---|---|
aMessage | const string | 구독별 암호화 후 모든 구독자에게 그대로 전달되는 원시 페이로드(일반적으로 JSON). |
브로드캐스트 페이로드가 이미 직렬화된 경우의 편의 오버로드. 영속성을 직접 관리하는 경우 Subscriptions.AddSubscription/Subscriptions.RemoveSubscription을 통해 수동으로 구독을 추가하거나 제거할 수 있습니다.
sgcWSAPIServer_WebPush1.BroadcastNotification(
'{"title":"Heads up","body":"Server restarting in 5 min"}');