{@inheritdoc}

@throws WebSocketException Invalid pong payload
434028
protected function handlePongFrame(NetworkFrame $frame)
    {
        if ($this->currentPingFrame === null) {
            $this->logger->warning("Got unsolicited pong packet from $this - ignoring");

            return;
        }

        if ($this->currentPingFrame->getPayload() !== $frame->getPayload()) {
            throw new WebSocketException("Invalid pong payload", DataFrame::CODE_PROTOCOL_ERROR);
        }

        $this->handler->onPong($this, $this->currentPingFrame);
        $this->currentPingFrame = null;
    }
803014
function pongIoDivHTML( divId, resourceURL, paramObj ) {
	log( "pong-io",  "divId="+divId+" resourceURL="+resourceURL );
	ioSense[ divId ] = new Array();
	if ( moduleConfig[ divId ] != null ) {
		pongIoRenderHTML( divId, resourceURL, paramObj, moduleConfig[ divId ] );
	} else {
		$.getJSON( 
			resourceURL+"/pong-io", 
			function( pmd ) {
				moduleConfig[ divId ] = pmd;
				pongIoRenderHTML( divId, resourceURL, paramObj, pmd );
			}
		);					
	}	
}
1292225
@Override
    public synchronized void update(ReceiveStreamEvent evt) {

        Participant participant = evt.getParticipant();    // could be null.
        ReceiveStream stream = evt.getReceiveStream();  // could be null.

        if (evt instanceof RemotePayloadChangeEvent) {
            LOGGER.severe("  - Received an RTP PayloadChangeEvent.");
            LOGGER.severe("Sorry, cannot handle payload change.");

        }
        else if (evt instanceof NewReceiveStreamEvent) {

            try {
                stream = evt.getReceiveStream();
                DataSource ds = stream.getDataSource();

                // Find out the formats.
                RTPControl ctl = (RTPControl) ds.getControl("javax.jmf.rtp.RTPControl");
                if (ctl != null) {
                    LOGGER.severe("  - Received new RTP stream: " + ctl.getFormat());
                }
                else
                    LOGGER.severe("  - Received new RTP stream");

                if (participant == null)
                    LOGGER.severe("      The sender of this stream had yet to be identified.");
                else {
                    LOGGER.severe("      The stream comes from: " + participant.getCNAME());
                }

                // create a player by passing datasource to the Media Manager
                Player p = javax.media.Manager.createPlayer(ds);
                if (p == null)
                    return;

                p.addControllerListener(this);
                p.realize();
                jingleMediaSession.mediaReceived(participant != null ? participant.getCNAME() : "");

                // Notify initialize() that a new stream had arrived.
                synchronized (dataSync) {
                    dataReceived = true;
                    dataSync.notifyAll();
                }

            }
            catch (Exception e) {
                LOGGER.severe("NewReceiveStreamEvent exception " + e.getMessage());
                return;
            }

        }
        else if (evt instanceof StreamMappedEvent) {

            if (stream != null && stream.getDataSource() != null) {
                DataSource ds = stream.getDataSource();
                // Find out the formats.
                RTPControl ctl = (RTPControl) ds.getControl("javax.jmf.rtp.RTPControl");
                LOGGER.severe("  - The previously unidentified stream ");
                if (ctl != null)
                    LOGGER.severe("      " + ctl.getFormat());
                LOGGER.severe("      had now been identified as sent by: " + participant.getCNAME());
            }
        }
        else if (evt instanceof ByeEvent) {

            LOGGER.severe("  - Got \"bye\" from: " + participant.getCNAME());

        }

    }
1015950
async def _handle_pong(self, message):
        
        pong = message.obj
        self._log.debug('Handling pong for message %d', pong.msg_id)
        state = self._pending_state.pop(pong.msg_id, None)
        if state:
            state.future.set_result(pong)
560766
private void callOnTextMessage(byte[] data)
    {
        if (mWebSocket.isDirectTextMessage())
        {
            mWebSocket.getListenerManager().callOnTextMessage(data);
            return;
        }

        try
        {
            // Interpret the byte array as a string.
            // OutOfMemoryError may happen when the size of data is too big.
            String message = Misc.toStringUTF8(data);

            // Call onTextMessage() method of the listeners.
            callOnTextMessage(message);
        }
        catch (Throwable t)
        {
            // Failed to convert payload data into a string.
            WebSocketException wse = new WebSocketException(
                WebSocketError.TEXT_MESSAGE_CONSTRUCTION_ERROR,
                "Failed to convert payload data into a string: " + t.getMessage(), t);

            // Notify the listeners that text message construction failed.
            callOnError(wse);
            callOnTextMessageError(wse, data);
        }
    }
