Class ChatSystem
Handles all message dispatching. Local Chat Channel Physics checks, and server event messaging.
Inheritance
Namespace: LlamaSoftware.Chat
Assembly: LlamaSoftware.Chat.dll
Syntax
public class ChatSystem : NetworkBehaviour
Fields
DuplicateJoinMessage
String Template for server broadcast messages when players try to join a channel they are already in. Only used if ShowChannelConnectionMessages is true.
Declaration
public string DuplicateJoinMessage
Field Value
Type | Description |
---|---|
System.String |
Instance
Declaration
public static ChatSystem Instance
Field Value
Type | Description |
---|---|
ChatSystem |
JoinedChannelMessage
String Template for server broadcast messages when players join a channel. Only used if ShowChannelConnectionMessages is true.
Declaration
public string JoinedChannelMessage
Field Value
Type | Description |
---|---|
System.String |
LeftChannelMessage
String Template for server broadcast messages when players leaves a channel. Only used if ShowChannelConnectionMessages is true.
Declaration
public string LeftChannelMessage
Field Value
Type | Description |
---|---|
System.String |
PlayerLayer
Layer that Players are on. Used in UnityEngine.Physics.OverlapSphere(UnityEngine.Vector3,System.Single) to determine which players should receive local chat channel messages.
Declaration
public LayerMask PlayerLayer
Field Value
Type | Description |
---|---|
UnityEngine.LayerMask |
ShowChannelConnectionMessages
Whether or not a server broadcast message should be sent to a player when they join/leave channels.
Declaration
public bool ShowChannelConnectionMessages
Field Value
Type | Description |
---|---|
System.Boolean |
Methods
FindSubscribedPlayersAndSendMessage(ChatMessage)
Finds players who are online and subscribed to the provided ChatMessage's Channel and sends them all the provided message.
Declaration
protected virtual void FindSubscribedPlayersAndSendMessage(ChatMessage chatMessage)
Parameters
Type | Name | Description |
---|---|---|
ChatMessage | chatMessage | Inbound message |
OnDisconnect(NetworkConnection)
Called by Unity automatically when a player disconnets. Removes the player from list of online players and updates
Declaration
public virtual void OnDisconnect(NetworkConnection Connection)
Parameters
Type | Name | Description |
---|---|---|
NetworkConnection | Connection | Connection of the disconnecting player |
OnStartServer()
Sets up DontDestroyOnLoad, or destroys itself if there's already a ChatSystem in the scene.
Also sets up
Declaration
public override void OnStartServer()
ReceiveBlockListStatusUpdate(NetworkMessage)
Handles block list add / removal requests.
UNET: Called by
Declaration
protected virtual void ReceiveBlockListStatusUpdate(NetworkMessage message)
Parameters
Type | Name | Description |
---|---|---|
NetworkMessage | message | Inbound message. |
ReceiveFriendListStatusUpdate(NetworkMessage)
Handles friend list add / removal requests.
Mirror: Called by
Declaration
protected virtual void ReceiveFriendListStatusUpdate(NetworkMessage message)
Parameters
Type | Name | Description |
---|---|---|
NetworkMessage | message | Inbound message. |
ReceiveMessage(NetworkMessage)
Handles incoming chat messages from clients. Will not send to clients who are not subscribed to the channel requested.
Declaration
protected virtual void ReceiveMessage(NetworkMessage message)
Parameters
Type | Name | Description |
---|---|---|
NetworkMessage | message | Inbound message |
ReceiveSubscriptionRequest(NetworkMessage)
Handles players requesting to join a channel.
UNET: Called by
Declaration
protected virtual void ReceiveSubscriptionRequest(NetworkMessage message)
Parameters
Type | Name | Description |
---|---|---|
NetworkMessage | message | Inbound Message |
SendBlockListUpdateMessage(Int32, BlockListMessage)
Sends the provided BlockListMessage to the player with the provided
Declaration
protected virtual void SendBlockListUpdateMessage(int ConnectionId, BlockListMessage blockListMessage)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | ConnectionId | Connection Id of the player to recieve the message. |
BlockListMessage | blockListMessage | Message to send. |
SendFriendsListUpdateMessage(Int32, FriendsListMessage)
Sends the provided FriendsListMessage to the player with the provided
Declaration
protected virtual void SendFriendsListUpdateMessage(int ConnectionId, FriendsListMessage friendsListMessage)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | ConnectionId | Connection Id of the player to recieve the message. |
FriendsListMessage | friendsListMessage | Message to send. |
SendServerBroadcastMessage(Int32, ServerBroadcastMessage)
Sends the provided ServerBroadcastMessage to the player with the provided
Declaration
protected virtual void SendServerBroadcastMessage(int ConnectionId, ServerBroadcastMessage Message)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | ConnectionId | Connection Id of the player to recieve the message. |
ServerBroadcastMessage | Message | Message to send. |
ShouldSendMessageToPlayer(String, String)
Returns whether or not a given player can message another player.
Declaration
protected bool ShouldSendMessageToPlayer(string SenderId, string ReceiverId)
Parameters
Type | Name | Description |
---|---|---|
System.String | SenderId | Unique Player ID of the player trying to send a message |
System.String | ReceiverId | Unique Player ID of the player who is trying to be contacted |
Returns
Type | Description |
---|---|
System.Boolean |
UpdatePlayerStatusOnDisconnect(NetworkConnection)
Updates player status for all friends when they disconnect.
Declaration
protected virtual void UpdatePlayerStatusOnDisconnect(NetworkConnection connection)
Parameters
Type | Name | Description |
---|---|---|
NetworkConnection | connection | Connection of the disconnecting player. |