process a chunk of adsb and commb messages recieved in the same
        time period.
173704
def process_raw(self, adsb_ts, adsb_msgs, commb_ts, commb_msgs, tnow=None):
        
        if tnow is None:
            tnow = time.time()

        self.t = tnow

        local_updated_acs_buffer = []
        output_buffer = []

        # process adsb message
        for t, msg in zip(adsb_ts, adsb_msgs):
            icao = pms.icao(msg)
            tc = pms.adsb.typecode(msg)

            if icao not in self.acs:
                self.acs[icao] = {
                    'live': None,
                    'call': None,
                    'lat': None,
                    'lon': None,
                    'alt': None,
                    'gs': None,
                    'trk': None,
                    'roc': None,
                    'tas': None,
                    'roll': None,
                    'rtrk': None,
                    'ias': None,
                    'mach': None,
                    'hdg': None,
                    'ver' : None,
                    'HPL' : None,
                    'RCu' : None,
                    'RCv' : None,
                    'HVE' : None,
                    'VVE' : None,
                    'Rc' : None,
                    'VPL' : None,
                    'EPU' : None,
                    'VEPU' : None,
                    'HFOMr' : None,
                    'VFOMr' : None,
                    'PE_RCu' : None,
                    'PE_VPL' : None,
                }

            self.acs[icao]['t'] = t
            self.acs[icao]['live'] = int(t)

            if 1 <= tc <= 4:
                cs = pms.adsb.callsign(msg)
                self.acs[icao]['call'] = cs
                output_buffer.append([t, icao, 'cs', cs])

            if (5 <= tc <= 8) or (tc == 19):
                vdata = pms.adsb.velocity(msg)
                if vdata is None:
                    continue

                spd, trk, roc, tag = vdata
                if tag != 'GS':
                    continue
                if (spd is None) or (trk is None):
                    continue

                self.acs[icao]['gs'] = spd
                self.acs[icao]['trk'] = trk
                self.acs[icao]['roc'] = roc
                self.acs[icao]['tv'] = t

                output_buffer.append([t, icao, 'gs', spd])
                output_buffer.append([t, icao, 'trk', trk])
                output_buffer.append([t, icao, 'roc', roc])


            if (5 <= tc <= 18):
                oe = pms.adsb.oe_flag(msg)
                self.acs[icao][oe] = msg
                self.acs[icao]['t'+str(oe)] = t

                if ('tpos' in self.acs[icao]) and (t - self.acs[icao]['tpos'] < 180):
                    # use single message decoding
                    rlat = self.acs[icao]['lat']
                    rlon = self.acs[icao]['lon']
                    latlon = pms.adsb.position_with_ref(msg, rlat, rlon)
                elif ('t0' in self.acs[icao]) and ('t1' in self.acs[icao]) and \
                     (abs(self.acs[icao]['t0'] - self.acs[icao]['t1']) < 10):
                    # use multi message decoding
                    try:
                        latlon = pms.adsb.position(
                            self.acs[icao][0],
                            self.acs[icao][1],
                            self.acs[icao]['t0'],
                            self.acs[icao]['t1'],
                            self.lat0, self.lon0
                            )
                    except:
                        # mix of surface and airborne position message
                        continue
                else:
                    latlon = None

                if latlon is not None:
                    self.acs[icao]['tpos'] = t
                    self.acs[icao]['lat'] = latlon[0]
                    self.acs[icao]['lon'] = latlon[1]

                    alt = pms.adsb.altitude(msg)
                    self.acs[icao]['alt'] = alt

                    output_buffer.append([t, icao, 'lat', latlon[0]])
                    output_buffer.append([t, icao, 'lon', latlon[1]])
                    output_buffer.append([t, icao, 'alt', alt])

                    local_updated_acs_buffer.append(icao)

            # Uncertainty & accuracy
            ac = self.acs[icao]

            if 9 <= tc <= 18:
                ac['nic_bc'] = pms.adsb.nic_b(msg)

            if (5 <= tc <= 8) or (9 <= tc <= 18) or (20 <= tc <= 22):
                ac['HPL'], ac['RCu'], ac['RCv'] = pms.adsb.nuc_p(msg)

                if (ac['ver'] == 1) and ('nic_s' in ac.keys()):
                    ac['Rc'], ac['VPL'] = pms.adsb.nic_v1(msg, ac['nic_s'])
                elif (ac['ver'] == 2) and ('nic_a' in ac.keys()) and ('nic_bc' in ac.keys()):
                    ac['Rc'] = pms.adsb.nic_v2(msg, ac['nic_a'], ac['nic_bc'])

            if tc == 19:
                ac['HVE'], ac['VVE'] = pms.adsb.nuc_v(msg)
                if ac['ver'] in [1, 2]:
                    ac['HFOMr'], ac['VFOMr'] = pms.adsb.nac_v(msg)

            if tc == 29:
                ac['PE_RCu'], ac['PE_VPL'], ac['base'] = pms.adsb.sil(msg, ac['ver'])
                ac['EPU'], ac['VEPU'] = pms.adsb.nac_p(msg)

            if tc == 31:
                ac['ver']  = pms.adsb.version(msg)
                ac['EPU'], ac['VEPU'] = pms.adsb.nac_p(msg)
                ac['PE_RCu'], ac['PE_VPL'], ac['sil_base'] = pms.adsb.sil(msg, ac['ver'])

                if ac['ver']  == 1:
                    ac['nic_s'] = pms.adsb.nic_s(msg)
                elif ac['ver']  == 2:
                    ac['nic_a'], ac['nic_bc'] = pms.adsb.nic_a_c(msg)


        # process commb message
        for t, msg in zip(commb_ts, commb_msgs):
            icao = pms.icao(msg)

            if icao not in self.acs:
                continue

            bds = pms.bds.infer(msg)

            if bds == 'BDS50':
                roll50 = pms.commb.roll50(msg)
                trk50 = pms.commb.trk50(msg)
                rtrk50 = pms.commb.rtrk50(msg)
                gs50 = pms.commb.gs50(msg)
                tas50 = pms.commb.tas50(msg)

                self.acs[icao]['t50'] = t
                if tas50:
                    self.acs[icao]['tas'] = tas50
                    output_buffer.append([t, icao, 'tas50', tas50])
                if roll50:
                    self.acs[icao]['roll'] = roll50
                    output_buffer.append([t, icao, 'roll50', roll50])
                if rtrk50:
                    self.acs[icao]['rtrk'] = rtrk50
                    output_buffer.append([t, icao, 'rtrk50', rtrk50])

                if trk50:
                    output_buffer.append([t, icao, 'trk50', trk50])
                if gs50:
                    output_buffer.append([t, icao, 'gs50', gs50])

            elif bds == 'BDS60':
                ias60 = pms.commb.ias60(msg)
                hdg60 = pms.commb.hdg60(msg)
                mach60 = pms.commb.mach60(msg)
                roc60baro = pms.commb.vr60baro(msg)
                roc60ins = pms.commb.vr60ins(msg)

                if ias60 or hdg60 or mach60:
                    self.acs[icao]['t60'] = t
                if ias60:
                    self.acs[icao]['ias'] = ias60
                if hdg60:
                    self.acs[icao]['hdg'] = hdg60
                if mach60:
                    self.acs[icao]['mach'] = mach60

                if roc60baro:
                    output_buffer.append([t, icao, 'roc60baro', roc60baro])
                if roc60ins:
                    output_buffer.append([t, icao, 'roc60ins', roc60ins])

        # clear up old data
        for icao in list(self.acs.keys()):
            if self.t - self.acs[icao]['live'] > self.cache_timeout:
                del self.acs[icao]
                continue

        if self.dumpto is not None:
            dh = str(datetime.datetime.now().strftime("%Y%m%d_%H"))
            fn = self.dumpto + '/pymodes_dump_%s.csv' % dh
            output_buffer.sort(key=lambda x: x[0])
            with open(fn, "a") as f:
                writer = csv.writer(f)
                writer.writerows(output_buffer)

        return
