use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.
the class ScribbleClient method createChannel.
protected void createChannel() throws ECFException {
// Get IChannelContainerAdapter adapter
IChannelContainerAdapter channelContainer = (IChannelContainerAdapter) container.getAdapter(IChannelContainerAdapter.class);
// Create channel ID with fixed name 'channel2'
final ID channelID = IDFactory.getDefault().createID(channelContainer.getChannelNamespace(), CHANNEL_ID);
// Setup listener so then when channelmessageevents are received that
// they present in UI
final IChannelListener channelListener = new IChannelListener() {
public void handleChannelEvent(final IChannelEvent event) {
if (event instanceof IChannelMessageEvent) {
IChannelMessageEvent msg = (IChannelMessageEvent) event;
scribbleView.handleDrawLine(msg.getData());
}
}
};
// Create new channel
IChannel channel = channelContainer.createChannel(channelID, channelListener, new HashMap());
// Set the view to use the given channel (for sending)
scribbleView.setChannel(channel);
}
use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.
the class GenericAuthConsumerContainerSelector method createContainer.
@Override
protected IRemoteServiceContainer createContainer(ContainerTypeDescription containerTypeDescription, String containerTypeDescriptionName, @SuppressWarnings("rawtypes") Map properties) throws SelectContainerException {
IRemoteServiceContainer result = super.createContainer(containerTypeDescription, containerTypeDescriptionName, properties);
ISharedObjectContainerClient client = (ISharedObjectContainerClient) result.getContainer().getAdapter(ISharedObjectContainerClient.class);
if (client != null) {
client.setConnectInitiatorPolicy(new IConnectInitiatorPolicy() {
public void refresh() {
}
public Object createConnectData(IContainer container, ID targetID, IConnectContext context) {
// to the server.
return getConnectData();
}
public int getConnectTimeout() {
return 30000;
}
});
}
return result;
}
use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.
the class Activator method createAndConfigureHostContainer.
private void createAndConfigureHostContainer(BundleContext context) throws Exception {
// Get IContainerManager singleton
ServiceTracker<IContainerManager, IContainerManager> containerManagerTracker = new ServiceTracker<IContainerManager, IContainerManager>(context, IContainerManager.class.getName(), null);
containerManagerTracker.open();
IContainerManager containerManager = containerManagerTracker.getService();
if (containerManager == null)
throw new NullPointerException("Cannot get IContainerManager service");
containerManagerTracker.close();
// Now create a hostContainer instance
hostContainer = containerManager.getContainerFactory().createContainer("ecf.generic.server");
// Get the ISharedObjectContainerGroupManager adapter interface
ISharedObjectContainerGroupManager hostManager = (ISharedObjectContainerGroupManager) hostContainer.getAdapter(ISharedObjectContainerGroupManager.class);
// Set connect policy
hostManager.setConnectPolicy(new IConnectHandlerPolicy() {
public void refresh() {
}
public PermissionCollection checkConnect(Object address, ID fromID, ID targetID, String targetGroup, Object connectData) throws Exception {
// What we will do when we receive a check connect call is to call
// verifyClientConnect
verifyClientConnect(fromID, connectData);
return null;
}
});
}
use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.
the class ChatRoomMessageHandler method preChatRoomConnect.
public void preChatRoomConnect(IChatRoomContainer roomContainer, ID roomID) {
// retrieve our name
ID connectedID = container.getConnectedID();
botName = connectedID.getName();
IChatID chatID = (IChatID) connectedID.getAdapter(IChatID.class);
if (chatID != null) {
botName = chatID.getUsername();
}
messageSenders.put(roomID, roomContainer.getChatRoomMessageSender());
if (password != null) {
try {
sendMessage(IDFactory.getDefault().createStringID("nickserv"), "identify " + password);
} catch (IDCreateException e) {
}
}
}
use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.
the class ChatRobotApplication method start.
/*
* (non-Javadoc)
*
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.
* IApplicationContext)
*/
public Object start(IApplicationContext context) throws Exception {
// process program arguments
String[] originalArgs = (String[]) context.getArguments().get("application.args");
if (originalArgs.length < 3) {
System.out.println("Parameters: <senderAccount> <senderPassword> <targetAccount> [<message>]. e.g. sender@gmail.com senderpassword receiver@gmail.com \"Hello there\"");
return new Integer(-1);
}
String message = null;
if (originalArgs.length > 3)
message = originalArgs[3];
// Create client
XMPPChatClient client = new XMPPChatClient(this, this);
// connect
client.connect(originalArgs[0], originalArgs[1]);
// Wait for 5s for the roster/presence information to be received
final Object lock = new Object();
synchronized (lock) {
lock.wait(5000);
}
// Get desired user ID from rosterUsers map. This is just looking for a user that's active and on our contacts list
ID targetID = (ID) rosterUsers.get(originalArgs[2]);
if (targetID == null) {
System.out.println("target user=" + originalArgs[2] + " is not on active on your contacts list. Cannot send message to this user");
return new Integer(0);
}
// Construct message
String msgToSend = (message == null) ? "Hi, I'm an ECF chat robot." : message;
System.out.println("ECF chat robot example sending to targetAccount=" + originalArgs[2] + " message=" + msgToSend);
// Send message to targetID
client.sendChat(targetID, msgToSend);
// Close up nicely and return
client.close();
return IApplication.EXIT_OK;
}
Aggregations