moto web application
修訂 | ea9e2d0c5c30b75af2e93606fa1451bdbe16f25b (tree) |
---|---|
時間 | 2014-02-05 17:30:06 |
作者 | astoria-d <astoria-d@mail...> |
Commiter | astoria-d |
push utf-8 charecter supported
@@ -3,10 +3,12 @@ package motoSample; | ||
3 | 3 | import org.atmosphere.config.service.Disconnect; |
4 | 4 | import org.atmosphere.config.service.ManagedService; |
5 | 5 | import org.atmosphere.config.service.Ready; |
6 | +import org.atmosphere.config.service.Get; | |
6 | 7 | import org.atmosphere.cpr.AtmosphereResource; |
7 | 8 | import org.atmosphere.cpr.AtmosphereResourceEvent; |
8 | 9 | import org.slf4j.Logger; |
9 | 10 | import org.slf4j.LoggerFactory; |
11 | +import javax.servlet.http.HttpServletResponse; | |
10 | 12 | |
11 | 13 | import static org.atmosphere.cpr.ApplicationConfig.MAX_INACTIVE; |
12 | 14 |
@@ -25,6 +27,15 @@ public class AtmosRes { | ||
25 | 27 | logger.info("Browser {} connected.", r.uuid()); |
26 | 28 | } |
27 | 29 | |
30 | + @Get | |
31 | + public void onGet(final AtmosphereResource r) { | |
32 | + logger.info("Browser Get from {}", r.uuid()); | |
33 | + //set character encoding... | |
34 | + HttpServletResponse response = r.getResponse(); | |
35 | + response.setCharacterEncoding("UTF-8"); | |
36 | + //response.setContentType("application/json;charset=UTF-8"); | |
37 | + } | |
38 | + | |
28 | 39 | /** |
29 | 40 | * Invoked when the client disconnect or when an unexpected closing of the underlying connection happens. |
30 | 41 | * |
@@ -183,7 +183,7 @@ public class ChatBean implements Serializable { | ||
183 | 183 | |
184 | 184 | //in order to update the display, notify the message to the other chat users (including myself.). |
185 | 185 | PushMsg pm = PushMsg.newChatMessage(); |
186 | - PushMsg.ChatMessage cm = pm.getChatMessage(); | |
186 | + ChatMessage cm = pm.getChatMessage(); | |
187 | 187 | cm.setMsg(msg); |
188 | 188 | cm.setDate(dt); |
189 | 189 | cm.setUname(userBean.getUid()); |
@@ -1,5 +1,6 @@ | ||
1 | 1 | package motoSample; |
2 | 2 | |
3 | +import motoSample.ChatBean.ChatMessage; | |
3 | 4 | |
4 | 5 | public class PushMsg { |
5 | 6 |
@@ -13,19 +14,6 @@ public class PushMsg { | ||
13 | 14 | public boolean getLogin() { return login; } |
14 | 15 | } |
15 | 16 | |
16 | - public static class ChatMessage { | |
17 | - private String uname; | |
18 | - private String msg; | |
19 | - private String date; | |
20 | - | |
21 | - public String getUname() { return uname; } | |
22 | - public String getMsg() { return msg; } | |
23 | - public String getDate() { return date; } | |
24 | - public void setUname(String uname) { this.uname = uname; } | |
25 | - public void setMsg(String msg) { this.msg = msg; } | |
26 | - public void setDate(String date) { this.date = date; } | |
27 | - } | |
28 | - | |
29 | 17 | private String pushType; |
30 | 18 | private LoginUser lu; |
31 | 19 | private ChatMessage cm; |