当前位置: 首页>>代码示例>>Java>>正文


Java TextWebSocketFrame.text方法代码示例

本文整理汇总了Java中io.netty.handler.codec.http.websocketx.TextWebSocketFrame.text方法的典型用法代码示例。如果您正苦于以下问题:Java TextWebSocketFrame.text方法的具体用法?Java TextWebSocketFrame.text怎么用?Java TextWebSocketFrame.text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.handler.codec.http.websocketx.TextWebSocketFrame的用法示例。


在下文中一共展示了TextWebSocketFrame.text方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: receivedTextWebSocketFrame

import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; //导入方法依赖的package包/类
void receivedTextWebSocketFrame(TextWebSocketFrame textWebSocketFrame) {
    try {
        Object deserializedMessage = webSocketMessageSerializer.deserialize(textWebSocketFrame.text());
        if (deserializedMessage instanceof HttpResponse) {
            HttpResponse httpResponse = (HttpResponse) deserializedMessage;
            String firstHeader = httpResponse.getFirstHeader(WEB_SOCKET_CORRELATION_ID_HEADER_NAME);
            WebSocketResponseCallback webSocketResponseCallback = callbackResponseRegistry.get(firstHeader);
            if (webSocketResponseCallback != null) {
                webSocketResponseCallback.handle(httpResponse);
            }
        } else if (deserializedMessage instanceof HttpRequest) {
            HttpRequest httpRequest = (HttpRequest) deserializedMessage;
            WebSocketRequestCallback webSocketRequestCallback = callbackForwardRegistry.get(httpRequest.getFirstHeader(WEB_SOCKET_CORRELATION_ID_HEADER_NAME));
            if (webSocketRequestCallback != null) {
                webSocketRequestCallback.handle(httpRequest);
            }
        } else {
            throw new WebSocketException("Unsupported web socket message " + deserializedMessage);
        }
    } catch (Exception e) {
        throw new WebSocketException("Exception while receiving web socket message" + textWebSocketFrame.text(), e);
    }
}
 
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:24,代码来源:WebSocketClientRegistry.java

示例2: channelRead0

import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext arg0, TextWebSocketFrame in) throws Exception {
	
	if( logger.isDebugEnabled() ) {
		logger.debug("[CHANNEL READ0] channel active=" + arg0.channel().isActive() + ", open=" + arg0.channel().isOpen());
	}
	
	final String cm = in.text();
	Platform.runLater( () -> receivingMessageModel.set(cm) );
}
 
开发者ID:bekwam,项目名称:examples-javafx-repos1,代码行数:11,代码来源:EchoClientHandlerWS.java

示例3: decode

import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, TextWebSocketFrame msg, List<Object> out) throws Exception {
    String json = msg.text();

    if (DEBUG) {
        System.out.println(json);
    }

    try {
        out.add(messageReader.readValue(json));
    } catch (IllegalArgumentException e) {
        // TODO just warn if decoded type is not implement yet
        ctx.fireExceptionCaught(e);
    }
}
 
开发者ID:h4ssi,项目名称:mmo-client,代码行数:16,代码来源:ServerConnection.java

示例4: channelRead0

import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; //导入方法依赖的package包/类
@Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
    Channel ch = ctx.channel();
    if (!handshaker.isHandshakeComplete()) {
        handshaker.finishHandshake(ch, (FullHttpResponse) msg);
        logger.debug("WebSocket Client connected!");
        handshakeFuture.setSuccess();
        return;
    }

    if (msg instanceof FullHttpResponse) {
        FullHttpResponse response = (FullHttpResponse) msg;
        throw new IllegalStateException(
                "Unexpected FullHttpResponse (getStatus=" + response.status() +
                ", content=" + response.content().toString(CharsetUtil.UTF_8) + ')');
    }

    WebSocketFrame frame = (WebSocketFrame) msg;
    if (frame instanceof TextWebSocketFrame) {
        TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
        logger.debug("WebSocket Client received text message: " + textFrame.text());
        textReceived = textFrame.text();
    } else if (frame instanceof BinaryWebSocketFrame) {
        BinaryWebSocketFrame binaryFrame = (BinaryWebSocketFrame) frame;
        bufferReceived = binaryFrame.content().nioBuffer();
        logger.debug("WebSocket Client received  binary message: " + bufferReceived.toString());
    } else if (frame instanceof PongWebSocketFrame) {
        logger.debug("WebSocket Client received pong");
        PongWebSocketFrame pongFrame = (PongWebSocketFrame) frame;
        bufferReceived = pongFrame.content().nioBuffer();
    } else if (frame instanceof CloseWebSocketFrame) {
        logger.debug("WebSocket Client received closing");
        ch.close();
    }
}
 
