File tree Expand file tree Collapse file tree 3 files changed +34
-4
lines changed
src/main/java/org/sobotics/chatexchange/chat Expand file tree Collapse file tree 3 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -31,5 +31,17 @@ public String getName() {
3131 public String getBaseUrl () {
3232 return baseUrl ;
3333 }
34+
35+ /**
36+ * Compares the host to another object
37+ * @param otherHost other object
38+ * @return true, if the name is the same
39+ */
40+ public boolean equals (ChatHost otherHost ) {
41+ if (otherHost == null )
42+ return false ;
43+
44+ return this .name .equals (otherHost .name );
45+ }
3446
3547}
Original file line number Diff line number Diff line change @@ -618,6 +618,14 @@ public RoomThumbs getThumbs() {
618618 public ChatHost getHost () {
619619 return host ;
620620 }
621+
622+ /**
623+ * Returns the cookies used to post in this room
624+ * @return cookies as Map
625+ */
626+ public Map <String , String > getCookies () {
627+ return this .cookies ;
628+ }
621629
622630 void close () {
623631 executor .shutdown ();
Original file line number Diff line number Diff line change @@ -247,12 +247,22 @@ public void setAutoCreateAccount(boolean autoCreateAccount) {
247247 this .autoCreateAccount = autoCreateAccount ;
248248 }
249249
250+
250251 /**
251- * Returns the cookies the library uses
252- * @return Cookies
252+ * Returns the cookies for the first room with the given host
253+ * @param host {@link ChatHost} to search for
254+ * @return null, if no room with the given {@link ChatHost} was found
253255 */
254- public Map <String , String > getCookies () {
255- return this .cookies ;
256+ public Map <String , String > getCookies (ChatHost host ) {
257+ for (Room room : this .rooms ) {
258+ ChatHost roomHost = room .getHost ();
259+
260+ if (host .equals (roomHost )) {
261+ return room .getCookies ();
262+ }
263+ }
264+
265+ return null ;
256266 }
257267
258268 /**
You can’t perform that action at this time.
0 commit comments