Skip to content

why socket did not disconnect when I pause Unity Client a long time? #252

Open
@sasalicat

Description

@sasalicat

my server config shows below,I havent set pingInterval,:
import config from "@colyseus/tools";

import { WebSocketTransport } from "@colyseus/ws-transport";
import { monitor } from "@colyseus/monitor";
import { playground } from "@colyseus/playground";
import { matchMaker } from "colyseus";
// import { RedisDriver } from "@colyseus/redis-driver";
// import { RedisPresence } from "@colyseus/redis-presence";

/**

  • Import your Room files
    */
    import { MyRoom } from "./rooms/MyRoom";
    import auth from "./config/auth";
    import { LobbyRoom } from "colyseus";

export default config({
options: {
// devMode: true,
// driver: new RedisDriver(),
// presence: new RedisPresence(),
//pingInterval: 3000
},

initializeTransport: (options) => new WebSocketTransport(options),

initializeGameServer: async (gameServer) => {
    /**
     * Define your room handlers:
     */
    gameServer.define('my_room', MyRoom);

    gameServer.define('lobby', LobbyRoom);
    //matchMaker.createRoom("default Room", {});
    console.log("create default room!");
        const conditions: any = {
            //locked: false,
            //private: false,
        };
    console.log(await matchMaker.query(conditions));
},

initializeExpress: (app) => {
    /**
     * Bind your custom express routes here:
     */
     console.log('initializeExpress be call')
    app.get("/", (req, res) => {
        res.send(`Instance ID => ${process.env.NODE_APP_INSTANCE ?? "NONE"}`);
    });
    app.get("/hello", (req, res) => {
        console.log('hellp be call');
        res.send(`hello there`);
    });

    app.get("/rooms", async (req, res) => {
        const conditions: any = {
            locked: false,
            private: false,
        };
        res.json(await matchMaker.query(conditions));
    });
    /**
     * Bind @colyseus/monitor
     * It is recommended to protect this route with a password.
     * Read more: https://docs.colyseus.io/tools/monitor/
     */
    app.use("/colyseus", monitor());

    // Bind "playground"
    app.use("/playground", playground());

    // Bind auth routes
    app.use(auth.prefix, auth.routes());
},


beforeListen: () => {
    /**
     * Before before gameServer.listen() is called.
     */
}

});
`
I pause Unity Editor for more then 1 minute,and I can still send messages after resuming the game,even I close the game,onleave Event did not been trigger.The onLeave event is only triggered when I restart the Unity Editor.

Is this case normal?did I missing some setting about this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions