• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java WritableCallback类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.koushikdutta.async.callback.WritableCallback的典型用法代码示例。如果您正苦于以下问题:Java WritableCallback类的具体用法?Java WritableCallback怎么用?Java WritableCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WritableCallback类属于com.koushikdutta.async.callback包,在下文中一共展示了WritableCallback类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: AsyncSSLSocketWrapper

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
private AsyncSSLSocketWrapper(AsyncSocket socket,
                              String host, int port,
                              SSLEngine sslEngine,
                              TrustManager[] trustManagers, HostnameVerifier verifier, boolean clientMode) {
    mSocket = socket;
    hostnameVerifier = verifier;
    this.clientMode = clientMode;
    this.trustManagers = trustManagers;
    this.engine = sslEngine;
    engine.setEnabledProtocols(new String[] { "SSLv3" });
    mHost = host;
    mPort = port;
    engine.setUseClientMode(clientMode);
    mSink = new BufferedDataSink(socket);
    mSink.setWriteableCallback(new WritableCallback() {
        @Override
        public void onWriteable() {
            if (mWriteableCallback != null)
                mWriteableCallback.onWriteable();
        }
    });

    // on pause, the emitter is paused to prevent the buffered
    // socket and itself from firing.
    // on resume, emitter is resumed, ssl buffer is flushed as well
    mSocket.setEndCallback(new CompletedCallback() {
        @Override
        public void onCompleted(Exception ex) {
            if (mEnded)
                return;
            mEnded = true;
            mEndException = ex;
            if (!pending.hasRemaining() && mEndCallback != null)
                mEndCallback.onCompleted(ex);
        }
    });

    mSocket.setDataCallback(dataCallback);
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:40,代码来源:AsyncSSLSocketWrapper.java


示例2: setWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public void setWriteableCallback(WritableCallback handler) {
    if (mSink != null)
        mSink.setWriteableCallback(handler);
    else
        writable = handler;
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:8,代码来源:AsyncHttpServerResponseImpl.java


示例3: writeAll

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
public static void writeAll(final DataSink sink, final ByteBufferList bb, final CompletedCallback callback) {
    WritableCallback wc;
    sink.setWriteableCallback(wc = new WritableCallback() {
        @Override
        public void onWriteable() {
            sink.write(bb);
            if (bb.remaining() == 0 && callback != null) {
                sink.setWriteableCallback(null);
                callback.onCompleted(null);
            }
        }
    });
    wc.onWriteable();
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:15,代码来源:Util.java


示例4: setDataSink

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
public void setDataSink(DataSink datasink) {
    mDataSink = datasink;
    mDataSink.setWriteableCallback(new WritableCallback() {
        @Override
        public void onWriteable() {
            writePending();
        }
    });
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:10,代码来源:BufferedDataSink.java


示例5: AsyncSSLSocketWrapper

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
private AsyncSSLSocketWrapper(AsyncSocket socket,
                              String host, int port,
                              SSLEngine sslEngine,
                              TrustManager[] trustManagers, HostnameVerifier verifier, boolean clientMode) {
    mSocket = socket;
    hostnameVerifier = verifier;
    this.clientMode = clientMode;
    this.trustManagers = trustManagers;
    this.engine = sslEngine;

    mHost = host;
    mPort = port;
    engine.setUseClientMode(clientMode);
    mSink = new BufferedDataSink(socket);
    mSink.setWriteableCallback(new WritableCallback() {
        @Override
        public void onWriteable() {
            if (mWriteableCallback != null)
                mWriteableCallback.onWriteable();
        }
    });

    // on pause, the emitter is paused to prevent the buffered
    // socket and itself from firing.
    // on resume, emitter is resumed, ssl buffer is flushed as well
    mSocket.setEndCallback(new CompletedCallback() {
        @Override
        public void onCompleted(Exception ex) {
            if (mEnded)
                return;
            mEnded = true;
            mEndException = ex;
            if (!pending.hasRemaining() && mEndCallback != null)
                mEndCallback.onCompleted(ex);
        }
    });

    mSocket.setDataCallback(dataCallback);
}
 
开发者ID:pogointel,项目名称:openmap-client-android,代码行数:40,代码来源:AsyncSSLSocketWrapper.java


示例6: setWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public void setWriteableCallback(WritableCallback handler) {
    mWritable = handler;        
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:OutputStreamDataSink.java


示例7: getWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public WritableCallback getWriteableCallback() {
    return mWritable;
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:OutputStreamDataSink.java


示例8: setOutputStreamWritableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
public void setOutputStreamWritableCallback(WritableCallback outputStreamCallback) {
    this.outputStreamCallback = outputStreamCallback;
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:4,代码来源:OutputStreamDataSink.java


示例9: setWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public void setWriteableCallback(WritableCallback handler) {
    mWriteableCallback = handler;
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:AsyncSSLSocketWrapper.java


示例10: getWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public WritableCallback getWriteableCallback() {
    return mWriteableCallback;
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:AsyncSSLSocketWrapper.java


示例11: setWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public void setWriteableCallback(WritableCallback handler) {
    mSink.setWriteableCallback(handler);
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:WebSocketImpl.java


示例12: getWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public WritableCallback getWriteableCallback() {
    return mSink.getWriteableCallback();
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:WebSocketImpl.java


示例13: setWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public void setWriteableCallback(WritableCallback handler) {
    writable = handler;
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:AsyncSpdyConnection.java


示例14: getWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public WritableCallback getWriteableCallback() {
    return writable;
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:AsyncSpdyConnection.java


示例15: initFirstWrite

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
void initFirstWrite() {
    if (headWritten)
        return;

    headWritten = true;

    final boolean isChunked;
    String currentEncoding = mRawHeaders.get("Transfer-Encoding");
    if ("".equals(currentEncoding))
        mRawHeaders.removeAll("Transfer-Encoding");
    boolean canUseChunked = ("Chunked".equalsIgnoreCase(currentEncoding) || currentEncoding == null)
    && !"close".equalsIgnoreCase(mRawHeaders.get("Connection"));
    if (mContentLength < 0) {
        String contentLength = mRawHeaders.get("Content-Length");
        if (!TextUtils.isEmpty(contentLength))
            mContentLength = Long.valueOf(contentLength);
    }
    if (mContentLength < 0 && canUseChunked) {
        mRawHeaders.set("Transfer-Encoding", "Chunked");
        isChunked = true;
    }
    else {
        isChunked = false;
    }

    String statusLine = String.format(Locale.ENGLISH, "HTTP/1.1 %s %s", code, AsyncHttpServer.getResponseCodeDescription(code));
    String rh = mRawHeaders.toPrefixString(statusLine);

    Util.writeAll(mSocket, rh.getBytes(), new CompletedCallback() {
        @Override
        public void onCompleted(Exception ex) {
            if (ex != null) {
                report(ex);
                return;
            }
            if (isChunked) {
                ChunkedOutputFilter chunked = new ChunkedOutputFilter(mSocket);
                chunked.setMaxBuffer(0);
                mSink = chunked;
            }
            else {
                mSink = mSocket;
            }

            mSink.setClosedCallback(closedCallback);
            closedCallback = null;
            mSink.setWriteableCallback(writable);
            writable = null;
            if (ended) {
                // the response ended while headers were written
                end();
                return;
            }
            getServer().post(new Runnable() {
                @Override
                public void run() {
                    WritableCallback wb = getWriteableCallback();
                    if (wb != null)
                        wb.onWriteable();
                }
            });
        }
    });
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:65,代码来源:AsyncHttpServerResponseImpl.java


示例16: getWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public WritableCallback getWriteableCallback() {
    if (mSink != null)
        return mSink.getWriteableCallback();
    return writable;
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:7,代码来源:AsyncHttpServerResponseImpl.java


示例17: getWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public WritableCallback getWriteableCallback() {
    return null;
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:ResponseCacheMiddleware.java


示例18: setWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public void setWriteableCallback(WritableCallback handler) {
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:4,代码来源:ResponseCacheMiddleware.java


示例19: pump

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
public static void pump(final InputStream is, final long max, final DataSink ds, final CompletedCallback callback) {
    final CompletedCallback wrapper = new CompletedCallback() {
        boolean reported;
        @Override
        public void onCompleted(Exception ex) {
            if (reported)
                return;
            reported = true;
            callback.onCompleted(ex);
        }
    };

    final WritableCallback cb = new WritableCallback() {
        int totalRead = 0;
        private void cleanup() {
            ds.setClosedCallback(null);
            ds.setWriteableCallback(null);
            pending.recycle();
            StreamUtility.closeQuietly(is);
        }
        ByteBufferList pending = new ByteBufferList();
        Allocator allocator = new Allocator();

        @Override
        public void onWriteable() {
            try {
                do {
                    if (!pending.hasRemaining()) {
                        ByteBuffer b = allocator.allocate();

                        long toRead = Math.min(max - totalRead, b.capacity());
                        int read = is.read(b.array(), 0, (int)toRead);
                        if (read == -1 || totalRead == max) {
                            cleanup();
                            wrapper.onCompleted(null);
                            return;
                        }
                        allocator.track(read);
                        totalRead += read;
                        b.position(0);
                        b.limit(read);
                        pending.add(b);
                    }
                    
                    ds.write(pending);
                }
                while (!pending.hasRemaining());
            }
            catch (Exception e) {
                cleanup();
                wrapper.onCompleted(e);
            }
        }
    };
    ds.setWriteableCallback(cb);

    ds.setClosedCallback(wrapper);
    
    cb.onWriteable();
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:61,代码来源:Util.java


示例20: setWriteableCallback

import com.koushikdutta.async.callback.WritableCallback; //导入依赖的package包/类
@Override
public void setWriteableCallback(WritableCallback handler) {
    mWritable = handler;
}
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:BufferedDataSink.java



注:本文中的com.koushikdutta.async.callback.WritableCallback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TokenRequest类代码示例发布时间:2022-05-22
下一篇:
Java DefaultConverterLookup类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap