Skip to content

從 0.14.x 版本遷移至 0.14.18 版本

0.14.18 版本引入了一些軟棄用,以及有關 MongooseDriver 的重大變更.

MongooseDriver 現在應該從 @colyseus/mongoose-driver 匯入

// Replace this
import { MongooseDriver } from "colyseus/lib/matchmaker/drivers/MongooseDriver"

// With this
import { MongooseDriver } from "@colyseus/mongoose-driver";
// Replace this
const MongooseDriver = require("colyseus/lib/matchmaker/drivers/MongooseDriver").MongooseDriver;

// With this
const MongooseDriver = require("@colyseus/mongoose-driver").MongooseDriver;

為 0.15 版本的傳輸抽象做準備

server, pingInterval, pingMaxRetriesverifyClient 選項正在被軟性棄用. 這些選項現在是預設 WebSocketTransport 實現中的一部分.

棄用警告: 'pingInterval', 'pingMaxRetries', 'server' 和 'verifyClient' 伺服器選項將會在 0.15 版本永久從 WebSocketTransport 中移除

現在不需要采取立即行動!

這是一次軟棄用 點此閱讀關於自定義傳輸選項的更多內容.

// Replace this
import { Server } from "colyseus";
const gameServer = new Server({
    server: http.createServer(app),
    pingInterval: 5000,
    pingMaxRetries: 3,
})

// With this
import { Server } from "colyseus";
import { WebSocketTransport } from "@colyseus/ws-transport";
const gameServer = new Server({
    transport: new WebSocketTransport({
        server: http.createServer(app),
        pingInterval: 5000,
        pingMaxRetries: 3,
    })
});

Back to top