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


Java Channels.fireMessageReceived方法代码示例

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


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

示例1: messageReceived

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
    throws Exception {
  ChannelBuffer buf = (ChannelBuffer) e.getMessage();
  ByteBuffer b = buf.toByteBuffer().asReadOnlyBuffer();
  XDR in = new XDR(b, XDR.State.READING);

  RpcInfo info = null;
  try {
    RpcCall callHeader = RpcCall.read(in);
    ChannelBuffer dataBuffer = ChannelBuffers.wrappedBuffer(in.buffer()
        .slice());
    info = new RpcInfo(callHeader, dataBuffer, ctx, e.getChannel(),
        e.getRemoteAddress());
  } catch (Exception exc) {
    LOG.info("Malformed RPC request from " + e.getRemoteAddress());
  }

  if (info != null) {
    Channels.fireMessageReceived(ctx, info);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:RpcUtil.java

示例2: handleUpstream

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
@Override
public void handleUpstream(
        ChannelHandlerContext ctx, ChannelEvent evt) throws Exception {
    if (!(evt instanceof MessageEvent)) {
        ctx.sendUpstream(evt);
        return;
    }

    MessageEvent e = (MessageEvent) evt;
    Object originalMessage = e.getMessage();
    Object decodedMessage = decode(e.getChannel(), e.getRemoteAddress(), originalMessage);
    onMessageEvent(e.getChannel(), e.getRemoteAddress(), originalMessage, decodedMessage);
    if (originalMessage == decodedMessage) {
        ctx.sendUpstream(evt);
    } else {
        if (decodedMessage == null) {
            decodedMessage = handleEmptyMessage(e.getChannel(), e.getRemoteAddress(), originalMessage);
        }
        if (decodedMessage != null) {
            if (decodedMessage instanceof Collection) {
                for (Object o : (Collection) decodedMessage) {
                    saveOriginal(o, originalMessage);
                    Channels.fireMessageReceived(ctx, o, e.getRemoteAddress());
                }
            } else {
                saveOriginal(decodedMessage, originalMessage);
                Channels.fireMessageReceived(ctx, decodedMessage, e.getRemoteAddress());
            }
        }
    }
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:32,代码来源:ExtendedObjectDecoder.java

示例3: messageReceived

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    this.cumulation = new ArrayList<WebSocketFrame>();
    super.messageReceived(ctx, e);
    // batch FireMessageReceived
    if (this.cumulation.size() > 0) {
        Channels.fireMessageReceived(ctx, cumulation, e.getRemoteAddress());
    }
}
 
开发者ID:kuiwang,项目名称:my-dev,代码行数:10,代码来源:CustomWebSocket13FrameDecoder.java

示例4: handleIncr

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
protected void handleIncr(ChannelHandlerContext channelHandlerContext, CommandMessage<CACHE_ELEMENT> command,
		Channel channel) throws DatabaseException, Exception {
	Integer incrDecrResp = cache.get_add(command.keys.get(0), command.incrAmount); // TODO
	// support
	// default
	// value
	// and
	// expiry!!
	Channels.fireMessageReceived(channelHandlerContext, new ResponseMessage(command)
			.withIncrDecrResponse(incrDecrResp), channel.getRemoteAddress());
}
 
开发者ID:sunli1223,项目名称:fqueue,代码行数:12,代码来源:MemcachedCommandHandler.java

示例5: handlePrepend

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
protected void handlePrepend(ChannelHandlerContext channelHandlerContext, CommandMessage<CACHE_ELEMENT> command,
		Channel channel) throws DatabaseException, Exception {
	Cache.StoreResponse ret;
	ret = cache.prepend(command.element);
	Channels.fireMessageReceived(channelHandlerContext, new ResponseMessage(command).withResponse(ret), channel
			.getRemoteAddress());
}
 
开发者ID:sunli1223,项目名称:fqueue,代码行数:8,代码来源:MemcachedCommandHandler.java

示例6: handleReplace

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
protected void handleReplace(ChannelHandlerContext channelHandlerContext, CommandMessage<CACHE_ELEMENT> command,
		Channel channel) throws DatabaseException, Exception {
	Cache.StoreResponse ret;
	ret = cache.replace(command.element);
	Channels.fireMessageReceived(channelHandlerContext, new ResponseMessage(command).withResponse(ret), channel
			.getRemoteAddress());
}
 
开发者ID:sunli1223,项目名称:fqueue,代码行数:8,代码来源:MemcachedCommandHandler.java

示例7: handleAdd

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
protected void handleAdd(ChannelHandlerContext channelHandlerContext, CommandMessage<CACHE_ELEMENT> command,
		Channel channel) throws DatabaseException, Exception {
	Cache.StoreResponse ret;
	ret = cache.add(command.element);
	Channels.fireMessageReceived(channelHandlerContext, new ResponseMessage(command).withResponse(ret), channel
			.getRemoteAddress());
}
 
开发者ID:sunli1223,项目名称:fqueue,代码行数:8,代码来源:MemcachedCommandHandler.java

示例8: handleCas

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
protected void handleCas(ChannelHandlerContext channelHandlerContext, CommandMessage<CACHE_ELEMENT> command,
		Channel channel) throws DatabaseException, Exception {
	Cache.StoreResponse ret;
	ret = cache.cas(command.cas_key, command.element);
	Channels.fireMessageReceived(channelHandlerContext, new ResponseMessage(command).withResponse(ret), channel
			.getRemoteAddress());
}
 
开发者ID:sunli1223,项目名称:fqueue,代码行数:8,代码来源:MemcachedCommandHandler.java

示例9: handleSet

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
protected void handleSet(ChannelHandlerContext channelHandlerContext, CommandMessage<CACHE_ELEMENT> command,
		Channel channel) throws DatabaseException, Exception {
	Cache.StoreResponse ret;
	ret = cache.set(command.element);
	Channels.fireMessageReceived(channelHandlerContext, new ResponseMessage(command).withResponse(ret), channel
			.getRemoteAddress());
}
 
开发者ID:sunli1223,项目名称:fqueue,代码行数:8,代码来源:MemcachedCommandHandler.java

示例10: messageReceived

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent event) throws Exception {
    Object o = event.getMessage();
    if (! (o instanceof ChannelBuffer)) {
        ctx.sendUpstream(event);
        return;
    }

    ChannelBuffer input = (ChannelBuffer) o;
    int readable = input.readableBytes();
    if (readable <= 0) {
        return;
    }

    com.alibaba.dubbo.remoting.buffer.ChannelBuffer message;
    if (buffer.readable()) {
        if (buffer instanceof DynamicChannelBuffer) {
            buffer.writeBytes(input.toByteBuffer());
            message = buffer;
        } else {
            int size = buffer.readableBytes() + input.readableBytes();
            message = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.dynamicBuffer(
                size > bufferSize ? size : bufferSize);
            message.writeBytes(buffer, buffer.readableBytes());
            message.writeBytes(input.toByteBuffer());
        }
    } else {
        message = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.wrappedBuffer(
            input.toByteBuffer());
    }

    NettyChannel channel = NettyChannel.getOrAddChannel(ctx.getChannel(), url, handler);
    Object msg;
    int saveReaderIndex;

    try {
        // decode object.
        do {
            saveReaderIndex = message.readerIndex();
            try {
                msg = codec.decode(channel, message);
            } catch (IOException e) {
                buffer = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.EMPTY_BUFFER;
                throw e;
            }
            if (msg == Codec2.DecodeResult.NEED_MORE_INPUT) {
                message.readerIndex(saveReaderIndex);
                break;
            } else {
                if (saveReaderIndex == message.readerIndex()) {
                    buffer = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.EMPTY_BUFFER;
                    throw new IOException("Decode without read data.");
                }
                if (msg != null) {
                    Channels.fireMessageReceived(ctx, msg, event.getRemoteAddress());
                }
            }
        } while (message.readable());
    } finally {
        if (message.readable()) {
            message.discardReadBytes();
            buffer = message;
        } else {
            buffer = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.EMPTY_BUFFER;
        }
        NettyChannel.removeChannelIfDisconnected(ctx.getChannel());
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:69,代码来源:NettyCodecAdapter.java

示例11: handleUpstream

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
@Override
public void handleUpstream(final ChannelHandlerContext ctx, ChannelEvent evt) throws Exception {
    if (!(evt instanceof MessageEvent)) {
        ctx.sendUpstream(evt);
        return;
    }

    final MessageEvent event = (MessageEvent) evt;
    Object message = event.getMessage();
    if (message instanceof Position) {
        final Position position = (Position) message;
        if ((position.getOutdated() || processInvalidPositions && !position.getValid())
                && position.getNetwork() != null) {
            Context.getStatisticsManager().registerGeolocationRequest();

            geolocationProvider.getLocation(position.getNetwork(),
                    new GeolocationProvider.LocationProviderCallback() {
                @Override
                public void onSuccess(double latitude, double longitude, double accuracy) {
                    position.set(Position.KEY_APPROXIMATE, true);
                    position.setValid(true);
                    position.setFixTime(position.getDeviceTime());
                    position.setLatitude(latitude);
                    position.setLongitude(longitude);
                    position.setAccuracy(accuracy);
                    position.setAltitude(0);
                    position.setSpeed(0);
                    position.setCourse(0);
                    position.set(Position.KEY_RSSI, 0);
                    Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
                }

                @Override
                public void onFailure(Throwable e) {
                    Log.warning(e);
                    Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
                }
            });
        } else {
            Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
        }
    } else {
        Channels.fireMessageReceived(ctx, message, event.getRemoteAddress());
    }
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:46,代码来源:GeolocationHandler.java

示例12: handleUpstream

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
@Override
public void handleUpstream(final ChannelHandlerContext ctx, ChannelEvent evt) throws Exception {
    if (!(evt instanceof MessageEvent)) {
        ctx.sendUpstream(evt);
        return;
    }

    final MessageEvent event = (MessageEvent) evt;
    Object message = event.getMessage();
    if (message instanceof Position) {
        final Position position = (Position) message;
        if (processInvalidPositions || position.getValid()) {
            if (geocoderReuseDistance != 0) {
                Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId());
                if (lastPosition != null && lastPosition.getAddress() != null
                        && position.getDouble(Position.KEY_DISTANCE) <= geocoderReuseDistance) {
                    position.setAddress(lastPosition.getAddress());
                    Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
                    return;
                }
            }

            Context.getStatisticsManager().registerGeocoderRequest();

            geocoder.getAddress(addressFormat, position.getLatitude(), position.getLongitude(),
                    new Geocoder.ReverseGeocoderCallback() {
                @Override
                public void onSuccess(String address) {
                    position.setAddress(address);
                    Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
                }

                @Override
                public void onFailure(Throwable e) {
                    Log.warning("Geocoding failed", e);
                    Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
                }
            });
        } else {
            Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
        }
    } else {
        Channels.fireMessageReceived(ctx, message, event.getRemoteAddress());
    }
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:46,代码来源:GeocoderHandler.java

示例13: sendRpcResponse

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
public static void sendRpcResponse(ChannelHandlerContext ctx,
    RpcResponse response) {
  Channels.fireMessageReceived(ctx, response);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:RpcUtil.java

示例14: messageReceived

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent event) throws Exception {
    Object o = event.getMessage();
    if (! (o instanceof ChannelBuffer)) {
        ctx.sendUpstream(event);
        return;
    }
    
    // FIXME 获取netty的channel  add by jileng
    ChannelBuffer input = (ChannelBuffer) o;
    int readable = input.readableBytes();
    if (readable <= 0) {
        return;
    }

    com.alibaba.dubbo.remoting.buffer.ChannelBuffer message;
    if (buffer.readable()) {
        if (buffer instanceof DynamicChannelBuffer) {
            //FIXME  读取netty buf的数据到 com.alibaba.dubbo.remoting.buffer.ChannelBuffer  add by jileng
            buffer.writeBytes(input.toByteBuffer());
            message = buffer;
        } else {
            int size = buffer.readableBytes() + input.readableBytes();
            message = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.dynamicBuffer(
                size > bufferSize ? size : bufferSize);
            message.writeBytes(buffer, buffer.readableBytes());
            message.writeBytes(input.toByteBuffer());
        }
    } else {
        message = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.wrappedBuffer(
            input.toByteBuffer());
    }

    NettyChannel channel = NettyChannel.getOrAddChannel(ctx.getChannel(), url, handler);
    Object msg;
    int saveReaderIndex;

    try {
        // decode object.
        do {
            saveReaderIndex = message.readerIndex();
            try {
                msg = codec.decode(channel, message);
            } catch (IOException e) {
                buffer = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.EMPTY_BUFFER;
                throw e;
            }
            if (msg == Codec2.DecodeResult.NEED_MORE_INPUT) {
                message.readerIndex(saveReaderIndex);
                break;
            } else {
                if (saveReaderIndex == message.readerIndex()) {
                    buffer = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.EMPTY_BUFFER;
                    throw new IOException("Decode without read data.");
                }
                //FIXME 一个完整的consumer消息已经接收完成   add by jileng
                if (msg != null) {
                    //FIXME fireMessageReceived => NettyHandler中的messageReceived()被触发  add by jileng
                    Channels.fireMessageReceived(ctx, msg, event.getRemoteAddress());
                }
            }
        } while (message.readable());
    } finally {
        if (message.readable()) {
            message.discardReadBytes();
            buffer = message;
        } else {
            buffer = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.EMPTY_BUFFER;
        }
        NettyChannel.removeChannelIfDisconnected(ctx.getChannel());
    }
}
 
开发者ID:spccold,项目名称:dubbo-comments,代码行数:73,代码来源:NettyCodecAdapter.java

示例15: fireMessageReceived

import org.jboss.netty.channel.Channels; //导入方法依赖的package包/类
private void fireMessageReceived(ChannelHandlerContext context, SocketAddress remoteAddress, Object result) {
  Channels.fireMessageReceived(context, result, remoteAddress);
}
 
开发者ID:leeyazhou,项目名称:nfs-rpc,代码行数:4,代码来源:NettyProtocolDecoder.java


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