740420
def on_message(self, message):
        """"""
        json_rpc = json.loads(message)
        logging.log(logging.DEBUG, json_rpc)

        if self.pool is None:
            self.pool = multiprocessing.Pool(processes=args.workers)

        # Spawn a process to protect the server against segfaults
        async = self.pool.apply_async(_worker_process, [json_rpc])
        try:
            result = async.get(timeout=args.timeout)
            error = 0
        except multiprocessing.TimeoutError:
            result = ("File format conversion timed out! This is due "
                      "either to a large input file or a segmentation "
                      "fault in the underlying open babel library.")
            error = 1
            self.pool.terminate()
            self.pool = multiprocessing.Pool(processes=args.workers)
        except Exception:
            result = traceback.format_exc()
            error = 1
        logging.log(logging.DEBUG, result)

        self.write_message(json.dumps({'result': result, 'error': error,
                                       'id': json_rpc['id']},
                                      separators=(',', ':')))
1140132
def process_task(self):
        """"""
        pdu = RegisterForeignDevice(self.bbmdTimeToLive)
        pdu.pduDestination = self.bbmdAddress

        # send it downstream
        self.request(pdu)
621030
def process_data(self, block):
        """"""
        if hasattr(block, 'send_destinations') and block.send_destinations:
            self.fire(events.FileProcessed(block))
            self._log_in_db(block)
            if self._sent_log_file:
                self._log_in_sent_log(block)
            self.log.info("Sent to '%s' file '%s' containing files: %s",
                          str(block.send_destinations),
                          block.processed_data_file_info.basename,
                          str([file_info.path for file_info in block.content_file_infos]))
        else:
            self.log.info("File %s wasn't sent", block.processed_data_file_info.basename)
        return block
