แพ็กเกจอย่างเป็นทางการ · เฟรมเวิร์ก

เรียลไทม์ ห้องรอ และแชตสำหรับ Ktor

ปลั๊กอิน Ktor 3 ที่เขียนด้วย Kotlin: เส้นทางการอนุญาตช่องและ webhook สำหรับ pusher-js และ Laravel Echo, ปลั๊กอินห้องรอระดับเส้นทาง และการใช้เหตุการณ์ Chat API และ Approvals ผ่าน coroutine

เวอร์ชันบน Maven Centralสัญญาอนุญาต

วิธีที่เร็วที่สุด: ปลั๊กอิน Hibira กับพรอมต์เดียว

ติดตั้งปลั๊กอินในเอเจนต์เขียนโค้ด AI ของคุณแล้ววางพรอมต์ เอเจนต์จะลงชื่อเข้าใช้ สร้างแอปฟรีหากจำเป็น เขียนโค้ด และส่งอีเวนต์ทดสอบให้ GitHub ↗

  1. ติดตั้งปลั๊กอิน

    claude plugin marketplace add hibira-io/agent-plugin
    claude plugin install hibira@hibira
  2. วางพรอมต์นี้

    Add Hibira Ktor (io.hibira:hibira-ktor) to this project.
    Follow https://hibira.io/guides/ktor, 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.
  • hibiraChannelAuth, hibiraUserAuth และ hibiraWebhooks เพิ่มเส้นทางที่ pusher-js และ Laravel Echo ต้องการ
  • install(HibiraWaitingRoom) บนเส้นทาง จะส่งผู้เยี่ยมชมที่ไม่มี pass ไปยังหน้ารอที่โฮสต์ไว้
  • ฟังก์ชัน suspend สำหรับเหตุการณ์ Chat API และ Approvals รวมถึงผู้เยี่ยมชมที่ยืนยันตัวตนใน Live Chat

ลงชื่อเข้าใช้เพื่อดูโค้ดตัวอย่างเหล่านี้พร้อมโฮสต์คลัสเตอร์ของคุณเอง ลงชื่อเข้าใช้

  1. ติดตั้ง

    implementation("io.hibira:hibira-ktor:0.1.0")
  2. ตั้งค่า

    HIBIRA_APP_ID=YOUR_APP_ID
    HIBIRA_KEY=YOUR_APP_KEY
    HIBIRA_SECRET=YOUR_APP_SECRET
    HIBIRA_HOST=ws.hibira.io
  3. ใช้งาน

    fun Application.module() {
        install(HibiraPlugin)
        routing {
            hibiraChannelAuth { channel ->
                val user = principal<UserIdPrincipal>() ?: return@hibiraChannelAuth deny()
                if (channel.startsWith("presence-")) presence(user.name) else allow()
            }
            route("/drop") {
                install(HibiraWaitingRoom) { room = "presale" }
                get { call.respondText("You are number ${call.waitingRoomPass!!.number()}") }
            }
        }
    }

ก่อนเริ่ม

  • ซีเคร็ตของแอปจะแสดงเพียงครั้งเดียว ตอนสร้างแอปหรือตอนหมุนเวียนซีเคร็ต เก็บไว้บนเซิร์ฟเวอร์เท่านั้น ห้ามใส่ในเบราว์เซอร์หรือไฟล์บิลด์ของเกม
  • ในแพ็กเกจ Free ให้ใส่ทุก origin ที่หน้าเว็บโหลดมาใน Origin ที่อนุญาตของแอป (http://localhost:3000 ระหว่างพัฒนา แล้วตามด้วยโดเมนของคุณ) ส่วน "*" ต้องใช้แพ็กเกจแบบชำระเงิน

ใช้ app key จากแดชบอร์ดของคุณ ส่วน secret ให้เก็บไว้บนเซิร์ฟเวอร์เท่านั้น ช่อง อีเวนต์ และ endpoint การยืนยันสิทธิ์ทำงานเหมือนกับที่ใช้กับ Pusher ทุกประการ สร้างบัญชีฟรีของคุณ →