← 返回
未分类 中文

Pilot Stream Data

Real-time NDJSON data streaming over persistent Pilot Protocol connections. Use this skill when: 1. You need to stream structured data in real-time between a...
通过持久化的 Pilot 协议连接实现实时 NDJSON 数据流。在以下情况下使用此技能:1. 需要在 … 之间实时流式传输结构化数据。
teoslayer teoslayer 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 402
下载
💾 0
安装
1
版本
#latest

概述

pilot-stream-data

Real-time structured data streaming using NDJSON format over Pilot Protocol's persistent connections with backpressure handling.

Commands

Start stream server:

pilotctl --json listen 1002 > /tmp/pilot-stream.log &

Stream NDJSON data:

DEST="1:0001.AAAA.BBBB"
while true; do
  MSG="{\"timestamp\":$(date +%s),\"temp\":$(echo "scale=2; 20 + $RANDOM % 10" | bc),\"humidity\":50}"
  pilotctl --json send "$DEST" 1002 --data "$MSG"
  sleep 1
done

Receive and process stream:

pilotctl --json listen 1002 | while read -r line; do
  TIMESTAMP=$(echo "$line" | jq -r '.timestamp')
  VALUE=$(echo "$line" | jq -r '.value')
  echo "[$TIMESTAMP] Value: $VALUE"
done

Subscribe to stream topic:

pilotctl --json subscribe "$DEST" data-stream | while read -r line; do
  echo "Data: $(echo $line | jq -r '.value')"
done

Workflow Example

#!/bin/bash
# Real-time sensor data streaming

STREAM_PORT=1002
DEST="1:0001.AAAA.BBBB"

# Producer: stream sensor data
produce_stream() {
  echo "Starting stream producer"

  # Send metadata header
  pilotctl --json send "$DEST" "$STREAM_PORT" \
    --data "{\"type\":\"stream_start\",\"schema\":\"temp_humidity_v1\"}"

  # Stream data
  counter=0
  while true; do
    timestamp=$(date +%s)
    temp=$(echo "scale=2; 20 + ($counter % 10)" | bc)
    humidity=$(echo "scale=2; 50 + ($counter % 20)" | bc)

    pilotctl --json send "$DEST" "$STREAM_PORT" \
      --data "{\"type\":\"data\",\"timestamp\":$timestamp,\"temp\":$temp,\"humidity\":$humidity,\"seq\":$counter}"

    counter=$((counter + 1))
    sleep 1
  done
}

# Consumer: receive and process
consume_stream() {
  pilotctl --json listen "$STREAM_PORT" | while read -r line; do
    type=$(echo "$line" | jq -r '.type')

    if [ "$type" = "data" ]; then
      temp=$(echo "$line" | jq -r '.temp')
      echo "Temperature: ${temp}°C"
    fi
  done
}

produce_stream

Dependencies

Requires pilot-protocol skill, running daemon, jq, bc, and optional gzip for compression.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-03 09:10 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 198 📥 68,235
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 686 📥 331,092
it-ops-security

Pilot Priority Queue

teoslayer
基于Pilot协议网络的优先级消息传递,支持紧急程度级别。适用场景:1. 需要处理带优先级的紧急消息...
★ 0 📥 542