Since a couple of days I'm making a mess of things :(
I have a feeling that I'm doing this the wrong way.
It all started with the 02-state-handler.ts
What I conclude is that you have a client that has an ID and that is constant no matter what room is created or joined.
However each joining or creation of a room is done with a session ID. SessionID != Client.ID
I want the game(s) to be able to get a list of players in the room.
export class RoomData{
playernames = "";
roomnames = "";
roomids = "";
sessionids = "";
}
export class Player {
ID = "";
Name = "";
x = Math.floor(Math.random() * 400);
y = Math.floor(Math.random() * 400);
width = 132;
height = 132;
}
Currently I use the RoomData class to alter the state of the server. These RoomData members are being broadcasted to the clients.
It feels kind of hacky to set these variables to have the roomstate being synchronized.
The way that I'm currently setting these values is in client (room.send) and server onMessage communications.
This is the current client perspective:
New Room:
Second Room:
Joining From the other Room (looks like it works)
And second player joining the third (this fails : player seems to be in two rooms ??!? )
Server Side Data :
roomName with id: RoomName:3tAeV4aU7 the changeID is pQZlJiSNb the ID without Name: 3tAeV4aU7 the name is Room424
roomName with id: RoomName:MZOaBj7hu the changeID is pQZlJiSNb the ID without Name: MZOaBj7hu the name is Room6959
roomName with id: RoomName:pQZlJiSNb the changeID is pQZlJiSNb the ID without Name: pQZlJiSNb the name is Room7704
roomnames: 3tAeV4aU7=Room424:MZOaBj7hu=Room6959:pQZlJiSNb=Room7704:
playername with id: PlayerName:iwIpOcjZs the changeID is pQZlJiSNb the id without name: iwIpOcjZs the name is Player8707
playername with id: PlayerName:j6a-rk8dc the changeID is pQZlJiSNb the id without name: j6a-rk8dc the name is Player4301
playername with id: PlayerName:EsP17dY-m the changeID is pQZlJiSNb the id without name: EsP17dY-m the name is Player1374
playernames: iwIpOcjZs=Player8707:j6a-rk8dc=Player4301:EsP17dY-m=Player1374
As it is fairly hacky stuff I'm hoping that someone has dealt with this before and can shed some light ....
When I don't use Client.ID and only show SessionIDs it worked much better, but how can I get a client (name) from a session?
The Player Class data does not appear to be part of a state. What should I do to get Player List with Names?!