class SocketdContext extends ContextEmpty {
    static final Logger log = LoggerFactory.getLogger(SocketdContext.class);

    private Session _session;
    private Message _request;
    private EntityDefault _response;
    private MethodType _method;

    public SocketdContext(Session session, Message message) throws IOException {
        _session = session;
        _request = message;
        _response = new EntityDefault();

        _method = MethodType.SOCKET;

        //传递 sessoin param
        if (session.handshake().paramMap().size() > 0) {
            headerMap().putAll(session.handshake().paramMap());
        }

        //传递 message meta
        if (Utils.isNotEmpty(message.metaString())) {
            headerMap().putAll(message.metaMap());
        }

        sessionState = new SocketdSessionState(_session);
    }


    @Override
    public Object request() {
        return _request;
    }

    @Override
    public String remoteIp() {
        try {
            return _session.remoteAddress().getAddress().toString();
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }

    @Override
    public int remotePort() {
        try {
            return _session.remoteAddress().getPort();
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }

    @Override
    public boolean isMultipart() {
        return false;
    }

    @Override
    public String method() {
        return _method.name;
    }

    @Override
    public String protocol() {
        return _session.handshake().uri().getScheme();
    }


    private URI _uri;

    @Override
    public URI uri() {<FILL_FUNCTION_BODY>}


    @Override
    public String url() {
        return _request.event();
    }

    @Override
    public long contentLength() {
        return _request.dataSize();
    }

    @Override
    public String contentType() {
        return header("Content-Type");
    }

    @Override
    public String queryString() {
        return uri().getQuery();
    }

    private InputStream bodyAsStream;
    @Override
    public InputStream bodyAsStream() throws IOException {
        if (bodyAsStream == null) {
            bodyAsStream = new ByteArrayInputStream(_request.dataAsBytes());
        }

        return bodyAsStream;
    }

    //==============

    @Override
    public Object response() {
        return _session;
    }

    @Override
    public void contentType(String contentType) {
        headerSet("Content-Type", contentType);
    }

    @Override
    public void headerSet(String key, String val) {
        _response.metaPut(key,val);
    }

    @Override
    public void headerAdd(String key, String val) {
        _response.metaPut(key,val);
    }

    @Override
    public String headerOfResponse(String name) {
        return _response.meta(name);
    }


    ByteArrayOutputStream _outputStream = new ByteArrayOutputStream();

    @Override
    public OutputStream outputStream() {
        return _outputStream;
    }

    @Override
    public void output(byte[] bytes) {
        try {
            outputStream().write(bytes);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    @Override
    public void output(InputStream stream) {
        try {
            IoUtil.transferTo(stream, outputStream());
        } catch (Throwable ex) {
            throw new RuntimeException(ex);
        }
    }

    @Override
    public void outputAsFile(File file) throws IOException {
        //文件，直接答复处理
        String fileName = URLEncoder.encode(file.getName(), Solon.encoding());
        String contentType = Utils.mime(file.getName());

        headerSet(EntityMetas.META_DATA_DISPOSITION_FILENAME, fileName);
        contentType(contentType);

        long len = file.length();
        FileEntity fileEntity = new FileEntity(file);

        replyDo(fileEntity.data(), (int) len);

        fileEntity.release();
    }

    @Override
    public void outputAsFile(DownloadedFile file) throws IOException {
        //文件，直接答复处理
        String fileName = URLEncoder.encode(file.getName(), Solon.encoding());

        headerSet(EntityMetas.META_DATA_DISPOSITION_FILENAME, fileName);
        contentType(file.getContentType());

        byte[] bytes = IoUtil.transferToBytes(file.getContent());
        replyDo(ByteBuffer.wrap(bytes), (int) file.getContentSize());
    }

    protected void commit() throws IOException {
        replyDo(ByteBuffer.wrap(_outputStream.toByteArray()), _outputStream.size());
    }

    private void replyDo(ByteBuffer dataStream, int dataSize) throws IOException {
        if (_request.isRequest() || _request.isSubscribe()) {
            _response.dataSet(dataStream);
            _session.replyEnd(_request, _response);
        } else {
            if (dataSize > 0) {
                log.warn("No reply is supported for the current message, sid={}", _request.sid());
            }
        }
    }

    @Override
    public boolean asyncSupported() {
        return true;
    }

    @Override
    public void asyncStart(long timeout, ContextAsyncListener listener) {
        //本身就是异步机制，不用启动
    }

    @Override
    public void asyncComplete() {

    }

    @Override
    public void close() throws IOException {
        _session.close();
    }
}

        if (_uri == null) {
            _uri = URI.create(url());
        }

        return _uri;
    
<methods>public void <init>() ,public void asyncComplete() ,public void asyncStart(long, org.noear.solon.core.handle.ContextAsyncListener) ,public boolean asyncSupported() ,public java.io.InputStream bodyAsStream() throws java.io.IOException,public void close() throws java.io.IOException,public java.lang.String contentCharset() ,public long contentLength() ,public java.lang.String contentType() ,public java.lang.String cookie(java.lang.String) ,public java.lang.String cookie(java.lang.String, java.lang.String) ,public org.noear.solon.core.NvMap cookieMap() ,public void cookieSet(java.lang.String, java.lang.String, java.lang.String, java.lang.String, int) ,public static org.noear.solon.core.handle.Context create() ,public void filesDelete() throws java.io.IOException,public Map<java.lang.String,List<org.noear.solon.core.handle.UploadedFile>> filesMap() throws java.io.IOException,public void flush() throws java.io.IOException,public void headerAdd(java.lang.String, java.lang.String) ,public org.noear.solon.core.NvMap headerMap() ,public java.lang.String headerOfResponse(java.lang.String) ,public void headerSet(java.lang.String, java.lang.String) ,public Map<java.lang.String,List<java.lang.String>> headersMap() ,public boolean isSecure() ,public java.lang.String method() ,public void output(byte[]) ,public void output(java.io.InputStream) ,public void outputAsFile(org.noear.solon.core.handle.DownloadedFile) throws java.io.IOException,public void outputAsFile(java.io.File) throws java.io.IOException,public java.io.OutputStream outputStream() ,public org.noear.solon.core.NvMap paramMap() ,public Map<java.lang.String,List<java.lang.String>> paramsMap() ,public java.lang.String protocol() ,public java.lang.String queryString() ,public void redirect(java.lang.String, int) ,public java.lang.String remoteIp() ,public int remotePort() ,public java.lang.Object request() ,public org.noear.solon.core.handle.ContextEmpty request(java.lang.Object) ,public java.lang.Object response() ,public org.noear.solon.core.handle.ContextEmpty response(java.lang.Object) ,public T session(java.lang.String, Class<T>) ,public double sessionAsDouble(java.lang.String) ,public double sessionAsDouble(java.lang.String, double) ,public int sessionAsInt(java.lang.String) ,public int sessionAsInt(java.lang.String, int) ,public long sessionAsLong(java.lang.String) ,public long sessionAsLong(java.lang.String, long) ,public void sessionClear() ,public java.lang.String sessionId() ,public T sessionOrDefault(java.lang.String, T) ,public void sessionRemove(java.lang.String) ,public void sessionSet(java.lang.String, java.lang.Object) ,public int status() ,public java.net.URI uri() ,public java.lang.String url() <variables>org.noear.solon.core.NvMap cookieMap,Map<java.lang.String,List<org.noear.solon.core.handle.UploadedFile>> filesMap,private org.noear.solon.core.NvMap headerMap,private Map<java.lang.String,List<java.lang.String>> headersMap,private org.noear.solon.core.NvMap paramMap,Map<java.lang.String,List<java.lang.String>> paramsMap,private java.lang.Object request,private java.lang.Object response,private int status