-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
170 lines (167 loc) · 8.72 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
---
layout: default
title: A full-featured real-time web framework for Java
---
<div class="grid-container">
<div class="grid-x">
<div class="cell">
<ul class="breadcrumbs">
<li><a href="/"><img src="/cettia-logo.svg" alt="Home"> Home</a></li>
</ul>
<section>
<h1>Cettia</h1>
<p>Cettia is a full-featured real-time web framework for Java that you can use to exchange events between servers and web clients in real-time. Cettia works with any web frameworks on the Java Virtual Machine, provides reliable full duplex message channels, enables elegant patterns which make it fast and enjoyable to build real-time web applications, and scales horizontally using messaging passing.</p>
<ul class="menu">
<li><a href="/guides/getting-started">Get started</a></li>
<li><a href="/guides/cettia-tutorial">Learn more</a></li>
</ul>
<h5>Latest posts</h5>
<ul>
{% for post in site.posts limit:3 %}
<li>
<a href="{{ post.url }}">
{{ post.title }}
</a> on <time>{{ post.date | date_to_string }}</time>
</li>
{% endfor %}
</ul>
<p><a href="/blog">See all posts</a></p>
</section>
<section>
<h3>Use whatever web framework you prefer</h3>
<p>Cettia is designed not just to run on any web framework seamlessly on the JVM but also not to degrade the underlying framework's performance. Almost all popular web frameworks in Java are supported: Java EE (Servlet and Java API for WebSocket), Spring WebFlux, Spring Web MVC, Play Framework, Vert.x, Grizzly, Netty, Atmosphere, and so on.</p>
<div class="explanation">
<p>Plug transport servers into your favorite web framework.</p>
{% capture panel %}
```java
io.cettia.Server server = new DefaultServer();
io.cettia.transport.http.HttpTransportServer hts = new HttpTransportServer().ontransport(server);
io.cettia.transport.websocket.WebSocketTransportServer wts = new WebSocketTransportServer().ontransport(server);
```
{% endcapture %}{{ panel | markdownify }}
{% include framework-examples.html %}
<p><a href="https://github.com/cettia/cettia-starter-kit" target="_blank">Check out working examples</a></p>
</div>
</section>
<section>
<h3>WebSocket, JSON and switch statement are not enough</h3>
<p>It might seem so at first glance but is likely to fall into the cracks at the enterprise level. Cettia's reliable full duplex message channels based on WebSocket and HTTP and elegant patterns including the robust event system free you from the pitfalls of traditional real-time web development.</p>
<div class="explanation">
<p>In the client side,</p>
{% capture panel %}
```javascript
import cettia from "cettia-client/cettia-bundler";
const socket = cettia.open("/cettia");
socket.on("open", () => socket.send("greeting", "Hello world")));
socket.on("greeting", data => console.log("Greeting from the server", data));
socket.on("klose", () => socket.close());
```
{% endcapture %}{{ panel | markdownify }}
<p>In the server side,</p>
{% capture panel %}
```java
server.onsocket((io.cettia.ServerSocket socket) -> {
socket.set("username", username);
socket.onopen(v -> socket.send("greeting", "Hello world"));
socket.on("greeting", data -> System.out.println("Greeting from the client " + data));
});
```
{% endcapture %}{{ panel | markdownify }}
</div>
</section>
<section>
<h3>Find sockets, do something with them</h3>
<p>Declare which sockets do you want to play with with a socket predicate and define what you want to do with them with a socket action. This simple functional programming model brings a new level of expressiveness and readability in socket handling.</p>
<div class="explanation">
<p>For all sockets, send <code>chat</code> event with <code>message</code> data.</p>
{% capture panel %}
```java
server.find(socket -> true, socket -> socket.send("chat", message));
```
{% endcapture %}{{ panel | markdownify }}
<p>Or, in short with <code>ServerSocketPredicates#all</code> and <code>Sentence#send</code>.</p>
{% capture panel %}
```java
server.find(all()).send("chat", message);
```
{% endcapture %}{{ panel | markdownify }}
<p>Limiting only one socket per user in one line.</p>
{% capture panel %}
```java
server.find(attr("username", username).and(id(socket).negate())).send("klose").close();
```
{% endcapture %}{{ panel | markdownify }}
<p>It finds sockets whose username is the same except the given <code>socket</code>, sends a <code>klose</code> event to prevent reconnection, and closes the sockets.</p>
</div>
</section>
<section>
<h3>Recover missed events declaratively</h3>
<p>The Cettia socket lifecycle is designed to be unaffected by temporary disconnections which happen commonly especially in the mobile environment. Declaratively decide and collect missed events to recover and send them on the next connection.</p>
<div class="explanation">
<p>Collect events failed to send due to no connection in the <code>cache</code> event and resend them in the <code>open</code> event fired when the connection is recovered within 1 minute since the disconnection.</p>
{% capture panel %}
```java
List<Object[]> cache = new CopyOnWriteArrayList<>();
socket.oncache((Object[] args) -> cache.add(args));
socket.onopen(v -> cache.forEach(args -> {
cache.remove(args);
socket.send((String) args[0], args[1], (Action<?>) args[2], (Action<?>) args[3]);
}));
```
{% endcapture %}{{ panel | markdownify }}
<p>After 1 minute has elapsed since the disconnection, <code>delete</code> event is fired. Here, you can send an email or push notifications about events which the socket finally missed.</p>
</div>
</section>
<section>
<h3>Scale out horizontally</h3>
<p>Cettia servers scale out horizontally using messaging passing without sharing any data between them. Any publish-subscribe messaging system can be used and it doesn't require any modification in the existing application.</p>
<div class="explanation">
<p>With Hazelcast, in-memory data grid based on Java, you can scale a Cettia application out as follows.</p>
{% capture panel %}
```java
((io.cettia.ClusteredServer) server).onpublish((message) -> {
topic.publish(message);
});
((com.hazelcast.core.ITopic) topic).addMessageListener(message -> {
server.messageAction().on(message.getMessageObject());
});
```
{% endcapture %}{{ panel | markdownify }}
<p>The message contains a socket predicate and a socket action used to call the <code>server.find</code> method. It is broadcast to every server in the cluster including one originally received the method call and applies to every server's sockets.</p>
</div>
</section>
<section>
<h2>Resources</h2>
<p>Here are a list of resources to help you get started with Cettia:</p>
<ul>
<li>
<a href="/guides/getting-started">Getting Started With Cettia</a>
<p>A quick start guide for those who are new to Cettia.</p>
</li>
<li>
<a href="https://github.com/cettia/cettia-starter-kit" target="_blank">Cettia Starter Kit</a>
<p>A starter kit to help you get started.</p>
</li>
<li>
<a href="/guides/cettia-tutorial">Building Real-Time Web Applications With Cettia</a>
<p>A reference documentation in the form of a tutorial.</p>
</li>
</ul>
<p>Browse community-driven resources as well:</p>
<ul>
<li><a href="https://github.com/ralscha/cettia-demo" target="blank">Various demo applications using Cettia and Spring 5</a> by Ralph Schaer</li>
<li><a href="https://golb.hplar.ch/2019/01/cettia-springboot.html" target="blank">Real-time messaging with Cettia and Spring Boot</a> by Ralph Schaer</li>
</ul>
</section>
<section>
<h2>Community</h2>
<p>As an open source project licensed under Apache License 2.0, Cettia has started since 2011 with the name of jQuery Stream by Donghwan Kim and grown into a full-featured real-time web framework for Java with the continued love and support from the community. If you are interested and would like to be more involved, feel free to join the community and share your feedback.</p>
<ul class="menu">
<li><a href="https://github.com/cettia" target="_blank">GitHub</a></li>
<li><a href="https://twitter.com/flowersits" target="_blank">Twitter</a></li>
<li><a href="http://groups.google.com/group/cettia" target="_blank">Mailing list</a></li>
</ul>
</section>
</div>
</div>
</div>