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


Java Roster.createEntry方法代码示例

本文整理汇总了Java中org.jivesoftware.smack.Roster.createEntry方法的典型用法代码示例。如果您正苦于以下问题:Java Roster.createEntry方法的具体用法?Java Roster.createEntry怎么用?Java Roster.createEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.smack.Roster的用法示例。


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

示例1: perform

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
    Action action = Action.valueOf(sampler.getPropertyAsString(ACTION, Action.get_roster.toString()));
    Roster roster = sampler.getXMPPConnection().getRoster();
    String entry = sampler.getPropertyAsString(ENTRY);
    res.setSamplerData(action.toString() + ": " + entry);
    if (action == Action.get_roster) {
        res.setResponseData(rosterToString(roster).getBytes());
    } else if (action == Action.add_item) {
        roster.createEntry(entry, entry, new String[0]);
    } else if (action == Action.delete_item) {
        RosterEntry rosterEntry = roster.getEntry(entry);
        if (rosterEntry != null) {
            roster.removeEntry(rosterEntry);
        }
    }

    return res;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:20,代码来源:RosterAction.java

示例2: addBuddy

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
void addBuddy(final Buddy buddy) {
	Runnable r = new Runnable() {
		
		@Override
		public void run() {
			try {
				XMPPCommonService service = getInternalService().getService();
				Roster roster = getInternalService().getConnection().getRoster();
				roster.createEntry(buddy.getProtocolUid(), buddy.getName(), (buddy.getGroupId() != null && !buddy.getGroupId().equals(ApiConstants.NO_GROUP_ID)) ? new String[] { buddy.getGroupId() } : new String[0]);
				service.getCoreService().buddyAction(
						ItemAction.ADDED, 
						service.getEntityAdapter().rosterEntry2Buddy(
								roster.getEntry(buddy.getProtocolUid()), 
								service.getProtocolUid(), 
								service.getContext(), 
								service.getServiceId()));
			} catch (XMPPException e) {
				Logger.log(e);
				getInternalService().getService().getCoreService().notification( e.getLocalizedMessage());
			}
		}
	};
	
	Executors.defaultThreadFactory().newThread(r).start();
}
 
开发者ID:snuk182,项目名称:aceim,代码行数:26,代码来源:XMPPRosterListener.java

