Show HN:Lightspeed,Laravel 的双向 WebSockets(附带小行星演示)
5 分•作者: jv22222•大约 13 小时前
各位 HN 的朋友们!
Laravel 支持 WebSocket 已经很多年了,但总的来说,它是一种单向推送架构(即 HTTP 输入,WebSocket 输出)。
Lightspeed 类似于 Node.js,它是一个单一服务器,集 HTTP 和 WebSocket 服务于一体。身份验证仅需 0.03 毫秒(一次 Redis 读取,无需数据库)。您的 Laravel 处理程序将在完整的容器内运行,响应会通过同一个 WebSocket 返回。我认为这对于创造与 Laravel 交互的新方式来说会非常棒。
总之,我搭建了一个实时演示来展示它的实际效果。基本上是 slither.io 和 Asteroids 的结合体。
游戏地址:
https://innerloop.works/lightspeed
代码仓库:
https://github.com/innerloop-dev/lightspeed
注意:这是 0.1.0 版本,API 在 1.0 版本之前可能会有变动。它需要 Swoole 扩展和 Redis。遵循 MIT 协议。
查看原文
Hi HN!<p>Laravel has worked with websockets for years but generally speaking it's a one way push architecture (i.e. http in, sockets out).<p>Lightspeed is kind of like node in that it's a single server that serves your http and your websockets all under one roof. Auth runs in 0.03ms (a Redis read, no database). Your Laravel handler runs inside the full container and the reply comes back down the same socket. I think this could be really cool for creating new ways of working with Laravel.<p>Anyway, I put together a live demo to show it in action. Basically a cross between slither.io and Asteroids.<p>Game here:<p><a href="https://innerloop.works/lightspeed" rel="nofollow">https://innerloop.works/lightspeed</a><p>Repo here:<p><a href="https://github.com/innerloop-dev/lightspeed" rel="nofollow">https://github.com/innerloop-dev/lightspeed</a><p>Note: This is 0.1.0, the API may change before 1.0. It needs the Swoole extension and Redis. MIT.