Skip to main content

PlayerCommunicationManager

A class in Root.Township, the global namespace.

Networked singleton the server uses to show a text message on players' screens. Get it from Instance.

Constructors​

MemberWhat it is
PlayerCommunicationManager()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

3 private and internal fields
MemberWhat it is
private static PlayerCommunicationManager instanceBacking field for Instance.
private static Logger loggerNLog logger for this class.
private MethodSyncStruct<PlayerTextMessage> syncMessageNetwork message that carries the text and duration.

Properties​

MemberWhat it is
static PlayerCommunicationManager Instance { get; }The current instance.

Methods​

MemberWhat it is
override void Initialize()Sets up the network message used to send text to players.
void SendMessageToAllPlayers(string message, float displayDuration = 5)Server: sends the message to every connected player, shown for the given seconds (5 by default).
void SendMessageToPlayer(IPlayer player, string message, float displayDuration = 5)Server: sends the message to one player with a player controller. Logs an error if called on a client.
2 private and internal methods
MemberWhat it is
private void Awake()Sets instance.
private void HandlePlayerMessage(IPlayer player, Stream stream, PlayerTextMessage textMessage)Serializes the message; on the receiving client, shows it on the local player's message display.