示例3: doAddContactToListAsync

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
@Override
protected void doAddContactToListAsync(String address, ContactList list) throws ImException {
    debug(TAG, "add contact to " + list.getName());
    org.jivesoftware.smack.packet.Presence response = new org.jivesoftware.smack.packet.Presence(
            org.jivesoftware.smack.packet.Presence.Type.subscribed);
    response.setTo(address);

    sendPacket(response);

    Roster roster = mConnection.getRoster();
    String[] groups = new String[] { list.getName() };
    try {
        Contact contact = makeContact(address);
        roster.createEntry(address, contact.getName(), groups);

        // If contact exists locally, don't create another copy
        
        if (!list.containsContact(contact))
            notifyContactListUpdated(list, ContactListListener.LIST_CONTACT_ADDED, contact);
        else
            debug(TAG, "skip adding existing contact locally " + contact.getName());
    } catch (XMPPException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:prive,项目名称:prive-android,代码行数:26,代码来源:XmppConnection.java

示例4: addUser

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 添加好友
 *
 * @param
 * @param userName
 * @param name
 * @param groupName 是否有分组
 * @return
 */
public boolean addUser(String userName, String name, String groupName) {
    Roster roster = con.getRoster();
    try {
        roster.createEntry(userName, name, null == groupName ? null
                : new String[]{groupName});
        return true;
    } catch (XMPPException e) {
        SLog.e(tag, Log.getStackTraceString(e));
    }
    return false;
}
 
开发者ID:jiangzehui,项目名称:xmpp,代码行数:21,代码来源:XmppTool.java

示例5: addUser

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 添加一个好友  无分组
 */
public static boolean addUser(Roster roster,String userName,String name)
{
	try {
		roster.createEntry(userName, name, null);
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}
	
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:15,代码来源:XmppUtil.java

示例6: addUsers

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 添加一个好友到分组
 * @param roster
 * @param userName
 * @param name
 * @return
 */
public static boolean addUsers(Roster roster,String userName,String name,String groupName)
{
	try {
		roster.createEntry(userName, name,new String[]{ groupName});
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		Log.e("jj", "添加好友异常:"+e.getMessage());
		return false;
	}
	
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:20,代码来源:XmppUtil.java

示例7: becomeFriends

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
public static void becomeFriends(XMPPConnection con0, XMPPConnection con1) throws XMPPException {
    Roster r0 = con0.getRoster();
    Roster r1 = con1.getRoster();
    r0.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
    r1.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
    r0.createEntry(con1.getUser(), "u2", null);
    r1.createEntry(con0.getUser(), "u1", null);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:9,代码来源:ConnectionUtils.java

示例8: addUser

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * ��Ӻ���
 * 
 * @param roster
 * @param userName
 * @param name
 * @param groupName
 *            �Ƿ��з���
 * @return
 */
public boolean addUser(Roster roster, String userName, String name,
		String groupName) {
	try {
		roster.createEntry(userName, name, null == groupName ? null
				: new String[] { groupName });
		return true;
	} catch (XMPPException e) {
		SLog.e(tag, Log.getStackTraceString(e));
	}
	return false;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:22,代码来源:XmppConnectionManager.java

示例9: addUser

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * ���һ������  �޷���
 */
public static boolean addUser(Roster roster,String userName,String name)
{
	try {
		roster.createEntry(userName, name, null);
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}
	
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:15,代码来源:XmppService.java

示例10: getImage

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
private void getImage(String requestAgent, String workgroup, HttpServletRequest request, HttpServletResponse response) {
    ChatManager chatManager = ChatManager.getInstance();

    boolean isOnline = WorkgroupStatus.isOnline(workgroup);
    final SettingsManager imageManager = SettingsManager.getInstance();

    final Roster roster = chatManager.getGlobalConnection().getRoster();
    final Presence presence = roster.getPresence(requestAgent);

    isOnline = isOnline && presence != null && presence.getType() == Presence.Type.available;

    if (!isOnline) {
        Object o = roster.getEntry(requestAgent);
        if (o == null) {
            try {
                roster.createEntry(requestAgent, requestAgent, null);
            }
            catch (XMPPException e) {
               WebLog.logError("Error creating new roster entry:", e);
            }
        }
    }

    byte[] image;
    if (isOnline) {
        image = imageManager.getImage("personalonline", workgroup, getServletContext());
    }
    else {
        image = imageManager.getImage("personaloffline", workgroup, getServletContext());
    }

    imageManager.writeBytesToStream(image, response);
}
 
开发者ID:igniterealtime,项目名称:Fastpath-webchat,代码行数:34,代码来源:DynamicImageServlet.java

示例11: getRoster

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
private void getRoster(){
	/*
	 * get the Roster and add the logaccount as a contact
	 */
	Roster roster = conn.getRoster();
	roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.accept_all);
	roster.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
	String[] groups= {"admins"};
	try {
		roster.createEntry(logAccount, logAccount,groups );
	} catch (XMPPException e) {
		e.printStackTrace();
	}
}
 
开发者ID:ControlAltDieliet,项目名称:system_updater,代码行数:15,代码来源:Bot.java

示例12: becomeFriends

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
public static void becomeFriends(Connection con0, Connection con1) throws XMPPException {
    Roster r0 = con0.getRoster();
    Roster r1 = con1.getRoster();
    r0.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
    r1.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
    r0.createEntry(con1.getUser(), "u2", null);
    r1.createEntry(con0.getUser(), "u1", null);
}
 
开发者ID:bejayoharen,项目名称:java-bells,代码行数:9,代码来源:ConnectionUtils.java

示例13: createEntry

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
public void createEntry(String user, String name) throws Exception {
	log.info(String.format("Creating entry for buddy '%1$s' with name %2$s", user, name));
	connect();
	Roster roster = connection.getRoster();
	roster.createEntry(user, name, null);
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:7,代码来源:XMPP.java

示例14: addEntry

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * Adds a new entry to the users Roster.
 *
 * @param jid      the jid.
 * @param nickname the nickname.
 * @param group    the contact group.
 * @return the new RosterEntry.
 */
public RosterEntry addEntry(String jid, String nickname, String group) {
    String[] groups = {group};

    Roster roster = SparkManager.getConnection().getRoster();
    RosterEntry userEntry = roster.getEntry(jid);

    boolean isSubscribed = true;
    if (userEntry != null) {
        isSubscribed = userEntry.getGroups().size() == 0;
    }

    if (isSubscribed) {
        try {
            roster.createEntry(jid, nickname, new String[]{group});
        }
        catch (XMPPException e) {
            Log.error("Unable to add new entry " + jid, e);
        }
        return roster.getEntry(jid);
    }


    try {
        RosterGroup rosterGroup = roster.getGroup(group);
        if (rosterGroup == null) {
            rosterGroup = roster.createGroup(group);
        }

        if (userEntry == null) {
            roster.createEntry(jid, nickname, groups);
            userEntry = roster.getEntry(jid);
        }
        else {
            userEntry.setName(nickname);
            rosterGroup.addEntry(userEntry);
        }

        userEntry = roster.getEntry(jid);
    }
    catch (XMPPException ex) {
        Log.error(ex);
    }
    return userEntry;
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:53,代码来源:SubscriptionDialog.java


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