当前位置: 首页>>代码示例>>Java>>正文


Java Jid类代码示例

本文整理汇总了Java中rocks.xmpp.core.Jid的典型用法代码示例。如果您正苦于以下问题:Java Jid类的具体用法?Java Jid怎么用?Java Jid使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Jid类属于rocks.xmpp.core包,在下文中一共展示了Jid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testOn

import rocks.xmpp.core.Jid; //导入依赖的package包/类
@Test
@Suspendable
public void testOn() throws Exception {

    Channel<String> channel = Channels.newChannel(0);

    r.on("image\\s+me\\s+ninjas", (request, o) -> channel.send("testOn"));
    r.on("some other stuff", (request, c) -> fail("incorrect handler triggered"));

    r.triggerHandlersForMessageText("@Mars image me ninjas", new Response(Jid.valueOf("[email protected]"), dummy));

    String result;
    int recv = 0;

    while((result=channel.receive(defaultTimeout)) != null)
    {
        if (!result.equals("testOn")) {
            fail("incorrect message received from event");
        } else {
            recv++;
        }
    }

    assertTrue("correct message not received before timeout (or received more than once)", recv==1);

}
 
开发者ID:ninjabear,项目名称:marissa-java,代码行数:27,代码来源:RouterTest.java

示例2: testWhenContains

import rocks.xmpp.core.Jid; //导入依赖的package包/类
@Test
@Suspendable
public void testWhenContains() throws Exception {

    Channel<String> channel = Channels.newChannel(0);

    r.whenContains(".*turtles.*", (request, o) -> channel.send("done"));
    r.on("some other stuff", (request, c) -> fail("incorrect handler triggered"));

    r.triggerHandlersForMessageText("the world loves some turtles now and again", new Response(Jid.valueOf("[email protected]"), dummy));

    String result;
    int recv = 0;

    while((result=channel.receive(defaultTimeout)) != null)
    {
        if (!result.equals("done")) {
            fail("incorrect message received from event");
        } else {
            recv++;
        }
    }

    assertTrue("correct message not received before timeout (or received more than once)", recv==1);

}
 
开发者ID:ninjabear,项目名称:marissa-java,代码行数:27,代码来源:RouterTest.java

示例3: load

import rocks.xmpp.core.Jid; //导入依赖的package包/类
/**
 * Creates a bean from the result {@link #dump()}
 *
 * @param aDump
 *            The result of {@link #dump()}
 * @return The created bean, or null
 */
public static XmppAccess load(final Object aDump) {

    if (aDump instanceof String) {
        try {
            // Parse the JID and prepare the bean
            final Jid jid = Jid.valueOf(aDump.toString());
            return new XmppAccess(jid);

        } catch (final IllegalArgumentException ex) {
            // Bad JID
            return null;
        }
    }

    // Unhandled kind of dump
    return null;
}
 
开发者ID:cohorte,项目名称:cohorte-herald,代码行数:25,代码来源:XmppAccess.java

示例4: getJid

import rocks.xmpp.core.Jid; //导入依赖的package包/类
/**
 * Looks for the JID to use to communicate with a peer
 *
 * @param aPeer
 *            A peer bean or null
 * @param aExtra
 *            The extra information for a reply or null
 * @return The JID to use to reply, or null
 */
private Jid getJid(final Peer aPeer, final XmppExtra aExtra) {

    Jid jid = null;
    if (aExtra != null) {
        // Try to use the extra information
        jid = aExtra.getSenderJid();
    }

    // Try to read information from the peer
    if (jid == null && aPeer != null) {
        final XmppAccess access = (XmppAccess) aPeer
                .getAccess(IXmppConstants.ACCESS_ID);
        if (access != null) {
            jid = access.getJid();
        }
    }

    return jid;
}
 
开发者ID:cohorte,项目名称:cohorte-herald,代码行数:29,代码来源:XmppTransport.java

示例5: onRoomCreated

import rocks.xmpp.core.Jid; //导入依赖的package包/类
@Override
public void onRoomCreated(final Jid aRoomJid, final String aNick) {

    synchronized (pCountdowns) {
        final Set<MarksCallback<Jid>> toRemove = new LinkedHashSet<>();
        for (final MarksCallback<Jid> marksCallback : pCountdowns) {
            // Mark the room
            marksCallback.set(aRoomJid);

            // Check for cleanup
            if (marksCallback.isDone()) {
                toRemove.add(marksCallback);
            }
        }

        // Clean up
        pCountdowns.removeAll(toRemove);
    }
}
 
开发者ID:cohorte,项目名称:cohorte-herald,代码行数:20,代码来源:XmppTransport.java

