dist/test.js
/**
     * Choose random connection and flush a random message from a random sender.
     *
     * If this function was unable to flush a message, because there are no more messages to flush, it returns false. true otherwise.
     * @return {boolean}
     */
Choose random connection and flush a random message from a random sender.
If this function was unable to flush a message, because there are no more messages to flush, it returns false. true otherwise.
@return {boolean}
Choose random connection and flush a random message from a random sender . If this function was unable to flush a message because there are no more messages to flush it returns false . true otherwise . @return { boolean }
flushRandomMessage () {
      const gen = this.prng;
      const conns = Array.from(this.onlineConns).filter(conn => conn.receiving.size > 0);
      if (conns.length > 0) {
        const receiver = oneOf(gen, conns);
        const [sender, messages] = oneOf(gen, Array.from(receiver.receiving));
        const m = messages.shift();
        if (messages.length === 0) {
          receiver.receiving.delete(sender);
        }
        if (m === undefined) {
          return this.flushRandomMessage()
        }
        const encoder = createEncoder();
        readSyncMessage(createDecoder(m), encoder, receiver, receiver.tc);
        if (length$1(encoder) > 0) {
          sender._receive(toUint8Array(encoder), receiver);
        }
        return true
      }
      return false
    }
flushRandomMessage ( ) { const gen = this . prng ; const conns = Array . from ( this . onlineConns ) . filter ( conn => conn . receiving . size > 0 ) ; if ( conns . length > 0 ) { const receiver = oneOf ( gen , conns ) ; const [ sender , messages ] = oneOf ( gen , Array . from ( receiver . receiving ) ) ; const m = messages . shift ( ) ; if ( messages . length === 0 ) { receiver . receiving . delete ( sender ) ; } if ( m === undefined ) { return this . flushRandomMessage ( ) } const encoder = createEncoder ( ) ; readSyncMessage ( createDecoder ( m ) , encoder , receiver , receiver . tc ) ; if ( length$1 ( encoder ) > 0 ) { sender . _receive ( toUint8Array ( encoder ) , receiver ) ; } return true } return false }
Choose random connection and flush a random message from a random sender.
Choose random connection and flush a random message from a random sender .
// console.log('receive (' + sender.userID + '->' + receiver.userID + '):\n', syncProtocol.stringifySyncMessage(decoding.createDecoder(m), receiver)) // do not publish data created when this function is executed (could be ss2 or update message) // send reply message