如何从另一个系统向SameTime用户发送消息?

时间:2011-04-01 16:30:07

标签: lotus instant-messaging sametime

我想我问的是有什么方法可以向用户发送SameTime消息?该版本是Notes 8.5中集成的版本。

是否有命令行,Web服务,.Net API,Java API,LotusScript Orr等?

1 个答案:

答案 0 :(得分:4)

有一个免费的Java API here。下面的摘录是一个如何发送消息的简单示例。

final STSession session = new STSession("SameTimeSender");
session.loadAllComponents();
session.start();

CommunityService comm = (CommunityService) session.getCompApi(CommunityService.COMP_NAME);
comm.addLoginListener(new LoginListener() {

    public void loggedOut(LoginEvent arg0) {
    }

    public void loggedIn(LoginEvent arg0) {
        LookupService lookup = (LookupService) session.getCompApi(LookupService.COMP_NAME);
        Resolver resolver = lookup.createResolver(true, false, true, false);
        resolver.addResolveListener(new ResolveListener() {

            public void resolved(ResolveEvent re) {
                STUser user = (STUser) re.getResolved();

                InstantMessagingService imservice = (InstantMessagingService) session.getCompApi(InstantMessagingService.COMP_NAME);

                final Im im = imservice.createIm(user, EncLevel.ENC_LEVEL_NONE, ImTypes.IM_TYPE_CHAT);
                im.addImListener(new ImListener() {

                    public void textReceived(ImEvent arg0) {
                    }

                    public void openImFailed(ImEvent arg0) {
                    }

                    public void imOpened(ImEvent arg0) {
                        im.sendText(false, "hello world!");
                    }

                    public void imClosed(ImEvent arg0) {
                    }

                    public void dataReceived(ImEvent arg0) {
                    }
                });
                im.open();
            }

            public void resolveFailed(ResolveEvent arg0) {
            }

            public void resolveConflict(ResolveEvent arg0) {
            }
        });

        resolver.resolve(recipientId);
    }
});

comm.loginByPassword(hostname, userId, password);