示例6: onRoomError

import rocks.xmpp.core.Jid; //导入依赖的package包/类
@Override
public void onRoomError(final Jid aRoomJid, final String aNick,
        final String aCondition, final String aDescription) {

    synchronized (pCountdowns) {
        final Set<MarksCallback<Jid>> toRemove = new LinkedHashSet<>();
        for (final MarksCallback<Jid> marksCallback : pCountdowns) {
            // Mark the room
            marksCallback.setError(aRoomJid);

            // Check for cleanup
            if (marksCallback.isDone()) {
                toRemove.add(marksCallback);
            }
        }

        // Clean up
        pCountdowns.removeAll(toRemove);
    }

    pLogger.log(LogService.LOG_ERROR, "Error creating room: "
            + aDescription + " (" + aCondition + ")");
}
 
开发者ID:cohorte,项目名称:cohorte-herald,代码行数:24,代码来源:XmppTransport.java

示例7: onRoomOut

import rocks.xmpp.core.Jid; //导入依赖的package包/类
@Override
public void onRoomOut(final Jid aRoomJid, final Occupant aOccupant) {

    final String uid = aOccupant.getNick();
    final Jid appRoomJid = getRoomJid(pDirectory.getApplicationId());

    if (!aOccupant.isSelf() && aRoomJid.equals(appRoomJid)) {
        // Someone else is leaving the main room: clean up the directory
        try {
            final Peer peer = pDirectory.getPeer(uid);
            peer.unsetAccess(IXmppConstants.ACCESS_ID);
            pLogger.log(LogService.LOG_DEBUG, "Peer " + peer
                    + " disconnected from XMPP");

        } catch (final UnknownPeer ex) {
            // Ignore
        }
    }
}
 
开发者ID:cohorte,项目名称:cohorte-herald,代码行数:20,代码来源:XmppTransport.java

示例8: sendMessage

import rocks.xmpp.core.Jid; //导入依赖的package包/类
/**
 * Prepares and sends a message over XMPP
 *
 * @param aType
 *            Kind of message (chat or groupchat)
 * @param aJid
 *            Target JID or MUC room
 * @param aMessage
 *            Herald message bean
 * @param aParentUid
 *            UID of the message this one replies to (optional)
 * @throws MarshallException
 *             Error converting the content of the message to JSON
 */
private void sendMessage(final Type aType, final Jid aJid,
        final Message aMessage, final String aParentUid)
        throws MarshallException {

	// update headers
	aMessage.addHeader(Message.MESSAGE_HEADER_SENDER_UID, pDirectory.getLocalUid());
    // Convert content to JSON        
	final String content = MessageUtils.toJSON(aMessage);
	
    // Prepare the XMPP message
    final rocks.xmpp.core.stanza.model.client.Message xmppMsg = new rocks.xmpp.core.stanza.model.client.Message(
            aJid, aType, content);
    xmppMsg.setFrom(pBot.getJid());
    xmppMsg.setSubject(aMessage.getSubject());
    xmppMsg.setThread(aMessage.getUid());
    if (aParentUid != null) {
        xmppMsg.setParentThread(aParentUid);
    }

    // Send it
    pBot.send(xmppMsg);
}
 
开发者ID:cohorte,项目名称:cohorte-herald,代码行数:37,代码来源:XmppTransport.java

示例9: create

import rocks.xmpp.core.Jid; //导入依赖的package包/类
/**
 * Implements 'http://xmpp.org/protocol/openlink:01:00:00#manage-voice-message' Create.
 * 
 * Creates a playlist.
 * 
 * @param to
 *            Openlink XMPP component.
 * @param profile
 *            the Openlink profile.
 * @param label
 *            the playlist label.
 * @param messageIds
 *            the Message ID/Keys to include in the playlist.
 * @return a collection of playlists.
 * @throws XmppException
 */
public Collection<VoiceMessage> create(String to, Profile profile, String label, Set<String> messageIds) throws XmppException {
	ManageVoiceMessage mvm = new ManageVoiceMessage();
	mvm.getIn().setProfile(profile.getId());
	mvm.getIn().setAction(ManageVoiceMessageAction.Create);
	mvm.getIn().setLabel(label);

	Set<ManageVoiceMessageFeature> mvmFeatures = new HashSet<ManageVoiceMessage.ManageVoiceMessageFeature>();
	for (String id : messageIds) {
		ManageVoiceMessageFeature mvmFeature = new ManageVoiceMessageFeature();
		mvmFeature.setId(id);
		mvmFeatures.add(mvmFeature);
	}
	mvm.getIn().setFeatures(mvmFeatures);

	IQ iq = new IQ(Jid.valueOf(to), IQ.Type.SET, mvm);
	IQ iqResult = xmppSession.query(iq);

	Collection<VoiceMessage> messages = getVoiceMessagesFromIQ(iqResult);

	return messages;
}
 
