/// <summary> /// Handles the event of a new client connecting. /// </summary> private void handleClientConnected(short clientID) { if (NetworkIdentity.isServer) { //Forward previous avatar requests to new client foreach (short client in clientAvatarRequests) { ServerBehaviour.Instance.sendMessageToClient(MessageFactory.createAvatarRequestMessage(false, client), clientID, true); } } }
/// <summary> /// Performs necessary initializations for player avatar if one is provided. /// </summary> private void initializePlayer(short clientID) { //Player needs an avatar if (playerAvatarPrefab) { Instantiate(playerAvatarPrefab).name = getAvatarName(clientID); //Notify network that this client has an avatar ClientMessageSender.Instance.sendMessage(MessageFactory.createAvatarRequestMessage(true), true); } }
private static void processAvatarRequestMessage(byte[] msg, bool clientMessage) { short clientID = ObjectSerializer.deserializeShort(ref msg); AvatarManager.Instance?.handleAvatarRequest(clientID); if (ServerBehaviour.Instance) //Message is being processed on the server { byte[] clientIDMsg = MessageFactory.createAvatarRequestMessage(false, clientID); ServerBehaviour.Instance.sendMessage(clientIDMsg, clientID, true); //Forward to all clients but the sender } }