开发者ID:wso2,项目名称:msf4j,代码行数:36,代码来源:WebSocketClientHandler.java

示例5: notifyTextMessage

import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; //导入方法依赖的package包/类
private void notifyTextMessage(TextWebSocketFrame textWebSocketFrame) throws ServerConnectorException {
    String text = textWebSocketFrame.text();
    boolean isFinalFragment = textWebSocketFrame.isFinalFragment();
    WebSocketMessageImpl webSocketTextMessage =
            new WebSocketTextMessageImpl(text, isFinalFragment);
    webSocketTextMessage = setupCommonProperties(webSocketTextMessage);
    connectorFuture.notifyWSListener((WebSocketTextMessage) webSocketTextMessage);
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:9,代码来源:WebSocketSourceHandler.java

示例6: notifyTextMessage

import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; //导入方法依赖的package包/类
private void notifyTextMessage(TextWebSocketFrame textWebSocketFrame, ChannelHandlerContext ctx)
        throws ServerConnectorException {
    String text = textWebSocketFrame.text();
    boolean isFinalFragment = textWebSocketFrame.isFinalFragment();
    WebSocketMessageImpl webSocketTextMessage =
            new WebSocketTextMessageImpl(text, isFinalFragment);
    webSocketTextMessage = setupCommonProperties(webSocketTextMessage, ctx);
    connectorListener.onMessage((WebSocketTextMessage) webSocketTextMessage);
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:10,代码来源:WebSocketTargetHandler.java

示例7: handleWebSocketFrame

import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; //导入方法依赖的package包/类
private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {

        // Check for closing frame
        if (frame instanceof CloseWebSocketFrame) {
            handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
            return;
        }
        if (frame instanceof PingWebSocketFrame) {
            ctx.channel().write(new PongWebSocketFrame(frame.content().retain()));
            return;
        }
        if (!(frame instanceof TextWebSocketFrame)) {
            throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass()
                    .getName()));
        }

        // Send the uppercase string back.
        TextWebSocketFrame frame2 = (TextWebSocketFrame) frame;
        
        String request = frame2.text();
                

        Thread t = Thread.currentThread();
        System.err.printf("%s received %s%n thread %d ", ctx.channel(), request, t.getId());        
       
        
        
        ///////////////////
        //Do your work here
        ///////////////////

        
        ctx.channel().write(new TextWebSocketFrame(request.toUpperCase()));
        
    }
 
开发者ID:oci-pronghorn,项目名称:NettyStages,代码行数:36,代码来源:WebSocketServerHandler.java

示例8: channelRead0

