Navigation

  • Recent
  • Tags
  • Users
  • Search
  • Login
Colyseus
  • Login
  • Search
  • Recent
  • Tags
  • Users

Documentation GitHub

We're migrating to GitHub Discussions. This forum does not accept new registrations since April 6, 2023.
  1. Home
  2. h4ss4n
h4ss4n

h4ss4n

@h4ss4n

Chat Follow Unfollow
0
Reputation
8
Posts
1.4k
Profile views
0
Followers
0
Following
Joined 3 Jun 2019, 21:54 Last Online 18 Jun 2019, 22:47

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

Posts made by h4ss4n

re-connection field

I have problem with re-connection method and get errors , Please guide me to solve this problem.

Node.js v: 10.14.2
Colyseus v: 0.11.15
Run on local machine

Server:

async onLeave (client, consented: boolean) {
    //console.log("ChatRoom:", client.sessionId, "left!");
      // flag client as inactive for other users
        this.state.players[client.sessionId].connected = false;

        try {
            if (consented) {
                throw new Error("consented leave");
            }

            // allow disconnected client to reconnect into this room until 20 seconds
            await this.allowReconnection(client, 20);

            // client returned! let's re-activate it.
            this.state.players[client.sessionId].connected = true;

        } catch (e) {

            // 20 seconds expired. let's remove the client.
            console.log('catch');
            delete this.state.players[client.sessionId];
        }
        
}

Client side:

function fun_recconection(){
console.log(room id ${roomPub.id} user id: ${roomPub.sessionId});
roomPub = client.reconnect(roomPub.id, roomPub.sessionId).then(room => {
console.log("joined successfully", room);
}).catch(e => {
console.error("join error", e);
});
}

I got below Errors when user want re-connection on server side:

(node:13296) UnhandledPromiseRejectionWarning: Error:
at Http2CallStream.call.on (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\client.js:96:45)
at Http2CallStream.emit (events.js:187:15)
at Http2CallStream.EventEmitter.emit (domain.js:441:20)
at process.nextTick (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\call-stream.js:71:22)
at process._tickCallback (internal/process/next_tick.js:61:11)
(node:13296) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:13296) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
lTQxdMuQe joined. rhvUnvD2e
(node:13296) UnhandledPromiseRejectionWarning: Error:
at Http2CallStream.call.on (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\client.js:96:45)
at Http2CallStream.emit (events.js:187:15)
at Http2CallStream.EventEmitter.emit (domain.js:441:20)
at process.nextTick (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\call-stream.js:71:22)
at process._tickCallback (internal/process/next_tick.js:61:11)
(node:13296) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)

posted in Questions & Help • 18 Oct 2019, 22:17
RE: Room details

@endel Thanks for your answer . I use this solution for set data to setMetadata and This code work well:

Client side (local):

room = client.join('create_or_join', { create: true, name:'hi2020', gametype:1 });

Server side (TS file):

onInit (options) {
this.setMetadata({
name: options.name,
gametype: options.gametype,
});}

posted in Questions & Help • 18 Jun 2019, 22:47
RE: Room details

@mdotedot
How can I set setMetadata on server and client ?

I try below Code but didn't work and receive this Error from browser
"Uncaught TypeError: room.setMetadata is not a function
at create (04-create-or-join-room.html:70)
at HTMLButtonElement.onclick (04-create-or-join-room.html:30)"

client side (Local):

function create () {
     room = client.join('create_or_join', { create: true });
    addListeners(room);
    room.setMetadata('hihi');
      
  }

Client side (Server):

setMetadata(meta){
    console.log("setMetadata ");
}

Do you have any suggestion ?

posted in Questions & Help • 18 Jun 2019, 21:44
RE: Room details

@mdotedot Thanks for your response it's great!

posted in Questions & Help • 12 Jun 2019, 11:36
RE: Room details

@h4ss4n answer of my first question: This variable _maxClientsReached hold status of room .

posted in Questions & Help • 4 Jun 2019, 12:18
Room details

I'm newbie in Colyseus and i would like to say sorry for my poor English, I want create a play Cards game with Node.js and HTML.
I have some question :
How can i get count of user exist in the room?
How can i get name and link of rooms ?

posted in Questions & Help • 3 Jun 2019, 22:20

© 2023 Endel Dreyer