Skip to content

Instantly share code, notes, and snippets.

@ManagedService(path = "/pubsub{uc:/[A-Z]{3}[0-9]{4}}")
public class EventSocket {
@Message
public void onMessage(AtmosphereResponse response, String message) throws IOException {
response.write(message);
}
}
diff --git a/modules/javascript/src/main/webapp/javascript/atmosphere.js b/modules/javascript/src/main/webapp/javascript/atmosphere.js
index c519583..2ffcb01 100644
--- a/modules/javascript/src/main/webapp/javascript/atmosphere.js
+++ b/modules/javascript/src/main/webapp/javascript/atmosphere.js
@@ -1227,7 +1227,6 @@
}
if (!_request.enableProtocol) {
- webSocketOpened = true;
if (reopening) {
@jfarcand
jfarcand / Atmosphere_Framework.md
Last active August 29, 2015 13:56
Atmosphere Framework

Atmosphere - Realtime Client Server Framework for the JVM, supporting WebSockets and Cross-Browser Fallbacks Support

  • Lightweight API for writing portable asynchronous applications
  • Use WebSockets when available, either by using Native WebSocket API or jsr 356, and fallback to HTTP when not. All transparent for application. Developers focus on business logic, not the protocol!!
  • Ship with Native Javascript and JQuery clients side library for websockets and fallback transports like Server Side Events, Streaming, JSONP, HTMLFILE and long-polling. Also have built in support for Javascript's library like Sockjs, Socket.IO, Cometd, GWT
  • An Atmosphere Application can be used with IE 6+, Opera 10+, Firefox 3.5+, Chrome 4+, Safari 3+ and server like JBoss 7+, GlassFish 2+, Tomcat 4+, Jetty 6+, Vert.x 1.0+, Netty 3.2+ TRANSPARENTLY, e.g without any change r
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.