@endel thank you, i will try this.
Posts made by hardik_sl
Error !
colyseus@0.9.24 postinstall /home/fancytee/nodevenv/game_server/8/lib/node_modules/colyseus
npm run -s donate
while running npm install on my server through ssh
here is a screen shot
in case image not visible
https://drive.google.com/file/d/1VM9z4aAC2nuPnkNWQr4FnKwbzBFfePoP/view?usp=sharing
@endel thank you. and i am just using cards array for push and pop only i am not mutating and thanks again for help.
My state is like this:
onInit(options)
this.maxClients = 5;
this.minClients = 3;
this.setState({
players: {},
apid: [],
dpid: [1, 2, 3, 4, 5],
});
onJoin(client, options) {
var id;
id = this.state.dpid.shift();
this.state.apid.push(id);
this.state.players[client.sessionId] = {
playerId: id,
cards: [],
state: 1,
pack: 0,
trickData: {
Rank: 0,
Sum: 0,
c1: 0,
c2: 0,
c3: 0
}
}
C# code for listen to state change is:
room.Listen("players/:id", OnPlayerChange);
//room.Listen("players/:id/:playerId", OnPlayerIdChange);
//room.Listen("players/:id/:pack", OnPlayerPack);
room.Listen("players/:id/:cards/:number", OnCardsChange);
Problem is when palyersId change the OnPlayerIdChange and OnPlayerPack both getting the this data of state
trickData: {
Rank: 0,
Sum: 0,
c1: 0,
c2: 0,
c3: 0
}
i want to listen to only playerId and pack when this variable changes
[SOLVED]
Thanks @endel but as i am making card game i need to have options for client to choose whether to create a room ( private table ) or join the room ( if there is no room available then auto create room with)
Whenever i try to join room with quick match i get this error
Error: Failed to auto-create room "table" during join request using options "
{"create":false,"requestId":1,"clientId":"7klsqdU1v","sessionId":"eYHS93fBq"}"
at MatchMaker.create (D:\Colysues Server Unity\Server\node_modules\colyseus\lib\MatchMaker.js:228:19)
at MatchMaker.<anonymous> (D:\Colysues Server Unity\Server\node_modules\colyseus\lib\MatchMaker.js:114:31)
at Generator.next (<anonymous>)
at fulfilled (D:\Colysues Server Unity\Server\node_modules\colyseus\lib\MatchMaker.js:4:58)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
although if there is any available room it worked just fine and join that room. problem occurs when there is no room available to join (should not it automatically create a room ?)
here's server onJoin method
requestJoin (options, isNew) {
console.log("request join!", options);
return (options.create)? (options.create && isNew) : this.clients.length > 0;
}
onJoin (client, options) {
console.log("client joined! ", options);
}
Unity client code
string roomName = "table"
//for Quick Join
public void Join()
{
room = client.Join(roomName, new Dictionary<string, object>()
{
{ "create", false}
});
StartCoroutine(ConnectToRoom());
}
//for Creting new room
public void Create()
{
Debug.Log("Let's Crete & join the room!");
room = client.Join(roomName, new Dictionary<string, object>()
{
{ "create", true },
});
StartCoroutine(ConnectToRoom());
}
@endel Yay !! thats work Thanks.
@endel here the code
const http = require("http");
const express = require("express");
const monitor = require("@colyseus/monitor");
const colyseus = require("colyseus");
const GameRoom = require('./game_room');
const PORT = process.env.PORT || 3553;
const app = new express();
const gameServer = new colyseus.Server({
server: http.createServer(app)
});
// Register GameRoom as "table"
gameServer.register("table", GameRoom);
app.get("/something", function (req, res) {
console.log("something!", process.pid);
res.send("Hey!");
});
//colyseus game server monitor panel
app.use("/colyseus", monitor(gameServer));
// Listen on specified PORT number
gameServer.listen(PORT);
console.log("Running on ws://localhost:" + PORT);
@anubiscode i mean that if i use typescript then i can use this code to attach monitor ->
app.use("/colyseus", monitor(gameServer));
but if i use java script that will not work so any other way to attach monitor to game server??