sonic-android/docs/javadoc/com/tencent/sonic/sdk/SonicServer.html
com.tencent.sonic.sdk
java.lang.Object
所有已实现的接口:SonicSessionStream.Callback
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() |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public static final java.lang.String TAG
另请参阅:常量字段值
-
protected final[SonicSessionConnection](../../../../com/tencent/sonic/sdk/SonicSessionConnection.html "com.tencent.sonic.sdk中的类")connectionImpl
A session connection implement.
-
protected java.lang.String serverRsp
-
protected java.lang.String templateString
-
protected java.lang.String dataString
-
protected int responseCode
-
protected final[SonicSession](../../../../com/tencent/sonic/sdk/SonicSession.html "com.tencent.sonic.sdk中的类")session
-
protected final android.content.Intent requestIntent
-
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
-
public SonicServer([SonicSession](../../../../com/tencent/sonic/sdk/SonicSession.html "com.tencent.sonic.sdk中的类")session,
android.content.Intent requestIntent)
-
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
-
public int getResponseCode()
-
public void disconnect()
Disconnect the communications link to the resource referenced by Sonic session
-
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
-
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.
-
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.
-
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.
-
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.
-
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.
-
protected void separateTemplateAndData()
-
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