|
Network Library Documentation
|
Manages network-related operations on the client side, including connection handling, user synchronization, transform and animation updates, and messaging. It is part of EDA architecture of the library. More...
Public Member Functions | |
| void | ConnectToServer () |
| Initiates a connection to the server. | |
| void | DisconnectFromServer () |
| Sends a request to disconnect the client from the server. | |
| void | AddUser (GameObject userPrefab) |
| Adds a newly spawned user object to the list of online users. | |
| GameObject | GetUserByName (string username) |
| Retrieves a user GameObject by username. | |
| GameObject | GetUserById (int id) |
| Retrieves a user GameObject by user ID. | |
| void | SpawnUser (int id, string userName, bool isLocal) |
| Instantiates and initializes a new user object in the scene. | |
| void | DisconnectForeignUser (int id) |
| Removes a remote user object from the scene based on its ID. | |
| void | SendTextMessage (string message, int mode, int id) |
| Sends a text message to either all users or a specific user. | |
| void | sendTestMessage () |
| Sends a test broadcast message to the server. | |
| void | UpdateTransform (Transform objectTransform) |
| Sends the updated transform of the local user to the server. | |
| void | SendAnimatorParameter (int type, string name, float value) |
| Sends an animation parameter change to the server for synchronization. | |
Public Attributes | |
| List< GameObject > | onlineUsers |
| List of all currently active (connected) user GameObjects in the scene. | |
| Transform[] | spawnPoints |
| Predefined spawn points used for placing newly connected users in the scene. | |
Static Public Attributes | |
| static NetworkManager | networkManager |
| Singleton instance of the NetworkManager. | |
Private Member Functions | |
| void | Awake () |
| Initializes the singleton instance of the NetworkManager. | |
| void | Start () |
| Subscribes to client events for handling network state changes and data reception, can be easily extended of new events. | |
| void | HandleConnected () |
| Callback invoked when the client successfully connects to the server. | |
| void | HandleConnectionFailed (string reason) |
| Callback invoked when the connection to the server fails. | |
| void | HandleMessage (string message) |
| Callback for processing a received message from the server. | |
| void | HandleDisconnected () |
| Callback invoked when the client is disconnected from the server. Removes all user objects from the scene. | |
| void | HandleTransformChange (int id, Vector3 pos, Quaternion rot) |
| Applies a received position and rotation update to the corresponding remote user. | |
| void | HandleAnimationChange (int id, int type, string name, float value) |
| Applies a received animation parameter change to the corresponding remote user. | |
Private Attributes | |
| ClientSettings | ClientSettings |
| Configuration settings for the client, including user prefab and other preferences. | |
Manages network-related operations on the client side, including connection handling, user synchronization, transform and animation updates, and messaging. It is part of EDA architecture of the library.
Definition at line 10 of file NetworkManager.cs.
| void NetworkManager.AddUser | ( | GameObject | userPrefab | ) |
Adds a newly spawned user object to the list of online users.
Definition at line 142 of file NetworkManager.cs.
|
private |
Initializes the singleton instance of the NetworkManager.
Definition at line 32 of file NetworkManager.cs.
| void NetworkManager.ConnectToServer | ( | ) |
Initiates a connection to the server.
Definition at line 58 of file NetworkManager.cs.
| void NetworkManager.DisconnectForeignUser | ( | int | id | ) |
Removes a remote user object from the scene based on its ID.
Definition at line 186 of file NetworkManager.cs.
| void NetworkManager.DisconnectFromServer | ( | ) |
Sends a request to disconnect the client from the server.
Definition at line 65 of file NetworkManager.cs.
| GameObject NetworkManager.GetUserById | ( | int | id | ) |
Retrieves a user GameObject by user ID.
Definition at line 163 of file NetworkManager.cs.
| GameObject NetworkManager.GetUserByName | ( | string | username | ) |
Retrieves a user GameObject by username.
Definition at line 149 of file NetworkManager.cs.
|
private |
Applies a received animation parameter change to the corresponding remote user.
Definition at line 125 of file NetworkManager.cs.
|
private |
Callback invoked when the client successfully connects to the server.
Definition at line 72 of file NetworkManager.cs.
|
private |
Callback invoked when the connection to the server fails.
Definition at line 79 of file NetworkManager.cs.
|
private |
Callback invoked when the client is disconnected from the server. Removes all user objects from the scene.
Definition at line 95 of file NetworkManager.cs.
|
private |
Callback for processing a received message from the server.
Definition at line 87 of file NetworkManager.cs.
|
private |
Applies a received position and rotation update to the corresponding remote user.
Definition at line 108 of file NetworkManager.cs.
| void NetworkManager.SendAnimatorParameter | ( | int | type, |
| string | name, | ||
| float | value ) |
Sends an animation parameter change to the server for synchronization.
Definition at line 228 of file NetworkManager.cs.
| void NetworkManager.sendTestMessage | ( | ) |
Sends a test broadcast message to the server.
Definition at line 214 of file NetworkManager.cs.
| void NetworkManager.SendTextMessage | ( | string | message, |
| int | mode, | ||
| int | id ) |
Sends a text message to either all users or a specific user.
Definition at line 202 of file NetworkManager.cs.
| void NetworkManager.SpawnUser | ( | int | id, |
| string | userName, | ||
| bool | isLocal ) |
Instantiates and initializes a new user object in the scene.
Definition at line 177 of file NetworkManager.cs.
|
private |
Subscribes to client events for handling network state changes and data reception, can be easily extended of new events.
Definition at line 46 of file NetworkManager.cs.
| void NetworkManager.UpdateTransform | ( | Transform | objectTransform | ) |
Sends the updated transform of the local user to the server.
Definition at line 221 of file NetworkManager.cs.
|
private |
Configuration settings for the client, including user prefab and other preferences.
Definition at line 23 of file NetworkManager.cs.
|
static |
Singleton instance of the NetworkManager.
Definition at line 15 of file NetworkManager.cs.
| List<GameObject> NetworkManager.onlineUsers |
List of all currently active (connected) user GameObjects in the scene.
Definition at line 19 of file NetworkManager.cs.
| Transform [] NetworkManager.spawnPoints |
Predefined spawn points used for placing newly connected users in the scene.
Definition at line 27 of file NetworkManager.cs.