/// <summary> /// Handles messages sent over a specified connection /// </summary> private void OnReceivedMessage( IConnection connection, Message msg ) { if ( !( msg is UpdateMessageBatch ) ) { // Not interested return; } UpdateMessageBatch batchMsg = ( UpdateMessageBatch )msg; if ( batchMsg.Sequence < m_Sequence ) // TODO: Should be <=. Just ordering issues between update message creation and sequence increment { return; } // Message away if ( batchMsg.Messages != null ) { foreach ( UpdateMessage updateMsg in batchMsg.Messages ) { if ( updateMsg.Sequence >= m_Sequence ) // TODO: Should be >. Just ordering issues between update message creation and sequence increment { IUpdateHandler handler = m_HandlerMap[ updateMsg.TargetId ]; handler.Handle( updateMsg ); } } } m_Sequence = batchMsg.Sequence; // Let's let the source know that we got an update! yay! // TODO: Should this be sent at every frame? // TODO: If there's an update source, then the information about the target sequence can be piggy-backed in an UpdateMessageBatch connection.DeliverMessage( new TargetSequenceMessage( m_Sequence ) ); }