1367095
function( data ) {
   
            
            var read_buffer = read_buffers_by_connection[tcp_connection];
            read_buffer += data;

            //split by new lines, 
            var messages = read_buffer.split('\n');
            
            //last element is either a partial message, or ''            
            read_buffer = messages.pop();
        
            for ( var i = 0; i < messages.length; i++ ) {
                
                //TODO error handling
                var message = messages[i];
                var components = message.split( ' ' );
                var path = components[0];
                var value = components[1];
                var timestamp = components[2];
                
                that.emit(  path, value, timestamp );                
            }            
        }
464119
@Override
    public void processMessage() {
        if (overwrite)
            storage.setArray(key, payload);
        else if (!storage.arrayExists(key))
            storage.setArray(key, payload);
    }
12988
async def _process_msgs(self):
        
        while True:
            args = await self._msgq.get()
            _LOGGER.debug('Processing: %s %02x %s %s %s', args[0], args[1],
                          *[args[i].hex() for i in range(2, 5)])
            await self._process_msg(*args)
1311968
function BatchResponseCB (data) {
    switch (data.status ) {
        case -1: console.log (" SMS -%d- Fail to Send SMS", data.smsid);
            break;
        case -2: console.log (" SMS -%d- Timeout waiting acknowledgement", data.smsid);
            break;
        case 1: console.log (" SMS -%d- Message Sent", data.smsid);
            break;
        case 2: console.log (" SMS -%d- Acknowledgement=[%s]", data.smsid, data.msg.ack);
            break;
        default:
    }
    // quit except if we wait for ack [leave some time to DB to close operation]
    if (data.status === 0) {
        console.log ('Last SMS from batch processed');
        setTimeout(process.exit, 1000);
    }
}
18153
protected void handleParsedMessage() {

        InterChannelCallback cb = null;
        // use the read callback for early reads or temp messages requested
        // LI4335 - handle early reads too
        if (this.bEarlyReads || this.bTempResponsesUsed) {
            cb = getAppReadCallback();
        } else {
            cb = getAppWriteCallback();
        }
        VirtualConnection vc = null;
        do {
            this.numResponsesReceived++;
            if (!getResponseImpl().isTemporaryStatusCode()) {
                // a final response message was received
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Notifying app channel of final response.");
                }
                cb.complete(getVC());
                return;
            }

            // received a temporary response
            int code = getResponseImpl().getStatusCodeAsInt();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Received response (#" + numberResponsesReceived() + "): " + code);
            }
            if (numberResponsesReceived() > getHttpConfig().getLimitOnNumberOfResponses()) {
                // too many temp responses
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Too many async temp responses received.");
                }
                cb.error(getVC(), new IOException("Max temp responses received: " + numberResponsesReceived()));
                return;
            }
            if (this.bTempResponsesUsed) {
                // call the app channel with this new response
                cb.complete(getVC());
                return;
            }
            if (getRequestImpl().isExpect100Continue()) {
                if (100 != code) {
                    // if the Expectation failed, then this connection is finished, so
                    // no need to reset any values.
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Expect 100-continue failed with " + code);
                    }
                    setPersistent(false);
                    cb.error(getVC(), new ExpectationFailedException(code + " " + getResponseImpl().getReasonPhrase()));
                    return;
                } else if (1 == numberResponsesReceived() && isHeadersSentState()) {
                    // first 100-continue only, return to app channel immed but
                    // only if sendHeaders was used (meaning they want 100-continue)
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Notifying channel of first 100-continue");
                    }
                    cb.complete(getVC());
                    return;
                }
            }
            // otherwise, this was a valid temporary response but the app channel
            // doesn't want to see it
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Ignoring temporary response...");
            }
            resetRead();
            if (setupReadBuffers(getHttpConfig().getIncomingHdrBufferSize(), false)) {
                // data is already available
                vc = getVC();
            } else {
                // read for the next bit of data
                vc = getTSC().getReadInterface().read(1, HttpOSCReadCallback.getRef(), false, getReadTimeout());
            }
            if (null != vc) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Attempting a parse of response data.");
                }
                vc = parseResponseMessageAsync();
            }
        } while (null != vc);
    }
