Skip to content

Commit c7183b8

Browse files
update site
- add "How to deal with cookies" in FAQ
1 parent 7716ed9 commit c7183b8

20 files changed

+259
-38
lines changed

changelog.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<!--
3-
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from src/site/markdown/changelog.md at 2022-06-29
3+
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from src/site/markdown/changelog.md at 2022-07-02
44
| Rendered using Apache Maven Fluido Skin 1.9
55
-->
66
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
@@ -32,7 +32,7 @@
3232

3333
<div id="breadcrumbs">
3434
<ul class="breadcrumb">
35-
<li id="publishDate">Last Published: 2022-06-29<span class="divider">|</span>
35+
<li id="publishDate">Last Published: 2022-07-02<span class="divider">|</span>
3636
</li>
3737
<li id="projectVersion">Version: 2.0.2-SNAPSHOT</li>
3838
</ul>
@@ -49,6 +49,7 @@
4949
<li><a href="listening_to_events.html" title="Listening to events"><span class="none"></span>Listening to events</a></li>
5050
<li><a href="socket_instance.html" title="The Socket instance"><span class="none"></span>The Socket instance</a></li>
5151
<li><a href="migrating_from_1_x.html" title="Migrating from 1.x"><span class="none"></span>Migrating from 1.x</a></li>
52+
<li><a href="faq.html" title="FAQ"><span class="none"></span>FAQ</a></li>
5253
<li class="nav-header">Miscellaneous</li>
5354
<li class="active"><a href="#"><span class="none"></span>Changelog</a></li>
5455
<li><a href="apidocs/index.html" title="Javadoc"><span class="none"></span>Javadoc</a></li>

dependencies.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<!--
3-
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.1:dependencies at 2022-06-29
3+
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.1:dependencies at 2022-07-02
44
| Rendered using Apache Maven Fluido Skin 1.9
55
-->
66
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
@@ -32,7 +32,7 @@
3232

3333
<div id="breadcrumbs">
3434
<ul class="breadcrumb">
35-
<li id="publishDate">Last Published: 2022-06-29<span class="divider">|</span>
35+
<li id="publishDate">Last Published: 2022-07-02<span class="divider">|</span>
3636
</li>
3737
<li id="projectVersion">Version: 2.0.2-SNAPSHOT</li>
3838
</ul>
@@ -49,6 +49,7 @@
4949
<li><a href="listening_to_events.html" title="Listening to events"><span class="none"></span>Listening to events</a></li>
5050
<li><a href="socket_instance.html" title="The Socket instance"><span class="none"></span>The Socket instance</a></li>
5151
<li><a href="migrating_from_1_x.html" title="Migrating from 1.x"><span class="none"></span>Migrating from 1.x</a></li>
52+
<li><a href="faq.html" title="FAQ"><span class="none"></span>FAQ</a></li>
5253
<li class="nav-header">Miscellaneous</li>
5354
<li><a href="changelog.html" title="Changelog"><span class="none"></span>Changelog</a></li>
5455
<li><a href="apidocs/index.html" title="Javadoc"><span class="none"></span>Javadoc</a></li>

dependency-info.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<!--
3-
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.1:dependency-info at 2022-06-29
3+
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.1:dependency-info at 2022-07-02
44
| Rendered using Apache Maven Fluido Skin 1.9
55
-->
66
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
@@ -32,7 +32,7 @@
3232

3333
<div id="breadcrumbs">
3434
<ul class="breadcrumb">
35-
<li id="publishDate">Last Published: 2022-06-29<span class="divider">|</span>
35+
<li id="publishDate">Last Published: 2022-07-02<span class="divider">|</span>
3636
</li>
3737
<li id="projectVersion">Version: 2.0.2-SNAPSHOT</li>
3838
</ul>
@@ -49,6 +49,7 @@
4949
<li><a href="listening_to_events.html" title="Listening to events"><span class="none"></span>Listening to events</a></li>
5050
<li><a href="socket_instance.html" title="The Socket instance"><span class="none"></span>The Socket instance</a></li>
5151
<li><a href="migrating_from_1_x.html" title="Migrating from 1.x"><span class="none"></span>Migrating from 1.x</a></li>
52+
<li><a href="faq.html" title="FAQ"><span class="none"></span>FAQ</a></li>
5253
<li class="nav-header">Miscellaneous</li>
5354
<li><a href="changelog.html" title="Changelog"><span class="none"></span>Changelog</a></li>
5455
<li><a href="apidocs/index.html" title="Javadoc"><span class="none"></span>Javadoc</a></li>

