parseNotificationFrame
Parse an inbound socket frame into a RawPositionNotification, or null when the frame is not a notification (control/ack frames, malformed JSON, or a missing payload — all skipped silently by the caller).
For enigma, the notification is unwrapped from its { data, address } envelope and the top-level address is hoisted onto the frame. For rasa, the frame arrives bare and is kept wire-faithful (numeric zero-sentinels included — normalizeNotification reconciles them); frames without a quote_id / temp_quote_id (acks, keepalives) return null. A literal protocol argument narrows the return to that protocol’s variant.
import { parseNotificationFrame } from "@symmio/trading-core";
const raw = parseNotificationFrame(event.data, "enigma");
if (raw) {
// a real notification frame
}Parameters
dataunknownrequiredThe raw event.data — a JSON string, or an already-parsed object.
protocolSymmioNotificationsProtocolrequiredThe endpoint’s wire protocol.
Returns
The parsed raw frame, or null for control/ack frames, malformed JSON, or a missing payload.
Related
- normalizeNotification — turns this raw frame into a
Notification. - buildSubscribeMessage — the outbound counterpart sent on connect.