Back to Vassonic

SonicServer (sdk 3.0.0 API)

sonic-android/docs/javadoc/com/tencent/sonic/sdk/SonicServer.html

3.1.110.4 KB
Original Source

跳过导航链接

com.tencent.sonic.sdk

类 SonicServer


public classSonicServerextends java.lang.Object
implements[SonicSessionStream.Callback](../../../../com/tencent/sonic/sdk/SonicSessionStream.Callback.html "com.tencent.sonic.sdk中的接口")

Instances of this class can be used to read server response from SonicSessionConnection. If this request support Local Sonic Server, it will separate html into template and data file.

字段概要

字段 | 限定符和类型 | 字段和说明 | | --- | --- | | protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> | cachedResponseHeaders Cached response headers which contains response headers from server and custom response headers from com.tencent.sonic.sdk.SonicSessionConfig | | protected SonicSessionConnection | connectionImpl A session connection implement. | | protected java.lang.String | dataString | | protected android.content.Intent | requestIntent | | protected int | responseCode | | protected java.lang.String | serverRsp | | protected SonicSession | session | | static java.lang.String | TAG | | protected java.lang.String | templateString |

构造器概要

构造器 | 构造器和说明 | | --- | | SonicServer(SonicSession session, android.content.Intent requestIntent) |

方法概要

所有方法 实例方法 具体方法 | 限定符和类型 | 方法和说明 | | --- | --- | | protected int | connect() Opens a communications link to the resource referenced by Sonic session. | | void | disconnect() Disconnect the communications link to the resource referenced by Sonic session | | int | getResponseCode() | | java.lang.String | getResponseData(boolean readUntilEnd) Return current cached server response data. | | java.lang.String | getResponseHeaderField(java.lang.String key) | | java.util.Map<java.lang.String,java.util.List<java.lang.String>> | getResponseHeaderFields() return response headers which contains response headers from server and custom response headers from com.tencent.sonic.sdk.SonicSessionConfig note: server response headers have high priority than custom headers! | | java.io.InputStream | getResponseStream(java.util.concurrent.atomic.AtomicBoolean breakConditions) Read all of data from SonicSessionConnection.getResponseStream() into byte array output stream outputStream until breakCondition is true when breakCondition is not null. | | java.lang.String | getTemplate() If the serverRsp is not empty, It will separate serverRsp into template and data file and return template as string. | | java.lang.String | getUpdatedData() If the serverRsp is not empty, It will separate serverRsp into template and data file and return data as JSONObject String. | | void | onClose(boolean readComplete, java.io.ByteArrayOutputStream outputStream) Close callback | | protected void | separateTemplateAndData() |

- 

从类继承的方法 java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

字段详细资料

- 

TAG

public static final java.lang.String TAG

另请参阅:常量字段值

- 

connectionImpl

protected final[SonicSessionConnection](../../../../com/tencent/sonic/sdk/SonicSessionConnection.html "com.tencent.sonic.sdk中的类")connectionImpl

A session connection implement.

- 

serverRsp

protected java.lang.String serverRsp
- 

templateString

protected java.lang.String templateString
- 

dataString

protected java.lang.String dataString
- 

responseCode

protected int responseCode
- 

session

protected final[SonicSession](../../../../com/tencent/sonic/sdk/SonicSession.html "com.tencent.sonic.sdk中的类")session
- 

requestIntent

protected final android.content.Intent requestIntent
- 

cachedResponseHeaders

protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> cachedResponseHeaders

Cached response headers which contains response headers from server and custom response headers from com.tencent.sonic.sdk.SonicSessionConfig

构造器详细资料

- 

SonicServer

public SonicServer([SonicSession](../../../../com/tencent/sonic/sdk/SonicSession.html "com.tencent.sonic.sdk中的类")session,
                   android.content.Intent requestIntent)

方法详细资料

- 

connect

protected int connect()

Opens a communications link to the resource referenced by Sonic session. If this request support Local Sonic Server, it will separate html into template and data file. 返回:Returns the response code of connection

- 

getResponseCode

public int getResponseCode()
- 

disconnect

public void disconnect()

Disconnect the communications link to the resource referenced by Sonic session

- 

getResponseHeaderFields

public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaderFields()

return response headers which contains response headers from server and custom response headers from com.tencent.sonic.sdk.SonicSessionConfig note: server response headers have high priority than custom headers! 返回:a Map of header fields

- 

getResponseHeaderField

public java.lang.String getResponseHeaderField(java.lang.String key)

参数:key - the name of a header field.返回:Returns the value of the named header field from SonicSessionConnection.

- 

getResponseStream

public java.io.InputStream getResponseStream(java.util.concurrent.atomic.AtomicBoolean breakConditions)

Read all of data from SonicSessionConnection.getResponseStream() into byte array output stream outputStream until breakCondition is true when breakCondition is not null. Then return a SonicSessionStream obtains input bytes from outputStream and a netStream when there is unread data from network. 参数:breakConditions - This method won't read any data from SonicSessionConnection.getResponseStream() if breakCondition is true.返回:Returns a SonicSessionStream obtains input bytes from outputStream and a netStream when there is unread data from network.

- 

getResponseData

public java.lang.String getResponseData(boolean readUntilEnd)

Return current cached server response data. If @{code readUntilEnd} is true and current cached response data is empty, read all of data from SonicSessionConnection.getResponseStream() into byte array output stream outputStream. And then this method convert outputStream into response string serverRsp.

Note: This method blocks until the end of the input stream has been reached or breakCondition has been reset to true.

参数:readUntilEnd - This method won't read any data from SonicSessionConnection.getResponseStream() if readUntilEnd is false.返回:Returns serverRsp current cached server response data.

- 

getTemplate

public java.lang.String getTemplate()

If the serverRsp is not empty, It will separate serverRsp into template and data file and return template as string. 返回:The template.

- 

getUpdatedData

public java.lang.String getUpdatedData()

If the serverRsp is not empty, It will separate serverRsp into template and data file and return data as JSONObject String. 返回:the JSONObject String which represent data.

- 

separateTemplateAndData

protected void separateTemplateAndData()
- 

onClose

public void onClose(boolean readComplete,
                    java.io.ByteArrayOutputStream outputStream)

从接口复制的说明: SonicSessionStream.Callback

Close callback 指定者:onClose 在接口中 SonicSessionStream.Callback参数:readComplete - SonicSessionStream data has read completedoutputStream - outputStream include memStream data and netStream data

跳过导航链接