distribution-management.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<!--
3-
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.1:distribution-management at 2022-06-29
3+
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.1:distribution-management at 2022-07-02
44
| Rendered using Apache Maven Fluido Skin 1.9
55
-->
66
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
@@ -32,7 +32,7 @@
3232

3333
<div id="breadcrumbs">
3434
<ul class="breadcrumb">
35-
<li id="publishDate">Last Published: 2022-06-29<span class="divider">|</span>
35+
<li id="publishDate">Last Published: 2022-07-02<span class="divider">|</span>
3636
</li>
3737
<li id="projectVersion">Version: 2.0.2-SNAPSHOT</li>
3838
</ul>
@@ -49,6 +49,7 @@
4949
<li><a href="listening_to_events.html" title="Listening to events"><span class="none"></span>Listening to events</a></li>
5050
<li><a href="socket_instance.html" title="The Socket instance"><span class="none"></span>The Socket instance</a></li>
5151
<li><a href="migrating_from_1_x.html" title="Migrating from 1.x"><span class="none"></span>Migrating from 1.x</a></li>
52+
<li><a href="faq.html" title="FAQ"><span class="none"></span>FAQ</a></li>
5253
<li class="nav-header">Miscellaneous</li>
5354
<li><a href="changelog.html" title="Changelog"><span class="none"></span>Changelog</a></li>
5455
<li><a href="apidocs/index.html" title="Javadoc"><span class="none"></span>Javadoc</a></li>

emitting_events.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<!--
3-
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from src/site/markdown/emitting_events.md at 2022-06-29
3+
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from src/site/markdown/emitting_events.md at 2022-07-02
44
| Rendered using Apache Maven Fluido Skin 1.9
55
-->
66
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
@@ -32,7 +32,7 @@
3232

3333
<div id="breadcrumbs">
3434
<ul class="breadcrumb">
35-
<li id="publishDate">Last Published: 2022-06-29<span class="divider">|</span>
35+
<li id="publishDate">Last Published: 2022-07-02<span class="divider">|</span>
3636
</li>
3737
<li id="projectVersion">Version: 2.0.2-SNAPSHOT</li>
3838
</ul>
@@ -49,6 +49,7 @@
4949
<li><a href="listening_to_events.html" title="Listening to events"><span class="none"></span>Listening to events</a></li>
5050
<li><a href="socket_instance.html" title="The Socket instance"><span class="none"></span>The Socket instance</a></li>
5151
<li><a href="migrating_from_1_x.html" title="Migrating from 1.x"><span class="none"></span>Migrating from 1.x</a></li>
52+
<li><a href="faq.html" title="FAQ"><span class="none"></span>FAQ</a></li>
5253
<li class="nav-header">Miscellaneous</li>
5354
<li><a href="changelog.html" title="Changelog"><span class="none"></span>Changelog</a></li>
5455
<li><a href="apidocs/index.html" title="Javadoc"><span class="none"></span>Javadoc</a></li>

