@endel Thanks for getting back to me :)
I'm using a Node server and C# Unity client.
Server Example:
class ShortDeckState extends Schema {
@type("string") gameState: ShortDeckGameState;
@type("int32") gameStateCountdown: number;
@type({ map: ShortDeckPlayer }) players = new MapSchema<ShortDeckPlayer>();
@type(ShortDeckTable) table: ShortDeckTable = new ShortDeckTable();
}
class ShortDeckTable extends Schema {
@type("string") flopCard1: string;
@type("string") flopCard2: string;
@type("string") flopCard3: string;
@type("string") turnCard: string;
@type("string") riverCard: string;
@type("string") dealerCard1: string;
@type("string") dealerCard2: string;
}
// Later in my code I receive a player message, and update the cards on the table:
this.state.table.flopCard1 = flopCards[0];
this.state.table.flopCard2 = flopCards[1];
this.state.table.flopCard3 = flopCards[2];
this.state.gameState = ShortDeckGameState.TurnWager;
// Immediately after I send an event to the clients that gamestate has changed.
// Before I wasn't including the table and players items in the message but I found I needed
// it to get my data accross.
var message = new ShortDeckWagerStateChanged();
message.wagerState = this.state.gameState;
message.wagerStateCountdown = this.WagerTimeoutSeconds;
message.table = this.state.table;
message.players = this.state.players;
this.broadcast(message, { afterNextPatch: true });
Client:
// On the client side after I receive ShortDeckWagerStateChanged I try to access room.state.table to get the flop cards but they are always null. gameState has the correct value however
private void OnShortDeckMessage(object message)
{
if (message is ShortDeckWagerStateChanged)
{
var wagerChangedMessage = message as ShortDeckWagerStateChanged;
// This is always null
var flopCard1 = this.room.State.table.flopCard1;
}
}
I hope that illustrates the point a little bit. I copied it from my codebase with some properties removed on the main state class for brevity. Thanks for any pointers you can give me here. I'd like to be able to just use the messages to notify clients of something interesting happening (folded, bet, etc...) and then the clients query the state object for data. This way the clients joining the server in the middle or the clients in the middle of the game are querying the same state data and not having to use a bunch of messages with different properties.