public class SonicServer extends java.lang.Object implements SonicSessionStream.Callback
| 限定符和类型 | 字段和说明 |
|---|---|
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
|
java.lang.String |
getCustomHeadFieldEtagKey() |
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() |
public static final java.lang.String TAG
protected final SonicSessionConnection connectionImpl
protected java.lang.String serverRsp
protected java.lang.String templateString
protected java.lang.String dataString
protected int responseCode
protected final SonicSession session
protected final android.content.Intent requestIntent
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> cachedResponseHeaders
com.tencent.sonic.sdk.SonicSessionConfigpublic SonicServer(SonicSession session, android.content.Intent requestIntent)
protected int connect()
public int getResponseCode()
public void disconnect()
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaderFields()
com.tencent.sonic.sdk.SonicSessionConfig
note: server response headers have high priority than custom headers!public java.lang.String getResponseHeaderField(java.lang.String key)
key - the name of a header field.public java.io.InputStream getResponseStream(java.util.concurrent.atomic.AtomicBoolean breakConditions)
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.SonicSessionStream obtains input bytes
from outputStream and a netStream when there is unread data from network.public java.lang.String getResponseData(boolean readUntilEnd)
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.serverRsp current cached server response data.public java.lang.String getTemplate()
public java.lang.String getUpdatedData()
protected void separateTemplateAndData()
public java.lang.String getCustomHeadFieldEtagKey()
public void onClose(boolean readComplete,
java.io.ByteArrayOutputStream outputStream)
SonicSessionStream.CallbackonClose 在接口中 SonicSessionStream.CallbackreadComplete - SonicSessionStream data has read completedoutputStream - outputStream include memStream data and netStream data