Using CDORemoteSessionManager [message #1420643] |
Wed, 10 September 2014 09:03 |
UmaShankar Subramani Messages: 194 Registered: December 2011 Location: SWEDEN |
Senior Member |
|
|
I want to use CDORemoteSessionManager to send message from one session to another.
I can send the message to all RemoteSessions. But I do not know how to receive those sent messages. I looked into the javac doc of CDORemoteSessionManager. But still I do not understand how to receive the sent message.
I need to send an xml file from one session to other remote sessions. Is it possible to do this using CDORemoteSessionManager?
The method I use to send the message is given below:
private void sendMessage() {
InternalCDORemoteSessionManager remoteSessionManager = new CDORemoteSessionManagerImpl();
remoteSessionManager.setLocalSession(this.getSession());
remoteSessionManager.setForceSubscription(true);
remoteSessionManager.activate();
CDORemoteSession[] recipients=remoteSessionManager.getRemoteSessions();
for(CDORemoteSession session:recipients)
{
remoteSessionManager.handleRemoteSessionSubscribed(session.getSessionID(), true);
}
CDORemoteSessionMessage message = new CDORemoteSessionMessage("Fist Message");
remoteSessionManager.sendMessage(message, recipients);
}
thanks,
Uma Shankar
[Updated on: Wed, 10 September 2014 09:07] Report message to a moderator
|
|
|
|
|
Re: Using CDORemoteSessionManager [message #1423043 is a reply to message #1420654] |
Sat, 13 September 2014 20:50 |
UmaShankar Subramani Messages: 194 Registered: December 2011 Location: SWEDEN |
Senior Member |
|
|
Hi Eike and Esteban,
Thanks for you replies. It works now. Now I can send the file(ecore file) which I wanted to send from one session to all Remote Sessions using CDORemoteSessionMessage.
I send the message as given below:
CDORemoteSessionMessage message = new CDORemoteSessionMessage("type", ecoreByteArray);
remoteSessionManager.sendMessage(message, recipients);
I also received the SentMessage in RemoteSessions. But I cannot De-Serialize the ecore file from the inputStream successfully. The code is given below:
There is no exception thrown. The file is not created in the specified location at all. Please help.
@Override
protected void onMessageReceived(CDORemoteSession remoteSession,
CDORemoteSessionMessage message) {
File file=new File("d:\\","newFile.ecore");
URI fileURI = URI.createFileURI(file.getAbsolutePath());
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.createResource(fileURI);
try {
resource.load(message.getInputStream(),resourceSet.getLoadOptions());
} catch (IOException e) {
e.printStackTrace();
}
}
[Updated on: Sat, 13 September 2014 21:31] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03287 seconds