Navigation

    Colyseus
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Users
    1. Home
    2. xiao
    X

    xiao

    @xiao

    Chat Follow Unfollow
    0
    Reputation
    4
    Posts
    265
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Continue chat with xiao
      • Flag Profile
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    xiao Follow

    Posts made by xiao

    RE: How to deploy https and wss(solved)

    Problem solved:

    wss://yourid.colyseus.dev
    
    posted in Colyseus Arena - Cloud Hosting •
    RE: How to deploy https and wss(solved)

    @coco
    Hi, I cant post in Chinese.

    My website is secure (https://domain.com), and I am hosting my game engine backend in Colyseus Arena (https://www.colyseus.io/arena), which is not secure (not https, not wss:), because I am following this documentations (https://docs.colyseus.io/arena/getting-started/create-colyseus-server/).

    How do I change the Colyseus backend (hosted on Colyseus Arena), to be listening on https and wss?

    My arena.config.js on the server doesn't host and listen in secure (https and wss):

    import Arena from "@colyseus/arena";
    import { monitor } from "@colyseus/monitor";
    
    import { RelayRoom } from "./rooms/RelayRoom";
    
    const { createServer } = require("https")
    const { key, cert } = require("./ssl")()
    import { WebSocketTransport } from "@colyseus/ws-transport"
    const express = require("express")
    import cors from "cors";
    
    export default Arena({
      getId: () => "Your Colyseus App",
    
      initializeGameServer: (gameServer) => {
        gameServer.define("gameroom", RelayRoom, {
          maxClients: 100,
          allowReconnectionTime: 0,
        });
      },
    
      
      initializeExpress: (app) => {
        /**
         * Bind your custom express routes here:
         */
        app.get("/", (req, res) => {
          res.send("It's time to kick ass and chew bubblegum!");
        });
    
        /**
         * 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());
      },
    
      beforeListen: () => {
        /**
         * Before before gameServer.listen() is called.
         */
      },
    
      initializeTransport: (options) => {
    
        const app = express()
        app.use(cors());
        app.use(express.json())
    
        // Prepare HTTPS server
        const secureServer = createServer({ key, cert }, app)
        console.log("secureServer created")
        return new WebSocketTransport({
            server: secureServer,
        });
    },
    
    });
    
    posted in Colyseus Arena - Cloud Hosting •
    How to deploy https and wss(solved)

    Since we cannot edit index.ts when deploying on Arena, how to deploy on Arena while it listening to wss:url and https for matchmaking API?

    Here is my attemp:

    import Arena from "@colyseus/arena";
    import { monitor } from "@colyseus/monitor";
    
    import { RelayRoom } from "./rooms/RelayRoom";
    
    const { createServer } = require("https")
    const { key, cert } = require("./ssl")()
    import { WebSocketTransport } from "@colyseus/ws-transport"
    const express = require("express")
    import cors from "cors";
    
    export default Arena({
      getId: () => "Your Colyseus App",
    
      initializeGameServer: (gameServer) => {
        gameServer.define("gameroom", RelayRoom, {
          maxClients: 100,
          allowReconnectionTime: 0,
        });
      },
    
      
      initializeExpress: (app) => {
        /**
         * Bind your custom express routes here:
         */
        app.get("/", (req, res) => {
          res.send("It's time to kick ass and chew bubblegum!");
        });
    
        /**
         * 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());
      },
    
      beforeListen: () => {
        /**
         * Before before gameServer.listen() is called.
         */
      },
    
      initializeTransport: (options) => {
    
        const app = express()
        app.use(cors());
        app.use(express.json())
    
        // Prepare HTTPS server
        const secureServer = createServer({ key, cert }, app)
        console.log("secureServer created")
        return new WebSocketTransport({
            server: secureServer,
        });
    },
    
    });
    
    posted in Colyseus Arena - Cloud Hosting •