faq.html

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
<!DOCTYPE html>
2+
<!--
3+
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from src/site/markdown/faq.md at 2022-07-02
4+
| Rendered using Apache Maven Fluido Skin 1.9
5+
-->
6+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
7+
<head>
8+
<meta charset="UTF-8" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1" />
10+
<meta name="generator" content="Apache Maven Doxia Site Renderer 1.9.2" />
11+
<title>socket.io-client &#x2013; Frequently asked questions</title>
12+
<link rel="stylesheet" href="./css/apache-maven-fluido-1.9.min.css" />
13+
<link rel="stylesheet" href="./css/site.css" />
14+
<link rel="stylesheet" href="./css/print.css" media="print" />
15+
<script src="./js/apache-maven-fluido-1.9.min.js"></script>
16+
</head>
17+
<body class="topBarDisabled">
18+
<a href="https://github.com/socketio/socket.io-client-java">
19+
<img style="position: absolute; top: 0; right: 0; border: 0; z-index: 10000;"
20+
src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"
21+
alt="Fork me on GitHub">
22+
</a>
23+
<div class="container-fluid">
24+
<header>
25+
<div id="banner">
26+
<div class="pull-left"><div id="bannerLeft"><h2>Socket.IO Java client</h2>
27+
</div>
28+
</div>
29+
<div class="pull-right"></div>
30+
<div class="clear"><hr/></div>
31+
</div>
32+
33+
<div id="breadcrumbs">
34+
<ul class="breadcrumb">
35+
<li id="publishDate">Last Published: 2022-07-02<span class="divider">|</span>
36+
</li>
37+
<li id="projectVersion">Version: 2.0.2-SNAPSHOT</li>
38+
</ul>
39+
</div>
40+
</header>
41+
<div class="row-fluid">
42+
<header id="leftColumn" class="span2">
43+
<nav class="well sidebar-nav">
44+
<ul class="nav nav-list">
45+
<li class="nav-header">Overview</li>
46+
<li><a href="installation.html" title="Installation"><span class="none"></span>Installation</a></li>
47+
<li><a href="initialization.html" title="Initialization"><span class="none"></span>Initialization</a></li>
48+
<li><a href="emitting_events.html" title="Emitting events"><span class="none"></span>Emitting events</a></li>
49+
<li><a href="listening_to_events.html" title="Listening to events"><span class="none"></span>Listening to events</a></li>
50+
<li><a href="socket_instance.html" title="The Socket instance"><span class="none"></span>The Socket instance</a></li>
51+
<li><a href="migrating_from_1_x.html" title="Migrating from 1.x"><span class="none"></span>Migrating from 1.x</a></li>
52+
<li class="active"><a href="#"><span class="none"></span>FAQ</a></li>
53+
<li class="nav-header">Miscellaneous</li>
54+
<li><a href="changelog.html" title="Changelog"><span class="none"></span>Changelog</a></li>
55+
<li><a href="apidocs/index.html" title="Javadoc"><span class="none"></span>Javadoc</a></li>
56+
<li class="nav-header">Project Documentation</li>
57+
<li><a href="project-info.html" title="Project Information"><span class="icon-chevron-right"></span>Project Information</a></li>
58+
</ul>
59+
</nav>
60+
<div class="well sidebar-nav">
61+
<hr />
62+
<div id="poweredBy">
63+
<div class="clear"></div>
64+
<div class="clear"></div>
65+
<div class="clear"></div>
66+
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
67+
</div>
68+
</div>
69+
</header>
70+
<main id="bodyColumn" class="span10" >
71+
<h1>Frequently asked questions</h1>
72+
<ul>
73+
<li><a href="#How_to_deal_with_cookies">How to deal with cookies</a></li>
74+
<li><a href="#How_to_use_with_AWS_Load_Balancing">How to use with AWS Load Balancing</a></li></ul>
75+
<section>
76+
<h2><a name="How_to_deal_with_cookies"></a>How to deal with cookies</h2>
77+
<p>In order to store the cookies sent by the server and include them in all subsequent requests, you need to create an OkHttpClient with a custom <a class="externalLink" href="https://square.github.io/okhttp/4.x/okhttp/okhttp3/-cookie-jar/">cookie jar</a>.</p>
78+
<p>You can either implement your own cookie jar:</p>
79+
80+
<div class="source">
81+
<div class="source"><pre class="prettyprint">public class MyApp {
82+
83+
public static void main(String[] argz) throws Exception {
84+
IO.Options options = new IO.Options();
85+
86+
OkHttpClient okHttpClient = new OkHttpClient.Builder()
87+
.cookieJar(new MyCookieJar())
88+
.build();
89+
90+
options.callFactory = okHttpClient;
91+
options.webSocketFactory = okHttpClient;
92+
93+
Socket socket = IO.socket(URI.create(&quot;https://example.com&quot;), options);
94+
95+
socket.connect();
96+
}
97+
98+
private static class MyCookieJar implements CookieJar {
99+
private Set&lt;WrappedCookie&gt; cache = new HashSet&lt;&gt;();
100+
101+
@Override
102+
public void saveFromResponse(HttpUrl url, List&lt;Cookie&gt; cookies) {
103+
for (Cookie cookie : cookies) {
104+
this.cache.add(new WrappedCookie(cookie));
105+
}
106+
}
107+
108+
@Override
109+
public List&lt;Cookie&gt; loadForRequest(HttpUrl url) {
110+
List&lt;Cookie&gt; cookies = new ArrayList&lt;&gt;();
111+
Iterator&lt;WrappedCookie&gt; iterator = this.cache.iterator();
112+
while (iterator.hasNext()) {
113+
Cookie cookie = iterator.next().cookie;
114+
if (isCookieExpired(cookie)) {
115+
iterator.remove();
116+
} else if (cookie.matches(url)) {
117+
cookies.add(cookie);
118+
}
119+
}
120+
return cookies;
121+
}
122+
123+
private static boolean isCookieExpired(Cookie cookie) {
124+
return cookie.expiresAt() &lt; System.currentTimeMillis();
125+
}
126+
}
127+
128+
private static class WrappedCookie {
129+
private final Cookie cookie;
130+
131+
public WrappedCookie(Cookie cookie) {
132+
this.cookie = cookie;
133+
}
134+
135+
@Override
136+
public boolean equals(Object o) {
137+
if (!(o instanceof WrappedCookie)) return false;
138+
WrappedCookie that = (WrappedCookie) o;
139+
return that.cookie.name().equals(this.cookie.name())
140+
&amp;&amp; that.cookie.domain().equals(this.cookie.domain())
141+
&amp;&amp; that.cookie.path().equals(this.cookie.path())
142+
&amp;&amp; that.cookie.secure() == this.cookie.secure()
143+
&amp;&amp; that.cookie.hostOnly() == this.cookie.hostOnly();
144+
}
145+
146+
@Override
147+
public int hashCode() {
148+
int hash = 17;
149+
hash = 31 * hash + cookie.name().hashCode();
150+
hash = 31 * hash + cookie.domain().hashCode();
151+
hash = 31 * hash + cookie.path().hashCode();
152+
hash = 31 * hash + (cookie.secure() ? 0 : 1);
153+
hash = 31 * hash + (cookie.hostOnly() ? 0 : 1);
154+
return hash;
155+
}
156+
}
157+
}
158+
</pre></div></div>
159+
160+
<p>Or use a package like <a class="externalLink" href="https://github.com/franmontiel/PersistentCookieJar">PersistentCookieJar</a>:</p>
161+
162+
<div class="source">
163+
<div class="source"><pre class="prettyprint">public class MyApp {
164+
165+
public static void main(String[] argz) throws Exception {
166+
IO.Options options = new IO.Options();
167+
168+
ClearableCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(context));
169+
170+
OkHttpClient okHttpClient = new OkHttpClient.Builder()
171+
.cookieJar(cookieJar)
172+
.build();
173+
174+
options.callFactory = okHttpClient;
175+
options.webSocketFactory = okHttpClient;
176+
177+
Socket socket = IO.socket(URI.create(&quot;https://example.com&quot;), options);
178+
179+
socket.connect();
180+
}
181+
}
182+
</pre></div></div>
183+
</section><section>
184+
<h2><a name="How_to_use_with_AWS_Load_Balancing"></a>How to use with AWS Load Balancing</h2>
185+
<p>When scaling to multiple Socket.IO servers, you must ensure that all the HTTP requests of a given session reach the same server (explanation <a class="externalLink" href="https://socket.io/docs/v4/using-multiple-nodes/#why-is-sticky-session-required">here</a>).</p>
186+
<p>Sticky sessions can be enabled on AWS Application Load Balancers, which works by sending a cookie (<code>AWSALB</code>) to the client.</p>
187+
<p>Please see <a href="#how-to-deal-with-cookies">above</a> for how to deal with cookies.</p>
188+
<p>Reference: <a class="externalLink" href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/sticky-sessions.html">https://docs.aws.amazon.com/elasticloadbalancing/latest/application/sticky-sessions.html</a></p></section>
189+
</main>
190+
</div>
191+
</div>
192+
<hr/>
193+
<footer>
194+
<div class="container-fluid">
195+
<div class="row-fluid">
196+
<p>&#169; 2022
197+
</p>
198+
</div>
199+
</div>
200+
</footer>
201+
</body>
202+
</html>

index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<!--
3-
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.1:index at 2022-06-29
3+
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.1:index at 2022-07-02
44
| Rendered using Apache Maven Fluido Skin 1.9
55
-->
66
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
@@ -32,7 +32,7 @@
3232

3333
<div id="breadcrumbs">
3434
<ul class="breadcrumb">
35-
<li id="publishDate">Last Published: 2022-06-29<span class="divider">|</span>
35+
<li id="publishDate">Last Published: 2022-07-02<span class="divider">|</span>
3636
</li>
3737
<li id="projectVersion">Version: 2.0.2-SNAPSHOT</li>
3838
</ul>
@@ -49,6 +49,7 @@
4949
<li><a href="listening_to_events.html" title="Listening to events"><span class="none"></span>Listening to events</a></li>
5050
<li><a href="socket_instance.html" title="The Socket instance"><span class="none"></span>The Socket instance</a></li>
5151
<li><a href="migrating_from_1_x.html" title="Migrating from 1.x"><span class="none"></span>Migrating from 1.x</a></li>
52+
<li><a href="faq.html" title="FAQ"><span class="none"></span>FAQ</a></li>
5253
<li class="nav-header">Miscellaneous</li>
5354
<li><a href="changelog.html" title="Changelog"><span class="none"></span>Changelog</a></li>
5455
<li><a href="apidocs/index.html" title="Javadoc"><span class="none"></span>Javadoc</a></li>

initialization.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<!--
3-
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from src/site/markdown/initialization.md at 2022-06-29
3+
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from src/site/markdown/initialization.md at 2022-07-02
44
| Rendered using Apache Maven Fluido Skin 1.9
55
-->
66
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
@@ -32,7 +32,7 @@
3232

3333
<div id="breadcrumbs">
3434
<ul class="breadcrumb">
35-
<li id="publishDate">Last Published: 2022-06-29<span class="divider">|</span>
35+
<li id="publishDate">Last Published: 2022-07-02<span class="divider">|</span>
3636
</li>
3737
<li id="projectVersion">Version: 2.0.2-SNAPSHOT</li>
3838
</ul>
@@ -49,6 +49,7 @@
4949
<li><a href="listening_to_events.html" title="Listening to events"><span class="none"></span>Listening to events</a></li>
5050
<li><a href="socket_instance.html" title="The Socket instance"><span class="none"></span>The Socket instance</a></li>
5151
<li><a href="migrating_from_1_x.html" title="Migrating from 1.x"><span class="none"></span>Migrating from 1.x</a></li>
52+
<li><a href="faq.html" title="FAQ"><span class="none"></span>FAQ</a></li>
5253
<li class="nav-header">Miscellaneous</li>
5354
<li><a href="changelog.html" title="Changelog"><span class="none"></span>Changelog</a></li>
5455
<li><a href="apidocs/index.html" title="Javadoc"><span class="none"></span>Javadoc</a></li>

0 commit comments

Comments
 (0)