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