1085751
private function setPayload($payload)
	{
		if ( (is_string($payload) && empty($payload)) || (is_array($payload) && count($payload) == 0) )
		{
			// Empty strings or arrays are not allowed
			throw new \InvalidArgumentException('Invalid payload for message. Payload was empty, but not null)');
		}
		else if (is_array($payload) || null === $payload)
		{
			if ( isset($payload['aps']) )
			{
				// Reserved key is used
				throw new \InvalidArgumentException('Invalid payload for message. Custom payload may not contain the reserved "aps" key.');
			}
			else
			{
				// This is okay, set as payload
				$this->payload = $payload;
			}
		}
		else
		{
			// Try to decode JSON string payload
			$payload = json_decode($payload, true);

			// Check if decoding the payload worked
			if (null === $payload) {
				throw new \InvalidArgumentException('Invalid payload for message. Payload was invalid JSON.');
			}

			// Set as payload
			$this->payload = $payload;
		}
	}
1012525
private function send($payload)
    {
        $msg = $payload."\r\n";
        $len = strlen($msg);
        while (true) {
            $written = @fwrite($this->streamSocket, $msg);
            if ($written === false) {
                throw new \Exception('Error sending data');
            }

            if ($written === 0) {
                throw new \Exception('Broken pipe or closed connection');
            }

            $len = ($len - $written);
            if ($len > 0) {
                $msg = substr($msg, (0 - $len));
            } else {
                break;
            }
        }

        if ($this->debug === true) {
            printf('>>>> %s', $msg);
        }
    }
1062909
def _handle_pong(self, ts, *args, **kwargs):
        
        log.info("BitfinexWSS.ping(): Ping received! (%ss)",
                 ts - self.ping_timer)
        self.ping_timer = None
1098825
public void sendPong(byte[] buf) {
        if (log.isTraceEnabled()) {
            log.trace("send pong: {}", buf);
        }
        // send pong
        send(Packet.build(buf, MessageType.PONG));
    }
1304132
private void validateMedia(JsonNode data) throws InvalidInputException {
    for (JsonNode node : data.findParents(INDEX)) {
      JsonNode text = node.path(TEXT);
      if (!text.isMissingNode() && (!text.isArray() || !text.get(0).isArray())) {
        throw new InvalidInputException(String.format("Invalid table payload: %s (index: %s)", text.asText(), node.get(INDEX)));
      }
    }
  }
