Author: solomax
Date: Thu Dec 20 13:23:15 2012
New Revision: 1424454

URL: http://svn.apache.org/viewvc?rev=1424454&view=rev
Log:
Wicket: chat messages are sent and received by wicket

Modified:
    
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.html
    
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.java

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.html
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.html?rev=1424454&r1=1424453&r2=1424454&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.html
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.html
 Thu Dec 20 13:23:15 2012
@@ -28,12 +28,18 @@
                        }
                        Wicket.Event.subscribe("/websocket/message", 
function(jqEvent, message) {
                                $('#messageArea').append('<div>' + message + 
'</div>'); 
-                               // do something with the message.
-                               // it may be a text or a binary message 
depending on what you pushed from the server side
                        });
                </script>
        </wicket:head>
        <wicket:panel>
+               <!--  script type="text/javascript">
+                       alert("AAAA");
+                       Wicket.Event.subscribe("/websocket/message", 
function(jqEvent, message) {
+                               $('#messageArea').append('<div>' + message + 
'</div>'); 
+                               // do something with the message.
+                               // it may be a text or a binary message 
depending on what you pushed from the server side
+                       });
+               </script -->
                <!-- "ui-icon ui-icon-carat-1-n sort-icon", "ui-icon 
ui-icon-carat-1-s sort-icon" -->
                <div id="chat">
                        <div id="controlBlock" onclick="toggleChat();"><div 
id="control" class="ui-icon ui-icon-carat-1-n sort-icon"></div></div>

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.java?rev=1424454&r1=1424453&r2=1424454&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.java
 Thu Dec 20 13:23:15 2012
@@ -30,7 +30,8 @@ import org.apache.wicket.markup.html.for
 import org.apache.wicket.markup.html.form.TextArea;
 import org.apache.wicket.model.PropertyModel;
 import org.apache.wicket.protocol.ws.IWebSocketSettings;
-import org.apache.wicket.protocol.ws.api.WebSocketPushBroadcaster;
+import org.apache.wicket.protocol.ws.api.IWebSocketConnection;
+import org.apache.wicket.protocol.ws.api.IWebSocketConnectionRegistry;
 import org.apache.wicket.protocol.ws.api.message.IWebSocketPushMessage;
 import org.apache.wicket.protocol.ws.api.message.TextMessage;
 import org.red5.logging.Red5LoggerFactory;
@@ -41,7 +42,7 @@ public class ChatPanel extends UserPanel
        private static final long serialVersionUID = -9144707674886211557L;
        private String message;
        
-       private class ChatMessage extends TextMessage implements 
IWebSocketPushMessage, Serializable {
+       class ChatMessage extends TextMessage implements IWebSocketPushMessage, 
Serializable {
                private static final long serialVersionUID = 
-3802182673895471248L;
 
                public ChatMessage(String msg) {
@@ -62,15 +63,15 @@ public class ChatPanel extends UserPanel
                        
                        protected void onSubmit(AjaxRequestTarget target) {
                                //Application.getBean(ChatService) 
sendMessageToOverallChat
-                               new 
WebSocketPushBroadcaster(IWebSocketSettings.Holder.get(getApplication()).getConnectionRegistry())
-                                       .broadcastAll(getApplication(), new 
ChatMessage(message));
-                               /*for (IWebSocketConnection c : 
IWebSocketSettings.Holder.get(getApplication()).getConnectionRegistry().getConnections(getApplication()))
 {
+                               IWebSocketConnectionRegistry reg = 
IWebSocketSettings.Holder.get(getApplication()).getConnectionRegistry();
+                               //new 
WebSocketPushBroadcaster(reg).broadcastAll(getApplication(), new 
ChatMessage(message));
+                               for (IWebSocketConnection c : 
reg.getConnections(getApplication())) {
                                        try {
                                                c.sendMessage(message);
                                        } catch(Exception e) {
                                                log.error("Error while sending 
message", e);
                                        }
-                               }*/
+                               }
                                ChatPanel.this.message = "";
                                target.add(f);
                        };


Reply via email to