แพ็กเกจอย่างเป็นทางการ · เฟรมเวิร์ก
เหตุการณ์เรียลไทม์จาก Hanami
ลงทะเบียน gem pusher เป็น provider ของ Hanami 2 ส่งเหตุการณ์ Hibira จาก action และ operation และลงนามการสมัครช่องใน action
pusherRubyGems ↗
วิธีที่เร็วที่สุด: ปลั๊กอิน Hibira กับพรอมต์เดียว
ติดตั้งปลั๊กอินในเอเจนต์เขียนโค้ด AI ของคุณแล้ววางพรอมต์ เอเจนต์จะลงชื่อเข้าใช้ สร้างแอปฟรีหากจำเป็น เขียนโค้ด และส่งอีเวนต์ทดสอบให้ GitHub ↗
ติดตั้งปลั๊กอิน
claude plugin marketplace add hibira-io/agent-plugin claude plugin install hibira@hibiraวางพรอมต์นี้
Add Hibira Hanami (pusher) to this project. Follow https://hibira.io/guides/hanami, adapted to how this project is already set up. If I have no Hibira app yet, create a Free one that allows http://localhost so I can test right away. Keep the app key and secret in environment variables, add placeholders to .env.example, and never commit real values or send the secret to a browser. When you are done, send a test event, show me it arriving, and list the files you changed.
อยากทำเองใช่ไหม ขั้นตอนด้านล่างมีดังนี้:
- provider ลงทะเบียนไคลเอนต์หนึ่งตัว และ action กับ operation รับไปใช้ผ่าน Deps
- action ลงนามช่องส่วนตัวและ presence สำหรับ pusher-js และ Laravel Echo
ลงชื่อเข้าใช้เพื่อดูโค้ดตัวอย่างเหล่านี้พร้อมโฮสต์คลัสเตอร์ของคุณเอง ลงชื่อเข้าใช้
ติดตั้ง
bundle add pusherตั้งค่า
# config/providers/hibira.rb Hanami.app.register_provider(:hibira) do prepare { require "pusher" } start do register "hibira", Pusher::Client.new( app_id: target["settings"].hibira_app_id, key: target["settings"].hibira_app_key, secret: target["settings"].hibira_app_secret, host: "ws.hibira.io", port: 443, use_tls: true ) end end # config/settings.rb: setting :hibira_app_id, setting :hibira_app_key, setting :hibira_app_secretใช้งาน
# app/actions/pusher/auth.rb (config/routes.rb: post "/pusher/auth", to: "pusher.auth") module Bookshelf module Actions module Pusher class Auth < Bookshelf::Action include Deps["hibira"] def handle(request, response) # check the signed-in user may join request.params[:channel_name] first response.format = :json response.body = hibira.authenticate(request.params[:channel_name], request.params[:socket_id]).to_json end end end end end # anywhere: hibira.trigger("orders", "order.shipped", { id: 1042 })
ก่อนเริ่ม
- ซีเคร็ตของแอปจะแสดงเพียงครั้งเดียว ตอนสร้างแอปหรือตอนหมุนเวียนซีเคร็ต เก็บไว้บนเซิร์ฟเวอร์เท่านั้น ห้ามใส่ในเบราว์เซอร์หรือไฟล์บิลด์ของเกม
- ในแพ็กเกจ Free ให้ใส่ทุก origin ที่หน้าเว็บโหลดมาใน Origin ที่อนุญาตของแอป (http://localhost:3000 ระหว่างพัฒนา แล้วตามด้วยโดเมนของคุณ) ส่วน "*" ต้องใช้แพ็กเกจแบบชำระเงิน
ใช้ app key จากแดชบอร์ดของคุณ ส่วน secret ให้เก็บไว้บนเซิร์ฟเวอร์เท่านั้น ช่อง อีเวนต์ และ endpoint การยืนยันสิทธิ์ทำงานเหมือนกับที่ใช้กับ Pusher ทุกประการ สร้างบัญชีฟรีของคุณ →