75479
public static void echoFrame(final WebSocketChannel channel, final StreamSourceFrameChannel ws) throws IOException {

        final WebSocketFrameType type;
        switch (ws.getType()) {
            case PONG:
                // pong frames must be discarded
                ws.close();
                return;
            case PING:
                // if a ping is send the autobahn testsuite expects a PONG when echo back
                type = WebSocketFrameType.PONG;
                break;
            default:
                type = ws.getType();
                break;
        }
        final StreamSinkFrameChannel sink = channel.send(type);
        sink.setRsv(ws.getRsv());
        initiateTransfer(ws, sink, new ChannelListener<StreamSourceFrameChannel>() {
                    @Override
                    public void handleEvent(StreamSourceFrameChannel streamSourceFrameChannel) {
                        IoUtils.safeClose(streamSourceFrameChannel);
                    }
                }, new ChannelListener<StreamSinkFrameChannel>() {
                    @Override
                    public void handleEvent(StreamSinkFrameChannel streamSinkFrameChannel) {
                        try {
                            streamSinkFrameChannel.shutdownWrites();
                        } catch (IOException e) {
                            UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
                            IoUtils.safeClose(streamSinkFrameChannel, channel);
                            return;
                        }
                        try {
                            if (!streamSinkFrameChannel.flush()) {
                                streamSinkFrameChannel.getWriteSetter().set(ChannelListeners.flushingChannelListener(
                                        new ChannelListener<StreamSinkFrameChannel>() {
                                            @Override
                                            public void handleEvent(StreamSinkFrameChannel streamSinkFrameChannel) {
                                                streamSinkFrameChannel.getWriteSetter().set(null);
                                                IoUtils.safeClose(streamSinkFrameChannel);
                                                if (type == WebSocketFrameType.CLOSE) {
                                                    IoUtils.safeClose(channel);
                                                }
                                            }
                                        }, new ChannelExceptionHandler<StreamSinkFrameChannel>() {
                                            @Override
                                            public void handleException(StreamSinkFrameChannel streamSinkFrameChannel, IOException e) {

                                                UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
                                                IoUtils.safeClose(streamSinkFrameChannel, channel);

                                            }
                                        }
                                ));
                                streamSinkFrameChannel.resumeWrites();
                            } else {
                                if (type == WebSocketFrameType.CLOSE) {
                                    IoUtils.safeClose(channel);
                                }
                                streamSinkFrameChannel.getWriteSetter().set(null);
                                IoUtils.safeClose(streamSinkFrameChannel);
                            }
                        } catch (IOException e) {
                            UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
                            IoUtils.safeClose(streamSinkFrameChannel, channel);

                        }
                    }
                }, new ChannelExceptionHandler<StreamSourceFrameChannel>() {
                    @Override
                    public void handleException(StreamSourceFrameChannel streamSourceFrameChannel, IOException e) {
                        UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
                        IoUtils.safeClose(streamSourceFrameChannel, channel);
                    }
                }, new ChannelExceptionHandler<StreamSinkFrameChannel>() {
                    @Override
                    public void handleException(StreamSinkFrameChannel streamSinkFrameChannel, IOException e) {
                        UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
                        IoUtils.safeClose(streamSinkFrameChannel, channel);
                    }
                }, channel.getBufferPool()
        );

    }
918742
public static void send(final PacketOutputStream pos) {
    try {
      pos.startPacket(0);
      pos.write(Packet.COM_QUIT);
      pos.flush();
    } catch (IOException ioe) {
      //eat
    }
  }
