@@ -25,6 +25,10 @@ private ResponseHandler(Context context, DataOutputStream responseStream) {
2525 this .responseStream = responseStream ;
2626 }
2727
28+ /**
29+ * @param json Json to be sent as Response .
30+ * @throws IOException throws exception if response channel closed .
31+ */
2832 // JSON Responses ..
2933 public void sendJsonResponse (String json ) throws IOException {
3034 if (json != null ) {
@@ -36,6 +40,11 @@ public void sendJsonResponse(String json) throws IOException {
3640 this .responseStream .close ();
3741 }
3842
43+ /**
44+ * @param json Json to be sent as Response .
45+ * @param customHeaders headers to be sent with the response .
46+ * @throws IOException throws exception if response channel closed .
47+ */
3948 public void sendJsonResponse (String json , Map <String , String > customHeaders ) throws IOException {
4049 if (json != null ) {
4150 byte [] data = json .getBytes ("UTF-8" );
@@ -46,6 +55,12 @@ public void sendJsonResponse(String json, Map<String, String> customHeaders) thr
4655 this .responseStream .close ();
4756 }
4857
58+ /**
59+ * @param code custom response code
60+ * @param json Json to be sent as Response .
61+ * @param customHeaders headers to be sent with the response .
62+ * @throws IOException throws exception if response channel closed .
63+ */
4964 public void sendJsonResponse (int code , String json , Map <String , String > customHeaders ) throws IOException {
5065 if (json != null ) {
5166 byte [] data = json .getBytes ("UTF-8" );
@@ -56,6 +71,11 @@ public void sendJsonResponse(int code, String json, Map<String, String> customHe
5671 this .responseStream .close ();
5772 }
5873
74+ /**
75+ * @param code custom response code
76+ * @param json Json to be sent as Response .
77+ * @throws IOException throws exception if response channel closed .
78+ */
5979 public void sendJsonResponse (int code , String json ) throws IOException {
6080 if (json != null ) {
6181 byte [] data = json .getBytes ("UTF-8" );
@@ -66,19 +86,30 @@ public void sendJsonResponse(int code, String json) throws IOException {
6686 this .responseStream .close ();
6787 }
6888
89+ /**
90+ * @param code custom response code
91+ * @param filename filename for the html file to be sent .
92+ * @param customHeaders headers to be sent with the response .
93+ * @throws IOException throws exception if response channel closed .
94+ */
6995 // HTML Response ..
70- public void sendHtmlFileResponseWithCustomHeader (int code , String filename ,Map <String ,String >customHeaders ) throws IOException {
96+ public void sendHtmlFileResponseWithCustomHeader (int code , String filename , Map <String , String > customHeaders ) throws IOException {
7197
7298 String page = ServerHelper .getHtmlFromAsset (context , filename );
7399
74100 byte [] data = page .getBytes ();
75- sendResponseHeader (code , ServerHelper .CONTENT_TYPE .HTML , data .length ,customHeaders );
101+ sendResponseHeader (code , ServerHelper .CONTENT_TYPE .HTML , data .length , customHeaders );
76102
77103 this .responseStream .write (data );
78104 this .responseStream .flush ();
79105 this .responseStream .close ();
80106 }
81107
108+ /**
109+ * @param code custom response code
110+ * @param filename filename for the html file to be sent .
111+ * @throws IOException throws exception if response channel closed .
112+ */
82113 public void sendHtmlFileResponse (int code , String filename ) throws IOException {
83114
84115 String page = ServerHelper .getHtmlFromAsset (context , filename );
@@ -91,6 +122,12 @@ public void sendHtmlFileResponse(int code, String filename) throws IOException {
91122 this .responseStream .close ();
92123 }
93124
125+ /**
126+ * @param code custom response code
127+ * @param filename filename for the html file to be sent .
128+ * @param placeHolders data values to be replaced with placeholders in the file to be sent with the response .
129+ * @throws IOException throws exception if response channel closed .
130+ */
94131 public void sendHtmlFileResponse (int code , String filename , @ NonNull Map <String , String > placeHolders ) throws IOException {
95132
96133 String page = ServerHelper .getHtmlFromAsset (context , filename );
@@ -108,7 +145,14 @@ public void sendHtmlFileResponse(int code, String filename, @NonNull Map<String,
108145 this .responseStream .close ();
109146 }
110147
111- public void sendHtmlFileResponse (int code , String filename , @ NonNull Map <String , String > placeHolders ,Map <String ,String >customHeaders ) throws IOException {
148+ /**
149+ * @param code custom response code
150+ * @param filename filename for the html file to be sent .
151+ * @param placeHolders data values to be replaced with placeholders in the file to be sent with the response .
152+ * @param customHeaders headers to be sent with the response .
153+ * @throws IOException throws exception if response channel closed .
154+ */
155+ public void sendHtmlFileResponse (int code , String filename , @ NonNull Map <String , String > placeHolders , Map <String , String > customHeaders ) throws IOException {
112156
113157 String page = ServerHelper .getHtmlFromAsset (context , filename );
114158 String value ;
@@ -118,7 +162,7 @@ public void sendHtmlFileResponse(int code, String filename, @NonNull Map<String,
118162 }
119163
120164 byte [] data = page .getBytes ();
121- sendResponseHeader (code , ServerHelper .CONTENT_TYPE .HTML , data .length ,customHeaders );
165+ sendResponseHeader (code , ServerHelper .CONTENT_TYPE .HTML , data .length , customHeaders );
122166
123167 this .responseStream .write (data );
124168 this .responseStream .flush ();
@@ -129,6 +173,10 @@ public Context getContext() {
129173 return this .context ;
130174 }
131175
176+ /**
177+ * @param image image to be sent .
178+ * @throws IOException throws exception if response channel closed .
179+ */
132180 // Response With Image (Response closed after image sent)
133181 public void sendImageResponse (@ NonNull byte [] image ) throws IOException {
134182
@@ -139,6 +187,10 @@ public void sendImageResponse(@NonNull byte[] image) throws IOException {
139187 responseStream .close ();
140188 }
141189
190+ /**
191+ * @param sound sound to be sent .
192+ * @throws IOException throws exception if response channel closed .
193+ */
142194 public void sendSoundResponse (@ NonNull byte [] sound ) throws IOException {
143195
144196 sendResponseHeader (ServerHelper .RESPONSE_CODE .OK , ServerHelper .CONTENT_TYPE .MPEG , sound .length );
0 commit comments