View | Details | Raw Unified | Return to bug 54127
Collapse All | Expand All

(-)java/org/apache/catalina/websocket/WsOutbound.java (-1 / +25 lines)
Lines 25-30 Link Here
25
import org.apache.coyote.http11.upgrade.UpgradeOutbound;
25
import org.apache.coyote.http11.upgrade.UpgradeOutbound;
26
import org.apache.tomcat.util.buf.B2CConverter;
26
import org.apache.tomcat.util.buf.B2CConverter;
27
import org.apache.tomcat.util.res.StringManager;
27
import org.apache.tomcat.util.res.StringManager;
28
import org.apache.catalina.websocket.Constants;
28
29
29
/**
30
/**
30
 * Provides the means to write WebSocket messages to the client. All methods
31
 * Provides the means to write WebSocket messages to the client. All methods
Lines 301-306 Link Here
301
     * @throws IOException  If an error occurs writing to the client
302
     * @throws IOException  If an error occurs writing to the client
302
     */
303
     */
303
    public synchronized void pong(ByteBuffer data) throws IOException {
304
    public synchronized void pong(ByteBuffer data) throws IOException {
305
    	sendControlMessage(data, Constants.OPCODE_PONG);
306
    }
307
308
    /**
309
     * Send a ping message to the client
310
     *
311
     * @param data      Optional message.
312
     *
313
     * @throws IOException  If an error occurs writing to the client
314
     */
315
    public synchronized void ping(ByteBuffer data) throws IOException {
316
    	sendControlMessage(data, Constants.OPCODE_PING);
317
    }
318
    
319
    /**
320
     * Generic function to send either a ping or a pong.
321
     * 
322
     * @param data      Optional message.
323
     * @param opcode	The byte to include as the opcode.
324
     *
325
     * @throws IOException  If an error occurs writing to the client
326
     */
327
    private synchronized void sendControlMessage(ByteBuffer data, byte opcode) throws IOException {
304
328
305
        if (closed) {
329
        if (closed) {
306
            throw new IOException(sm.getString("outbound.closed"));
330
            throw new IOException(sm.getString("outbound.closed"));
Lines 308-314 Link Here
308
332
309
        doFlush(true);
333
        doFlush(true);
310
334
311
        upgradeOutbound.write(0x8A);
335
        upgradeOutbound.write(0x80 | opcode);
312
        if (data == null) {
336
        if (data == null) {
313
            upgradeOutbound.write(0);
337
            upgradeOutbound.write(0);
314
        } else {
338
        } else {

Return to bug 54127