@endel Thank you so much.
But i still not understand how to send the code to player who is invited.
For example:
Player A login, and see this lists
B, C, D
A want to invite C to duel, A send a message to Server "Hey, I want to make a duel with C"
I don't know how to make Server to send message to C "Hey A want to make a dule with C" and C can accept or not.
This is my code
// When a client sends a message
onMessage (client, message) {
switch (message.action) {
//A send request to invite C to make a duel
case 'request_dule':
let guestId = message.data.guest_id;
let guest = this.state.players[guestId];
//find a client has id equal with C's client id
for (let i = 0; i < this.clients.length; i++) {
if (this.clients[i].id == guest.client_Id) {
//send request to C's client and wait C accepting
this.send(this.clients[i], {action: 'request_dule', data: {host: client.id}});
break;
}
}
break;
default:
break;
}
}
Looking forward your advice. Thanks