Skip to content

Instantly share code, notes, and snippets.

T 127.0.0.1:61314 -> 127.0.0.1:8080 [AP]
GET /chat?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.1.4-javascript&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&X-Cache-Date=0&Content-Type=application/json&X-atmo-protocol=true HTTP/1.1.
Upgrade: websocket.
Connection: Upgrade.
Host: 127.0.0.1:8080.
Origin: http://127.0.0.1:8080.
Pragma: no-cache.
Cache-Control: no-cache.
Sec-WebSocket-Key: 8e5n55kJPeEH9LJjG2chWw==.
Sec-WebSocket-Version: 13.
@PushEndpoint("/chat/{room}")
@Singleton
public class ChatResource {
private final Logger logger = LoggerFactory.getLogger(ChatResource.class);
/**
* The client is sending a JSON message which is decoded as Message object. From the Message, we grab the
* remote's endpoint userName and create a PrivateTarget. The PrivateTarget will be used when a message
* needs to be delivered only to that connection.
@jfarcand
jfarcand / gist:8852670
Created February 6, 2014 21:20
Netty Byte Copy Writer
/*
* Copyright 2014 Jeanfrancois Arcand
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
5:58:55.964 [main] INFO com.poweredbypace.pace.AtmoTest - Num connections=299, memory: total:505 MB, max:505 MB, free:2 MB, used=503 MB
15:58:59.130 [main] INFO com.poweredbypace.pace.AtmoTest - Num connections=303, memory: total:505 MB, max:505 MB, free:1 MB, used=504 MB
15:59:01.680 [main] INFO com.poweredbypace.pace.AtmoTest - Num connections=307, memory: total:505 MB, max:505 MB, free:2 MB, used=503 MB
15:59:07.154 [main] INFO com.poweredbypace.pace.AtmoTest - Num connections=311, memory: total:505 MB, max:505 MB, free:0 MB, used=505 MB
15:59:10.189 [main] INFO com.poweredbypace.pace.AtmoTest - Num connections=320, memory: total:505 MB, max:505 MB, free:0 MB, used=505 MB
15:59:13.497 [main] INFO com.poweredbypace.pace.AtmoTest - Num connections=324, memory: total:505 MB, max:505 MB, free:0 MB, used=505 MB
15:59:18.675 [New I/O worker #1] DEBUG o.a.nettosphere.BridgeRuntime - Exception
java.lang.OutOfMemoryError: Java heap space
15:59:18.676 [New I/O worker #1] DEBUG o.a.nettosphere.BridgeRuntime - E
@Test(groups = { "online", "default_provider" })
public void testWssRequestProxy() throws IOException, InterruptedException, ExecutionException, TimeoutException {
AsyncHttpClientConfig.Builder b = new AsyncHttpClientConfig.Builder();
b.setFollowRedirects(true);
ProxyServer ps = new ProxyServer(ProxyServer.Protocol.HTTPS, "127.0.0.1", port1);
AsyncHttpClientConfig config = b.build();
AsyncHttpClient asyncHttpClient = getAsyncHttpClient(config);
try {
@jfarcand
jfarcand / gist:8673186
Last active October 3, 2017 14:52
Primefaces Push 5.0
/*
* Copyright 2013 Jeanfrancois Arcand
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Magneto:gwt20-managed-rpc jfarcand$ rm -rf target/
Magneto:gwt20-managed-rpc jfarcand$ mvn install gwt:run
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.atmosphere.samples:gwt20-managed-rpc:war:2.1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.eclipse.jetty:jetty-maven-plugin is missing. @ org.atmosphere:atmosphere-samples-project:2.1.0-SNAPSHOT, /Users/jfarcand/workspace/atmosphere-samples/pom.xml, line 101, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
08:48:57.961 INFO [main] o.a.c.AtmosphereFramework [AtmosphereFramework.java:779] Atmosphere is using async support: org.atmosphere.container.Jetty9AsyncSupportWithWebSocket running under container: jetty/9.1.1.v20140108 with WebSocket enabled.
08:48:57.962 INFO [main] o.a.c.AtmosphereFramework [AtmosphereFramework.java:781] Atmosphere Framework 2.1.0-SNAPSHOT started.
08:48:57.962 INFO [main] o.a.c.AtmosphereFramework [AtmosphereFramework.java:783]
For Atmosphere Framework Commercial Support, visit
http://www.async-io.org/ or send an email to [email protected]
2014-01-14 08:48:57.969:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@26a549a8{/atmosphere-chat,file:/private/var/folders/lq/7wssqgvd6jzdwbt0vg06j8yc0000gn/T/jetty-0.0.0.0-8080-atmosphere-chat.war-_atmosphere-chat-any-368035570580900042.dir/webapp/,AVAILABLE}{/Users/jfarcand/workspace/containers/shared_webapps/atmosphere-chat.war}
2014-01-14 08:48:57.985:INFO:oejs.ServerConnector:main: Started ServerConnector@518bc6a4{HTTP/1.1}{0
@jfarcand
jfarcand / gist:8418528
Created January 14, 2014 13:47
Atmosphere + Jetty 9.1.0
08:46:44.732 INFO [main] o.a.c.AtmosphereFramework [AtmosphereFramework.java:779] Atmosphere is using async support: org.atmosphere.container.Jetty9AsyncSupportWithWebSocket running under container: jetty/9.1.0.v20131115 with WebSocket enabled.
08:46:44.734 INFO [main] o.a.c.AtmosphereFramework [AtmosphereFramework.java:781] Atmosphere Framework 2.1.0-SNAPSHOT started.
08:46:44.734 INFO [main] o.a.c.AtmosphereFramework [AtmosphereFramework.java:783]
For Atmosphere Framework Commercial Support, visit
http://www.async-io.org/ or send an email to [email protected]
2014-01-14 08:46:44.735:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@2feea189{/atmosphere-chat,file:/private/var/folders/lq/7wssqgvd6jzdwbt0vg06j8yc0000gn/T/jetty-0.0.0.0-8080-atmosphere-chat.war-_atmosphere-chat-any-8278089751165587569.dir/webapp/,AVAILABLE}{/Users/jfarcand/workspace/containers/shared_webapps/atmosphere-chat.war}
2014-01-14 08:46:44.750:INFO:oejs.ServerConnector:main: Started ServerConnector@5332f20b{HTTP/1.1}{
--- a/modules/cpr/src/main/java/org/atmosphere/cache/UUIDBroadcasterCache.java
+++ b/modules/cpr/src/main/java/org/atmosphere/cache/UUIDBroadcasterCache.java
@@ -139,8 +139,10 @@ public class UUIDBroadcasterCache implements BroadcasterCache {
} else {
String clientId = uuid(r);
- activeClients.put(clientId, now);
- addMessageIfNotExists(clientId, cacheMessage);
+ synchronized(clientId) {
+ activeClients.put(clientId, now);