开发者ID:Globility,项目名称:openlink-java,代码行数:38,代码来源:ManageVoiceMessageHandler.java

示例10: query

import rocks.xmpp.core.Jid; //导入依赖的package包/类
/**
 * Implements 'http://xmpp.org/protocol/openlink:01:00:00#manage-voice-message' Query.
 * 
 * @param to
 *            Openlink XMPP component.
 * @param profile
 *            the Openlink profile.
 * @param messageIds
 *            the Message ID/Keys.
 * @return a collection of messages and playlists.
 * @throws XmppException
 */
public Collection<VoiceMessage> query(String to, Profile profile, Set<String> messageIds) throws XmppException {
	ManageVoiceMessage mvm = new ManageVoiceMessage();
	mvm.getIn().setProfile(profile.getId());
	mvm.getIn().setAction(ManageVoiceMessageAction.Query);

	Set<ManageVoiceMessageFeature> mvmFeatures = new HashSet<ManageVoiceMessage.ManageVoiceMessageFeature>();
	for (String id : messageIds) {
		ManageVoiceMessageFeature mvmFeature = new ManageVoiceMessageFeature();
		mvmFeature.setId(id);
		mvmFeatures.add(mvmFeature);
	}
	mvm.getIn().setFeatures(mvmFeatures);

	IQ iq = new IQ(Jid.valueOf(to), IQ.Type.SET, mvm);
	IQ iqResult = xmppSession.query(iq);

	Collection<VoiceMessage> messages = getVoiceMessagesFromIQ(iqResult);

	return messages;
}
 
开发者ID:Globility,项目名称:openlink-java,代码行数:33,代码来源:ManageVoiceMessageHandler.java

示例11: playback

import rocks.xmpp.core.Jid; //导入依赖的package包/类
/**
 * Implements 'http://xmpp.org/protocol/openlink:01:00:00#manage-voice-message' Playback.
 * 
 * @param to
 *            Openlink XMPP component.
 * @param profile
 *            the Openlink profile.
 * @param messageIds
 *            the Message ID/Keys.
 * @return a collection of messages and playlists.
 * @throws XmppException
 */
public Collection<VoiceMessage> playback(String to, Profile profile, Set<String> messageIds) throws XmppException {
	ManageVoiceMessage mvm = new ManageVoiceMessage();
	mvm.getIn().setProfile(profile.getId());
	mvm.getIn().setAction(ManageVoiceMessageAction.Playback);

	Set<ManageVoiceMessageFeature> mvmFeatures = new HashSet<ManageVoiceMessage.ManageVoiceMessageFeature>();
	for (String id : messageIds) {
		ManageVoiceMessageFeature mvmFeature = new ManageVoiceMessageFeature();
		mvmFeature.setId(id);
		mvmFeatures.add(mvmFeature);
	}
	mvm.getIn().setFeatures(mvmFeatures);

	IQ iq = new IQ(Jid.valueOf(to), IQ.Type.SET, mvm);
	IQ iqResult = xmppSession.query(iq);

	Collection<VoiceMessage> messages = getVoiceMessagesFromIQ(iqResult);

	return messages;
}
 
开发者ID:Globility,项目名称:openlink-java,代码行数:33,代码来源:ManageVoiceMessageHandler.java

示例12: archive

import rocks.xmpp.core.Jid; //导入依赖的package包/类
public Collection<VoiceMessage> archive(String to, Profile profile, Set<String> messageIds) throws XmppException {
	Collection<VoiceMessage> messages = new ArrayList<VoiceMessage>();

	ManageVoiceMessage mvm = new ManageVoiceMessage();
	mvm.getIn().setProfile(profile.getId());
	mvm.getIn().setAction(ManageVoiceMessageAction.Archive);

	Set<ManageVoiceMessageFeature> mvmFeatures = new HashSet<ManageVoiceMessage.ManageVoiceMessageFeature>();
	for (String id : messageIds) {
		ManageVoiceMessageFeature mvmFeature = new ManageVoiceMessageFeature();
		mvmFeature.setId(id);
		mvmFeatures.add(mvmFeature);
	}
	mvm.getIn().setFeatures(mvmFeatures);

	IQ iq = new IQ(Jid.valueOf(to), IQ.Type.SET, mvm);
	IQ iqResult = xmppSession.query(iq);

	messages = getVoiceMessagesFromIQ(iqResult);

	return messages;
}
 