986942
def _handleSmsReceived(self, notificationLine):
        
        self.log.debug('SMS message received')
        cmtiMatch = self.CMTI_REGEX.match(notificationLine)
        if cmtiMatch:
            msgMemory = cmtiMatch.group(1)
            msgIndex = cmtiMatch.group(2)
            sms = self.readStoredSms(msgIndex, msgMemory)
            self.deleteStoredSms(msgIndex)
            self.smsReceivedCallback(sms)
1082851
def process_message_notification(request, messages_path):
    """"""
    if not messages_path:
        return

    global _MESSAGES_CACHE
    global _MESSAGES_MTIME

    # NOTE (lhcheng): Cache the processed messages to avoid parsing
    # the files every time. Check directory modification time if
    # reload is necessary.
    if (_MESSAGES_CACHE is None or
            _MESSAGES_MTIME != os.path.getmtime(messages_path)):
        _MESSAGES_CACHE = _get_processed_messages(messages_path)
        _MESSAGES_MTIME = os.path.getmtime(messages_path)

    for msg in _MESSAGES_CACHE:
        msg.send_message(request)
69351
def _flush_message_buffer(self):
        
        while True:
            message_bytes = self.transport.receive()

            # there were no messages receives, so break from the loop
            if message_bytes is None:
                break

            # check if the message is encrypted and decrypt if necessary
            if message_bytes[:4] == b"\xfdSMB":
                message = SMB2TransformHeader()
                message.unpack(message_bytes)
                message_bytes = self._decrypt(message)

            # now retrieve message(s) from response
            is_last = False
            session_id = None
            while not is_last:
                next_command = struct.unpack("<L", message_bytes[20:24])[0]
                header_length = \
                    next_command if next_command != 0 else len(message_bytes)
                header_bytes = message_bytes[:header_length]
                message = SMB2HeaderResponse()
                message.unpack(header_bytes)

                flags = message['flags']
                if not flags.has_flag(Smb2Flags.SMB2_FLAGS_RELATED_OPERATIONS):
                    session_id = message['session_id'].get_value()

                self._verify(message, session_id)
                message_id = message['message_id'].get_value()
                request = self.outstanding_requests.get(message_id, None)
                if not request:
                    error_msg = "Received response with an unknown message " \
                                "ID: %d" % message_id
                    raise smbprotocol.exceptions.SMBException(error_msg)

                # add the upper credit limit based on the credits granted by
                # the server
                credit_response = message['credit_response'].get_value()
                self.sequence_window['high'] += \
                    credit_response if credit_response > 0 else 1

                request.response = message
                self.outstanding_requests[message_id] = request

                message_bytes = message_bytes[header_length:]
                is_last = next_command == 0
1313228
public void handleIncomingMessage(byte[] data, int offset, int len) {
		synchronized(messageQueue) {
			messageQueue.add(new IncomingMessage(data, offset, len));
		}
		synchronized(lock) {
			lock.notifyAll();
		}
	}
492310
async def _receive_data_chunk(self, chunk):
        
        self._sack_needed = True

        # mark as received
        if self._mark_received(chunk.tsn):
            return

        # find stream
        inbound_stream = self._get_inbound_stream(chunk.stream_id)

        # defragment data
        inbound_stream.add_chunk(chunk)
        self._advertised_rwnd -= len(chunk.user_data)
        for message in inbound_stream.pop_messages():
            self._advertised_rwnd += len(message[2])
            await self._receive(*message)