import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; //导入方法依赖的package包/类
@Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
    Channel ch = ctx.channel();
    if (!handshaker.isHandshakeComplete()) {
        handshaker.finishHandshake(ch, (FullHttpResponse) msg);
        if (logger.isDebugEnabled()) {
            logger.debug("WebSocket Client connected!");
        }
        handshakeFuture.setSuccess();
        return;
    }

    if (msg instanceof FullHttpResponse) {
        FullHttpResponse response = (FullHttpResponse) msg;
        throw new IllegalStateException(
                "Unexpected FullHttpResponse (getStatus=" + response.status() +
                        ", content=" + response.content().toString(CharsetUtil.UTF_8) + ')');
    }

    WebSocketFrame frame = (WebSocketFrame) msg;
    if (frame instanceof TextWebSocketFrame) {
        TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
        if (logger.isDebugEnabled()) {
            logger.debug("WebSocket Client received text message: " + textFrame.text());
        }
        textReceived = textFrame.text();
    } else if (frame instanceof BinaryWebSocketFrame) {
        BinaryWebSocketFrame binaryFrame = (BinaryWebSocketFrame) frame;
        bufferReceived = binaryFrame.content().nioBuffer();
        if (logger.isDebugEnabled()) {
            logger.debug("WebSocket Client received  binary message: " + bufferReceived.toString());
        }
    } else if (frame instanceof PongWebSocketFrame) {
        if (logger.isDebugEnabled()) {
            logger.debug("WebSocket Client received pong");
        }
        PongWebSocketFrame pongFrame = (PongWebSocketFrame) frame;
        bufferReceived = pongFrame.content().nioBuffer();
    } else if (frame instanceof CloseWebSocketFrame) {
        if (logger.isDebugEnabled()) {
            logger.debug("WebSocket Client received closing");
        }
        isOpen = false;
    }
    countDownLatch();
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:47,代码来源:WebSocketClientHandler.java

示例9: channelRead0

import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; //导入方法依赖的package包/类
@Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
    Channel ch = ctx.channel();
    if (!handshaker.isHandshakeComplete()) {
        handshaker.finishHandshake(ch, (FullHttpResponse) msg);
        logger.debug("WebSocket Client connected!");
        handshakeFuture.setSuccess();
        return;
    }

    if (msg instanceof FullHttpResponse) {
        FullHttpResponse response = (FullHttpResponse) msg;
        throw new IllegalStateException(
                "Unexpected FullHttpResponse (getStatus=" + response.status() +
                        ", content=" + response.content().toString(CharsetUtil.UTF_8) + ')');
    }

    WebSocketFrame frame = (WebSocketFrame) msg;
    if (frame instanceof TextWebSocketFrame) {
        TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
        logger.debug("WebSocket Client received text message: " + textFrame.text());
        textReceived = textFrame.text();
    } else if (frame instanceof BinaryWebSocketFrame) {
        BinaryWebSocketFrame binaryFrame = (BinaryWebSocketFrame) frame;
        bufferReceived = binaryFrame.content().nioBuffer();
        logger.debug("WebSocket Client received  binary message: " + bufferReceived.toString());
    } else if (frame instanceof PingWebSocketFrame) {
        logger.debug("WebSocket Client received pong");
        PingWebSocketFrame pingFrame = (PingWebSocketFrame) frame;
        isPingReceived = true;
        bufferReceived = pingFrame.content().nioBuffer();
    } else if (frame instanceof PongWebSocketFrame) {
        logger.debug("WebSocket Client received pong");
        PongWebSocketFrame pongFrame = (PongWebSocketFrame) frame;
        isPongReceived = true;
        bufferReceived = pongFrame.content().nioBuffer();
    } else if (frame instanceof CloseWebSocketFrame) {
        logger.debug("WebSocket Client received closing");
        isOpen = false;
    }
    countDownLatch();
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:43,代码来源:WebSocketClientHandler.java

示例10: channelRead0

import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame frame) throws Exception {
    String request = frame.text();
    ctx.channel().writeAndFlush(new TextWebSocketFrame(request.toUpperCase()));
}
 
开发者ID:kyle-liu,项目名称:netty4study,代码行数:6,代码来源:CustomTextFrameHandler.java

示例11: messageReceived

import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; //导入方法依赖的package包/类
@Override
protected void messageReceived(ChannelHandlerContext ctx, TextWebSocketFrame frame) throws Exception {
    String request = frame.text();
    ctx.channel().writeAndFlush(new TextWebSocketFrame(request.toUpperCase()));
}
 
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:6,代码来源:CustomTextFrameHandler.java


注:本文中的io.netty.handler.codec.http.websocketx.TextWebSocketFrame.text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。