wsky / top-link

embedded duplex multi-channel endpoint and connection management for c#/java/...
6 stars 1 forks source link

RemotingClientChannelHandler integer duplicate at server, and response not write #13

Closed wsky closed 11 years ago

wsky commented 11 years ago

currently one identity AtomicInteger per handler, but only have one serverhandler, flag will confused between RemotingClientChannelHandler

public ByteBuffer pending(ClientChannel channel, RemotingCallback handler) throws ChannelException {
        int flag = this.identity.incrementAndGet();
        ByteBuffer buffer = BufferManager.getBuffer();
        buffer.putInt(flag);

        handler.flag = flag + "";
        this.callbacks.put(handler.flag, handler);// concurrent?
        this.logger.debug("sending request of rpc-call#%s", flag);

        return buffer;
    }
wsky commented 11 years ago

channel will be reused, so we can only have one ChannelHandler per channel

public static DynamicProxy connect(URI uri) throws ChannelException {
        ClientChannel channel = selectHandler.getClientChannel(uri);
        RemotingClientChannelHandler channelHandler = new RemotingClientChannelHandler(
                loggerFactory.create("RemotingClientChannelHandler-" + uri));
        channel.setChannelHandler(channelHandler);
        return new DynamicProxy(channel, channelHandler);
    }

channel in use will get unexpect handler!