789401
def process(data)
      bytes = StringIO.new(String(data)).each_byte
      bytes.each do |byte|
        case byte
        when REPORT_VERSION
          @major_version = bytes.next
          @minor_version = bytes.next

          emit('report_version')

        when ANALOG_MESSAGE_RANGE
          least_significant_byte = bytes.next
          most_significant_byte = bytes.next

          value = least_significant_byte | (most_significant_byte << 7)
          pin = byte & 0x0F

          if analog_pin = analog_pins[pin]
            pins[analog_pin].value = value

            emit('analog-read', pin, value)
            emit("analog-read-#{pin}", value)
          end

        when DIGITAL_MESSAGE_RANGE
          port           = byte & 0x0F
          first_bitmask  = bytes.next
          second_bitmask = bytes.next
          port_value     = first_bitmask | (second_bitmask << 7)

          8.times do |i|
            pin_number = 8 * port + i
            if pin = pins[pin_number] and pin.mode == INPUT
              value = (port_value >> (i & 0x07)) & 0x01
              pin.value = value
              emit('digital-read', pin_number, value)
              emit("digital-read-#{pin_number}", value)
            end
          end

        when START_SYSEX
          current_buffer = [byte]
          begin
            current_buffer.push(bytes.next)
          end until current_buffer.last == END_SYSEX

          command = current_buffer[1]

          case command
          when CAPABILITY_RESPONSE
            supported_modes = 0
            n = 0

            current_buffer.slice(2, current_buffer.length - 3).each do |byte|
              if byte == 127
                modes = []
                # the pin modes
                [ INPUT, OUTPUT, ANALOG, PWM, SERVO ].each do |mode|
                   modes.push(mode) unless (supported_modes & (1 << mode)).zero?
                end

                @pins.push(Pin.new(modes, OUTPUT, 0))

                supported_modes = 0
                n = 0
                next
              end

              supported_modes |= (1 << byte) if n.zero?

              n ^= 1
            end

            emit('capability_query')

          when ANALOG_MAPPING_RESPONSE
            pin_index = 0

            current_buffer.slice(2, current_buffer.length - 3).each do |byte|

              @pins[pin_index].analog_channel = byte

              @analog_pins.push(pin_index) unless byte == 127

              pin_index += 1
            end

            emit('analog_mapping_query')

          when PIN_STATE_RESPONSE
            pin       = pins[current_buffer[2]]
            pin.mode  = current_buffer[3]
            pin.value = current_buffer[4]

            pin.value |= (current_buffer[5] << 7) if current_buffer.size > 6

            pin.value |= (current_buffer[6] << 14) if current_buffer.size > 7

          when FIRMWARE_QUERY
            @firmware_name = current_buffer.slice(4, current_buffer.length - 5).reject { |b| b.zero? }.map(&:chr).join
            emit('firmware_query')

          else
            puts 'bad byte'
          end
        end
      end
    rescue StopIteration
      # do nadda
    end
335171
private void processSyncMessageChunk(CommsByteBuffer buffer, Conversation conversation,
                                        boolean connectionMessage)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "processSyncMessageChunk",
                                           new Object[]{buffer, conversation, connectionMessage});

      // First get the ConnectionProxy for this conversation
      ClientConversationState convState = (ClientConversationState) conversation.getAttachment();
      ConnectionProxy connProxy = (ConnectionProxy) convState.getSICoreConnection();
      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Found connection: ", connProxy);

      // Now read the connection object Id
      buffer.getShort();                                            // BIT16 ConnectionObjId
      if (connectionMessage)
      {
         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Adding message part directly to connection");
         connProxy.addMessagePart(buffer);
      }
      else
      {
         short consumerSessionId = buffer.getShort();               // BIT16 ConsumerSessionId
         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Consumer Session Id:", ""+consumerSessionId);

         // Now simply pass the message buffer off to the consumer
         ConsumerSessionProxy consumer = connProxy.getConsumerSessionProxy(consumerSessionId);
         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Found consumer:", consumer);
         consumer.addMessagePart(buffer);
      }

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "processSyncMessageChunk");
   }
672325
def split(self, text):
        """"""
        text = cleanup(text)
        return self.sent_detector.tokenize(text.strip())