Skip to content

Commit 1f358aa

Browse files
committed
fixing #267
1 parent 0035f77 commit 1f358aa

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

websocket/atmosphere-chat/src/main/java/org/javaee7/websocket/atmosphere/ChatEndpoint.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,41 @@
1-
*
1+
/*
2+
* Copyright 2013 Jeanfrancois Arcand
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package org.javaee7.websocket.atmosphere;
17+
18+
import org.atmosphere.config.service.Disconnect;
19+
import org.atmosphere.config.service.ManagedService;
20+
import org.atmosphere.config.service.Ready;
21+
import org.atmosphere.cpr.AtmosphereResource;
22+
import org.atmosphere.cpr.AtmosphereResourceEvent;
23+
import org.slf4j.Logger;
24+
import org.slf4j.LoggerFactory;
25+
26+
import java.io.IOException;
27+
28+
/**
29+
* Simple annotated class that demonstrate the power of Atmosphere. This class supports all transports, support
30+
* message length guarantee, heart beat, message cache thanks to the @ManagedAService.
31+
*
32+
* The client will first try with WebSocket and then fallback using the client's preference.
33+
*/
34+
@ManagedService(path = "/chat")
35+
public class ChatEndpoint {
36+
private final Logger logger = LoggerFactory.getLogger(ChatEndpoint.class);
37+
38+
/** *
239
* @param r
340
*/
441
@Ready

websocket/atmosphere-chat/src/main/java/org/javaee7/websocket/atmosphere/Message.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
/*
2+
* Copyright 2013 Jeanfrancois Arcand
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package org.javaee7.websocket.atmosphere;
17+
18+
import java.util.Date;
19+
20+
public class Message {
21+
22+
private String message;
23+
private String author;
24+
private long time;
25+
26+
public Message() {
27+
this("", "");
28+
}
29+
30+
public Message(String author, String message) {
31+
this.author = author;
32+
this.message = message;
33+
this.time = new Date().getTime();
34+
}
35+
36+
public String getMessage() {
37+
return message;
38+
}
39+
140
public String getAuthor() {
241
return author;
342
}

websocket/atmosphere-chat/src/main/webapp/javascript/application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ $(function () {
4444
content.html($('<p>', { text: 'Atmosphere re-connected using ' + response.transport }));
4545
};
4646

47-
<!-- For demonstration of how you can customize the fallbackTransport using the onTransportFailure function -->
47+
// For demonstration of how you can customize the fallbackTransport using the onTransportFailure function
4848
request.onTransportFailure = function(errorMsg, request) {
4949
atmosphere.util.info(errorMsg);
5050
request.fallbackTransport = "long-polling";

0 commit comments

Comments
 (0)