1307302
function pongRss_UpdateData( divId, paramsObj ) {
  log( "PongRss", "pongRss_UpdateData ");
  
  var pmd = moduleConfig[ divId ] 
  if ( pmd.rssURLs ) {
    rssData[divId] = []

    for ( var i=0; i < pmd.rssURLs.length; i++  ) {
      log( "PongRss", pmd.rssURLs[i].url ) 
      rssCounter[divId]++

      $.ajax({
            type: 'GET',
            url: pmd.rssURLs[i].url,
            crossDomain: true,
            crossOrigin: true,
            cache: false,
            success: 
              function( rssXML  ) {
                if( $.trim( rssXML ) == "false" ) {
                  alert("Fail to recived data");
                }
                else {
                  pongRss_print( divId, rssXML )
                }  
              }
      }).always( 
        function() {
          rssCounter[divId]--
          log( "PongRss", "rssCounter[divId]="+rssCounter[divId])
          if ( rssCounter[divId] == 0 ) {
            pongRss_rssToHTML( divId ) 
          }
        }
      )
    }    
  }
  
  log( "PongRss", "pongRss_UpdateData end.");
}
740894
function PongMessage(arg, options) {
  Message.call(this, options);
  this.command = 'pong';
  $.checkArgument(
    _.isUndefined(arg) || (BufferUtil.isBuffer(arg) && arg.length === 8),
    'First argument is expected to be an 8 byte buffer'
  );
  this.nonce = arg || utils.getNonce();
}
1101839
function pongIOrenderSwitch( divId, ctx, def, dta ) {
	log( "pong-io", "pongIOrenderSwitch '"+def.id+"': "+JSON.stringify(dta) );
	ioSense[ divId ][ def.id ] = new Array();
	var x = parseInt( def.pos.x );
	var y = parseInt( def.pos.y );
	ctx.textAlign = "start";
	ctx.textBaseline = "middle";
	if ( def.values && def.values.length ) { 
		ctx.beginPath();
		ctx.strokeStyle = "#00F";
		ctx.fillStyle   = "#DDD";
		if ( def.lineCol ) { ctx.strokeStyle = def.lineCol; }
		if ( def.fillCol ) { ctx.fillStyle   = def.fillCol; }
		ctx.arc( x, y, 15, 0 ,2*Math.PI );
		ctx.stroke();		
		ctx.fill();
		ctx.beginPath();
		ctx.moveTo( x, y );
		var xx = x + 17
		if ( def.values.length == 2 ) {
			var yy = y - 8;
			textOut( divId, def, ctx, def.values[0], xx, yy );
			pongIOaddSwitchSense( divId, def.id, def.values[0], xx, yy );
			if ( dta && dta.value ) {
			  if ( def.values[0] == dta.value ) {
	        pongIOrenderSwitchLine( ctx, x+10, y-10, def );
			  }
			} else if ( def.defaultValue && def.defaultValue == def.values[0] ){ // first value is default
	       pongIOrenderSwitchLine( ctx, x+10, y-10, def );
			} 
			yy = y + 8;
			textOut( divId, def, ctx, def.values[1], xx, yy );
			pongIOaddSwitchSense( divId, def.id, def.values[1], xx, yy );
			if ( dta && dta.value ) {
			  if (def.values[1] == dta.value ) {
	        pongIOrenderSwitchLine( ctx, x+10, y+10, def );
			  }
			} else if ( def.defaultValue && def.defaultValue == def.values[1] ){ // second value is default
         pongIOrenderSwitchLine( ctx, x+10, y+10, def );
      } 
		} else if ( def.values.length == 3 ) {
			var yy = y - 12;
			textOut( divId, def, ctx, def.values[0], xx, yy );
			pongIOaddSwitchSense( divId, def.id, def.values[0], xx, yy );
			if ( dta && dta.value ) {
        if ( def.values[0] == dta.value ) {
          pongIOrenderSwitchLine( ctx, x+10, y-10, def );
        }
      } else if ( def.defaultValue && def.defaultValue == def.values[0] ){ // first value is default
        pongIOrenderSwitchLine( ctx, x+10, y-10, def );        
      }
			yy = y;
			textOut( divId, def, ctx, def.values[1], xx, yy );
			pongIOaddSwitchSense( divId, def.id, def.values[1], xx, yy );
			if ( dta && dta.value ) {
        if ( def.values[1] == dta.value ) {
          pongIOrenderSwitchLine( ctx, x+15, y, def );
        } 
			} else if ( def.defaultValue && def.defaultValue == def.values[1] ){ // second value is default
        pongIOrenderSwitchLine( ctx, x+15, y, def );			  
			}
			yy = y + 12;
			textOut( divId, def, ctx, def.values[2], xx, yy );
			pongIOaddSwitchSense( divId, def.id, def.values[2], xx, yy );
			if ( dta && dta.value ) {
        if ( def.values[2] == dta.value ) {
          pongIOrenderSwitchLine( ctx, x+10, y+10, def );
        }
			} else if ( def.defaultValue && def.defaultValue == def.values[1] ){ // second value is default
        pongIOrenderSwitchLine( ctx, x+10, y+10, def );
			}
		}
	}
	
	log( "pong-io", "pongIOrenderSwitch end.");
}
36174
private WebSocketInputStream openInputStream(Socket socket) throws WebSocketException
    {
        try
        {
            // Get the input stream of the raw socket through which
            // this client receives data from the server.
            return new WebSocketInputStream(
                new BufferedInputStream(socket.getInputStream()));
        }
        catch (IOException e)
        {
            // Failed to get the input stream of the raw socket.
            throw new WebSocketException(
                WebSocketError.SOCKET_INPUT_STREAM_FAILURE,
                "Failed to get the input stream of the raw socket: " + e.getMessage(), e);
        }
    }
1345869
@Override
    public void send(PayloadData payloadData) throws Exception {
        if (logger.isDebugEnabled()) {
            logger.debug(String.format("Tx : Ass=%s %s", this.getName(), payloadData));
        }

        NettySctpChannelInboundHandlerAdapter handler = checkSocketIsOpen();

        final ByteBuf byteBuf = payloadData.getByteBuf();
        if (this.ipChannelType == IpChannelType.SCTP) {
            SctpMessage sctpMessage = new SctpMessage(payloadData.getPayloadProtocolId(), payloadData.getStreamNumber(),
                    payloadData.isUnordered(), byteBuf);
            handler.writeAndFlush(sctpMessage);
        } else {
            handler.writeAndFlush(byteBuf);
        }
    }