new HostController()
a wrapper class for the net controller for the host, this just overrides some things to fix up how data is sent and prepared
for clients.
Members
-
connections
-
all connections to the host's peer
-
netPlayers
-
players not on the local machine
dictionary with keys equal to the client's peer id -
peerId
-
the id of the host's peer
-
player
-
the player on the local machine
-
self
-
the host's peer
Methods
-
createOutGoingNetPlayers(recipientId)
-
assembles the proper list of netPlayers with host included and recipient excluded
Parameters:
Name Type Description recipientId
the id of the recipient's peer
-
distributeDataToClients(obj, senderId)
-
a function to redistribute data to all clients
Parameters:
Name Type Description obj
* the object to distribute
senderId
* the id of the original sender
-
distributeNetPlayersToClients()
-
send an updated list of all net players to the client.
The host needs to be included in this list and the client the information is being sent to needs to be excluded from this list -
onPlayerInfoData()
-
processes playerinfo and then emits the 'playerInfo' event
Fires:
- event:playerInfo
-
preprocessData(data, conn)
-
a function that will preprocess the data for onData.
this adds the field .id equal to the connection's id and distribute's data to clientsParameters:
Name Type Description data
the data that was sent
conn
the connection that is sending the data
-
sendPlayerInfo()
-
alias of distributeNetPlayersToClients used for updating players when this one changes
-
startGame()
-
send all connections the startGame command