Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Using CDORemoteSessionManager
Using CDORemoteSessionManager [message #1420643] Wed, 10 September 2014 09:03 Go to next message
UmaShankar Subramani is currently offline UmaShankar SubramaniFriend
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 #1420651 is a reply to message #1420643] Wed, 10 September 2014 09:12 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi UmaShankar,

You can add a CDORemoteSessionManager.EventAdapter as listener to the
CDORemoteSessionManager. And by sending CDORemoteSessionMessage you can
send what you want as byte array.

Best Regards.

Le 10/09/2014 11:03, UmaShankar Subramani a écrit :
> 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 and
> CDORemoteSessionMessage?
Re: Using CDORemoteSessionManager [message #1420654 is a reply to message #1420643] Wed, 10 September 2014 09:15 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 10.09.2014 um 11:03 schrieb UmaShankar Subramani:
> 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 and CDORemoteSessionMessage?
Yes, you need to send a CDORemoteSessionMessage. Other clients need to add an IListener to their CDORemoteSessionManager
and handle the CDORemoteSessionEvent.MessageReceived events.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: Using CDORemoteSessionManager [message #1423043 is a reply to message #1420654] Sat, 13 September 2014 20:50 Go to previous messageGo to next message
UmaShankar Subramani is currently offline UmaShankar SubramaniFriend
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

Re: Using CDORemoteSessionManager [message #1423308 is a reply to message #1423043] Sun, 14 September 2014 07:24 Go to previous message
UmaShankar Subramani is currently offline UmaShankar SubramaniFriend
Messages: 194
Registered: December 2011
Location: SWEDEN
Senior Member
It works now. resource save statement was missing.

resource.save(null);

Previous Topic:Deserialize an Ecore File
Next Topic:CDORemoteSessionMessage for accessing a CDOModel
Goto Forum:
  


Current Time: Wed Apr 24 23:53:33 GMT 2024

Powered by FUDForum. Page generated in 0.03287 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top