You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by "Andrey Bogdanov (JIRA)" <ji...@apache.org> on 2013/06/07 08:39:21 UTC
[jira] [Comment Edited] (OPENMEETINGS-662) Code contribution -
mathematical whiteboard
[ https://issues.apache.org/jira/browse/OPENMEETINGS-662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13677860#comment-13677860 ]
Andrey Bogdanov edited comment on OPENMEETINGS-662 at 6/7/13 6:38 AM:
----------------------------------------------------------------------
Some comments about using this code.
1. Add js, css and image files from bin folder to you project.
2. Add html-element which will contain whiteboard
3. Create whiteboard with using call bay.whiteboard.Create()
4. Render created whiteboard to the html-element using whiteboard.render
5. Example is in given html-file
To use synchronisation create websocket chat-server. Below is a sample code based on org.apache.catalina.websocket.WebSocketServlet
Link websocket address to whiteboard: whiteboard.linkWebSocket('ws://host:port/path');
Sample websocket server:
public class WhiteboardWebSocketServlet extends WebSocketServlet {
private static final long serialVersionUID = 2L;
// Set of connected clients
private final Set<WBMessageInbound> connections = new CopyOnWriteArraySet<WBMessageInbound>();
@Override
protected StreamInbound createWebSocketInbound(String subProtocol, HttpServletRequest request) {
return new WBMessageInbound();
}
private final class WBMessageInbound extends MessageInbound {
@Override
protected void onOpen(WsOutbound outbound) {
connections.add(this);
}
@Override
protected void onClose(int status) {
connections.remove(this);
}
@Override
protected void onBinaryMessage(ByteBuffer message) throws IOException {
throw new UnsupportedOperationException("Binary message not supported.");
}
@Override
protected void onTextMessage(CharBuffer message) throws IOException {
// translate the message to all other clients
for (WBMessageInbound connection : connections) {
try {
if (connection != this)
connection.getWsOutbound().writeTextMessage(message);
} catch (IOException ignore) {
}
}
}
}
}
was (Author: bay73):
Some comments about using this code.
1. Add js, css and image files from bin folder to you project.
2. Add html-element which will contain whiteboard
3. Create whiteboard with using call bay.whiteboard.Create()
4. Render created whiteboard to the html-element using whiteboard.render
5. Example is in given html-file
To use synchronisation create websocket chat-server. Below is a sample code based on org.apache.catalina.websocket.WebSocketServlet
Link websocket address to whiteboard: whiteboard.linkWebSocket('ws://host:port/path');
Sample websocket server:
public class WhiteboardWebSocketServlet extends WebSocketServlet {
private static final long serialVersionUID = 2L;
// Set of connected clients
private final Set<WBMessageInbound> connections = new CopyOnWriteArraySet<WBMessageInbound>();
@Override
protected StreamInbound createWebSocketInbound(String subProtocol, HttpServletRequest request) {
return new WBMessageInbound();
}
private final class WBMessageInbound extends MessageInbound {
@Override
protected void onOpen(WsOutbound outbound) {
connections.add(this);
}
@Override
protected void onClose(int status) {
connections.remove(this);
}
@Override
protected void onBinaryMessage(ByteBuffer message) throws IOException {
throw new UnsupportedOperationException("Binary message not supported.");
}
@Override
protected void onTextMessage(CharBuffer message) throws IOException {
// translate the message to all other clients
for (WBMessageInbound connection : connections) {
try {
if (connection != this)
connection.getWsOutbound().writeTextMessage(message);
} catch (IOException ignore) {
}
}
}
}
}
> Code contribution - mathematical whiteboard
> -------------------------------------------
>
> Key: OPENMEETINGS-662
> URL: https://issues.apache.org/jira/browse/OPENMEETINGS-662
> Project: Openmeetings
> Issue Type: Improvement
> Components: HTML5
> Reporter: Andrey Bogdanov
> Priority: Minor
> Attachments: bin.zip, src.zip
>
>
> Source code for mathematical whiteboard is attached. It can be used as alternate whiteboard for openmeetings
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira