private void ServerProcessInput(NetworkMessage netMsg) { //Get the msg InputListMessage msg = netMsg.ReadMessage <InputListMessage>(); //Add all inputs msg.inputsList.ForEach(e => inputsList.Enqueue(e)); //Store the last received message lastMassageTime = msg.stamp; }
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>FIXED UPDATE private void SendMessages() { //Clients (local not server) if(isLocalPlayer && !isServer) { //Only send input at the network send interval if (dataStep > GetNetworkSendInterval()) { dataStep = 0; int toSend = inputsList.Count; //Send input to the server if (inputsList.Count > 0) { InputListMessage messageToSend = new InputListMessage(); messageToSend.inputsList = new List<Inputs>(inputsList); connectionToServer.Send(InputListMessage.MSGID, messageToSend); //Clear the input list inputsList.Clear(); } } } //Host Client if(isLocalPlayer && isServer) { //This is for the host player to send its position to all other clients //HOST (THE CLIENT ON THE SERVER) CLIENT if (isServer) { if (dataStep > GetNetworkSendInterval()) { dataStep = 0; if (movementToSend) { //Send the current server pos to all clients RpcClientReceivePosition(currentStamp, transform.position, m_MoveDir); movementToSend = false; } } } } //Server dummies if(!isLocalPlayer && isServer) { //If its time to send messages if (dataStep > GetNetworkSendInterval()) { //If we have any changes in position or rotation, we send a messsage if (movementToSend) { RpcClientReceivePosition(currentStamp, transform.position, m_MoveDir); movementToSend = false; } dataStep = 0; } } //Update data step dataStep += Time.deltaTime; }
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>FIXED UPDATE private void SendMessages() { //Clients (local not server) if (isLocalPlayer && !isServer) { //Only send input at the network send interval if (dataStep > GetNetworkSendInterval()) { dataStep = 0; int toSend = inputsList.Count; //Send input to the server if (inputsList.Count > 0) { InputListMessage messageToSend = new InputListMessage(); messageToSend.inputsList = new List <Inputs>(inputsList); connectionToServer.Send(InputListMessage.MSGID, messageToSend); //Clear the input list inputsList.Clear(); } } } //Host Client if (isLocalPlayer && isServer) { //This is for the host player to send its position to all other clients //HOST (THE CLIENT ON THE SERVER) CLIENT if (isServer) { if (dataStep > GetNetworkSendInterval()) { dataStep = 0; if (movementToSend) { //Send the current server pos to all clients RpcClientReceivePosition(currentStamp, transform.position, m_MoveDir); movementToSend = false; } } } } //Server dummies if (!isLocalPlayer && isServer) { //If its time to send messages if (dataStep > GetNetworkSendInterval()) { //If we have any changes in position or rotation, we send a messsage if (movementToSend) { RpcClientReceivePosition(currentStamp, transform.position, m_MoveDir); movementToSend = false; } dataStep = 0; } } //Update data step dataStep += Time.deltaTime; }