/// <summary> /// Adds a message to the buffer with a given sequence value /// </summary> public void AddMessage( UpdateMessage msg, uint localSequence ) { if ( msg == null ) { throw new System.ArgumentException( "Can't add null message" ); } // TODO: These messages will not be arriving at the server in sequence - they need to be sorted msg.Sequence = localSequence; m_Messages[ m_CurMessageIndex ] = msg; // NOTE: This crushes messages in order from oldest to youngest if the number of stored messages reached // a maximum (because some lousy client hasn't been keeping up-to-date) m_CurMessageIndex = ( m_CurMessageIndex + 1 ) % m_Messages.Length; m_NumMessages = Utils.Min( m_NumMessages + 1, m_Messages.Length ); }
/// <summary> /// Handles an update message. Passes the message payload up to the parent object /// </summary> public void Handle( UpdateMessage msg ) { if ( m_Target == null ) { if ( m_NotifyNullTarget ) { NetworkLog.RuntLog.Warning( "{0} somehow received an UpdateMessage without a valid" ); m_NotifyNullTarget = false; } } else { Message payload = msg.Payload; // Mark the payload message with this object as the source, so it can be ignored // when it comes back along the message recipient chain payload.Sender = this; m_Target.HandleMessage( payload ); } }
/// <summary> /// Sets up the message batch /// </summary> public UpdateMessageBatch( uint sequence, UpdateMessage[] updateMessages ) { m_Sequence = sequence; m_Messages = updateMessages; }