发布于 2018-01-16 00:51:19 | 135 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Firefly 分布式游戏服务器端框架

Firefly是免费、开源、稳定、快速扩展、能 “热更新”的分布式游戏服务器端框架,采用Python编写,基于Twisted框架开发。它包括了开发框架和数据库缓存服务等各种游戏服务器基础服务,节省大量游戏开发的工作时间,真正做到让使用者把精力放在游戏玩法逻辑上。用它可以搭建自定义的分布式架构,只需要修改相应的配置文件即可。


Firefly 4.7.0 增加了新的 WebSocket APIs,改进了 HTTP 2 编解码器的性能,并修复了一些 bug。

新的 WebSocket APIs 例如:

public static void main(String[] args) {      SimpleWebSocketServer server = $.createWebSocketServer();      server.webSocket("/helloWebSocket")            .onConnect(conn -> conn.sendText("OK."))            .onText((text, conn) -> System.out.println("The server received: " + text))            .listen("localhost", 8080);        SimpleWebSocketClient client = $.createWebSocketClient();      client.webSocket("ws://localhost:8080/helloWebSocket")            .onText((text, conn) -> System.out.println("The client received: " + text))            .connect()            .thenAccept(conn -> conn.sendText("Hello server."));  }

也增加了 Kotlin DSL 版 APIs,例如:

fun main(args: Array<String>) {      val scheduler = Schedulers.createScheduler()      val p = Paths.get(HttpServer::class.java.getResource("/").toURI())        HttpServer {          router {              httpMethod = HttpMethod.GET              paths = listOf("/favicon.ico", "/static/*")              handler(StaticFileHandler(p.toAbsolutePath().toString()))          }            router {              httpMethod = HttpMethod.GET              path = "/"              asyncHandler { renderTemplate("template/websocket/index.mustache") }          }            webSocket("/helloWebSocket") {              onConnect {                  val future = scheduler.scheduleAtFixedRate(                          { it.sendText("Current time: " + Date()) },                          0, 1, TimeUnit.SECONDS)                  it.onClose { future.cancel() }              }                onText { text, _ ->                  println("Server received: " + text)              }          }      }.listen("localhost", 8080)  }

这个例子中 WebSocket 服务和 HTTP 服务公用一个端口。

更多详情请参考 WebSocket 文档

更新日志:

  1. 增加新的 WebSocket DSL APIs。

  2. 优化 HTTP 2 编解码性能。

  3. 修复了 HTTP1 Upgrade 机制时效的问题。

  4. 修复了 TCP Session 在并发调用 close 和 write 方法的情况下有可能无法正确关闭的问题。



历史版本 :
Firefly 4.7.0 正式版发布,增加新的 WebSocket APIs
Firefly 4.6.0 正式版发布,新增OpenSSL引擎支持
Firefly 4.5.0 正式版发布
Firefly 4.0.21 发布,Java 的 Web 框架
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务