當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。