开发者ID:Globility,项目名称:openlink-java,代码行数:23,代码来源:ManageVoiceMessageHandler.java

示例13: edit

import rocks.xmpp.core.Jid; //导入依赖的package包/类
/**
 * Implements 'http://xmpp.org/protocol/openlink:01:00:00#manage-voice-message' Playback.
 * 
 * @param to
 *            Openlink XMPP component.
 * @param profile
 *            the Openlink profile.
 * @param label
 *            the new message label.
 * @param messageIds
 *            the Message ID/Keys.
 * @return a collection of messages and playlists.
 * @throws XmppException
 */
public Collection<VoiceMessage> edit(String to, Profile profile, String label, Set<String> messageIds) throws XmppException {
	Collection<VoiceMessage> messages = new ArrayList<VoiceMessage>();

	ManageVoiceMessage mvm = new ManageVoiceMessage();
	mvm.getIn().setProfile(profile.getId());
	mvm.getIn().setAction(ManageVoiceMessageAction.Edit);
	mvm.getIn().setLabel(label);

	Set<ManageVoiceMessageFeature> mvmFeatures = new HashSet<ManageVoiceMessage.ManageVoiceMessageFeature>();
	for (String id : messageIds) {
		ManageVoiceMessageFeature mvmFeature = new ManageVoiceMessageFeature();
		mvmFeature.setId(id);
		mvmFeatures.add(mvmFeature);
	}
	mvm.getIn().setFeatures(mvmFeatures);

	IQ iq = new IQ(Jid.valueOf(to), IQ.Type.SET, mvm);
	IQ iqResult = xmppSession.query(iq);

	messages = getVoiceMessagesFromIQ(iqResult);

	return messages;
}
 
开发者ID:Globility,项目名称:openlink-java,代码行数:38,代码来源:ManageVoiceMessageHandler.java

示例14: save

import rocks.xmpp.core.Jid; //导入依赖的package包/类
/**
 * Implements 'http://xmpp.org/protocol/openlink:01:00:00#manage-voice-message' Playback.
 * 
 * @param to
 *            Openlink XMPP component.
 * @param profile
 *            the Openlink profile.
 * @param label
 *            the new message label.
 * @param audioFiles
 *            the Audio Files to save.
 * @return a collection of messages and playlists.
 * @throws XmppException
 */
public Collection<VoiceMessage> save(String to, Profile profile, String label, Set<AudioFile> audioFiles) throws XmppException {
	Collection<VoiceMessage> messages = new ArrayList<VoiceMessage>();

	ManageVoiceMessage mvm = new ManageVoiceMessage();
	mvm.getIn().setProfile(profile.getId());
	mvm.getIn().setAction(ManageVoiceMessageAction.Save);
	mvm.getIn().setLabel(label);
	mvm.getIn().setAudioFiles(audioFiles);

	IQ iq = new IQ(Jid.valueOf(to), IQ.Type.SET, mvm);
	IQ iqResult = xmppSession.query(iq);

	messages = getVoiceMessagesFromIQ(iqResult);

	return messages;
}
 
开发者ID:Globility,项目名称:openlink-java,代码行数:31,代码来源:ManageVoiceMessageHandler.java

示例15: getInterests

import rocks.xmpp.core.Jid; //导入依赖的package包/类
/**
 * Implements 'http://xmpp.org/protocol/openlink:01:00:00#get-interests'.
 *
 * @param to
 *            Openlink XMPP component.
 * @param profile
 *            User's profile.
 * @return collection of user's interests.
 */
public Collection<Interest> getInterests(String to, Profile profile) throws XmppException {
	Collection<Interest> result = new ArrayList<Interest>();

	GetInterests gi = new GetInterests();
	gi.getIn().setProfile(profile.getId());
	IQ iq = new IQ(Jid.valueOf(applySiteIdOnSystem(to)), IQ.Type.SET, gi);
	IQ iqResult = xmppSession.query(iq);

	Command command = iqResult.getExtension(Command.class);
	if (command != null) {
		validateCommandNoteTypeError(command);
		IoData ioData = command.getExtension(IoData.class);
		if (ioData != null && ioData.getOut() != null) {
			Interests interests = ioData.getOut().getExtension(Interests.class);
			if (interests != null) {
				result = interests.getInterests();
			}
		}
	}
	return result;
}
 
开发者ID:Globility,项目名称:openlink-java,代码行数:31,代码来源:OpenlinkClient.java


注:本文中的rocks.xmpp.core.Jid类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。