Firefly v4.7.0 is released

11 Jan 2018, Alvin Qiu

Firefly v4.7.0 adds new WebSocket DSL APIs, improves the HTTP2 codec’s performance, and fixes some bugs. The new WebSocket DSL APIs like this:

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."));
}

The Kotlin version:

fun main(args: Array<String>) {
    val server = firefly.createWebSocketServer()
    server.webSocket("/helloWebSocket")
          .onConnect { conn -> conn.sendText("OK.") }
          .onText { text, conn -> println("The server received: " + text) }
          .listen("localhost", 8080)

    val client = firefly.createWebSocketClient()
    client.webSocket("ws://localhost:8080/helloWebSocket")
          .onText { text, conn -> println("The client received: " + text) }
          .connect()
          .thenAccept { conn -> conn.sendText("Hello server.") }
}

More detailed information, please refer to the WebSocket server and client document.

Update log:

  1. Add new WebSocket DSL APIs (include Java and Kotlin).
  2. Optimize the HTTP2 codec’s performance.
  3. Fix the HTTP1 upgrades to HTTP2 or WebSocket failure.
  4. Fix the session can’t close correctly when the many threads call the close and write method concurrently.