今天发现我用本机的IE8访问本机的Tomcat,和其他同事用IE8访问我的Tomcat,效果不一样,同样的事情已经发生很多次,然后想卸载IE8再重新安装,结果没找到地方卸载,原来是在控制面板的更新组件,不勾选就是卸载,勾选就是安装
在Appdelegate.ccp的bool AppDelegate::applicationDidFinishLaunching()函数中setDeviceOrientation(CCDeviceOrientationPortrait);设置的只是屏幕的方向,但显示内容依旧是横屏的。
return UIInterfaceOrientationIsLandscape( interfaceOrientation );
//肖像模式(竖屏)
return UIInterfaceOrientationIsPortrait( interfaceOrientation );return YES;
主要基于两张table实现:ofroster,ofrostergroups。
ofroster:用于记录好友关系(一对好友关系用两条记录来实现)
ofrostergroups:用于记录好友分组
特别说明:openfire中用户的主键是自然主键,也就是username。没有使用自增ID。
我们先来看一下官方(http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/database-guide.html)对 两张表的描述:
ofRoster (buddy rosters or lists)Column Name Type Length Description
rosterID NUMBER n/a ID of roster (Primary Key) username VARCHAR 32 User Name jid TEXT n/a The address of the roster entry sub NUMBER n/a The subscription status of the entry ask NUMBER n/a The ask status of the entry recv NUMBER n/a Flag indicating the entry is a roster request that was received nick VARCHAR 255 The nickname assigned to this roster entry
ofRosterGroups (Groups of buddy entries in a roster)Column Name Type Length Description
rosterID NUMBER n/a Roster ID (Primary Key) rank NUMBER n/a Position of the entry (Primary Key) groupName VARCHAR 255 The user defined name for this roster group
看不太明白?不要着急,我们慢慢分析。
假设有用户A,用户B。
当A申请加B为好友时(例如:A将B加入好亲人的分组中)。会在ofroster表中插入两条记录,
rosterID username jid sub ask recv nick
1 A B@192.168.1.102 0 0 -1 B
2 B A@192.168.1.102 0 -1 1 null
同时往ofrostergroups表中插入一条记录
rosterID rank groupName
1 0 亲人
这时B同意将A加为好友,并设置为家人分组中,那么会修改ofroster表中刚插入的两条记录,如下所示:
rosterID username jid sub ask recv nick
1 A B@192.168.1.102 1 -1 1 B
2 B A@192.168.1.102 2 0 -1 null
同时往ofrostergroups表中插入一条记录.
rosterID rank groupName
2 0 家人
到此为止,双方的好友关系便建立起来。
疑问:1.若B不同意呢?则不做任何操作。下一次,若B加A为好友,将等同于执行同意的操作。
2.如何查询某个人所有好友,和分组?
在ofroster中根据username便可获得某个用户的所有好友信息。然后根据每条记录的rosterid去ofrostergroups表中查找分组的名称即可。
3.当用户添加一个空的好友分组时,ofrostergroups表是否插入一条记录?
不插,测试发现并没有实质的插入一条记录,但用户可以看到这个分组名称,怎么回事?推测可能是存放在session中。测试发现当用户创建一个空的好友分组,然后下线,再上线时,发现该好友分组已消失。充分说明当好友分组为空时,并没有插库。
Notice the different status types? Here is a list of all of the different status types, witha brief description, also from the plugin's readme file.
askstatus- -1—The roster item has no pending subscription requests.
- 0—The roster item has been asked for permission to subscribe to its presence but no response has been received.
- 1—The roster owner has asked the roster item to be unsubscribed from its presence notifications but hasn't yet received confi rmation.
- -1—There are no subscriptions that have been received but not presented to the user.
- 1—The server has received a subscribe request, but has not forwarded it to the user.
- 2—The server has received an unsubscribe request, but has not forwarded it to the user.
- -1—Indicates that the roster item should be removed.
- 0—No subscription is established.
- 1—The roster owner has a subscription to the roster item’s presence.
- 2—The roster item has a subscription to the roster owner’s presence.
- 3—The roster item and the owner have a mutual subscription.
代码操作: PacketListener myListener = new PacketListener() { public void processPacket(Packet packet) { if(packet instanceof Message) { Message message = (Message) packet; String type = message.getType().toString(); if(type.equals("chat")) { //接收消息 if(message.getBody()!=null){ //保存信息到客户端数据库 } } } } else if(packet instanceof Presence) { Presence presence = (Presence) packet; String type = presence.getType().toString(); boolean b= TalkService.this.roster.contains(packet.getFrom()); Log.i(tag, b+""); Roster roster = connection.getRoster(); RosterEntry rosterEntry = roster.getEntry(presence.getFrom()); String itemType=""; if(rosterEntry!=null){ Log.e(tag, "PacketListener Presence: rosterEntry.getName()= "+rosterEntry.getName()+ " - rosterEntry.getUser()="+rosterEntry.getUser()+ " - rosterEntry.getStatus()="+rosterEntry.getStatus()+ " -rosterEntry.getType()= "+rosterEntry.getType()); itemType=rosterEntry.getType().toString(); } Log.e(tag, "itemType=="+itemType); if(type.equals("subscribe")) {//我收到对方的加好友的请求 //添加好友请求 FriendRelationParam param = new FriendRelationParam(); TalkCallback callback = new TalkCallback(); callback.from = getUId(presence.getFrom()); callback.to = getUId(presence.getTo()); try { param.callbackStr = callback.toJsonObject().toString(); } catch (Exception e) { e.printStackTrace(); } param.userId = Long.parseLong(callback.to); param.friendUid = Long.parseLong(callback.from); startFriendRelation(param); if("none".equals(itemType)){//收到对方的加好友的请求 Log.i(tag, "type="+type+" 我收到对方的加好友的请求"); } if("to".equals(itemType)){//我加对方好友后,对方同意,给我发回的交友请求 Log.i(tag, "type="+type+" 我加对方好友后,对方同意,给我发回的交友请求"); } }else if("subscribed".equals(type)){//对方同意加我为好友 if("both".equals(itemType)){//双方互为好友关系建立 Log.i(tag, "type="+type+" 双方互为好友关系建立!"); } Log.e("TalkService"+Thread.currentThread().getName(), presence.getFrom()+"同意了我["+packet.getTo()+"]的加好友请求 "); }else if(type.equals("unsubscribe")) {//对方发起了把我删除了||或者拒绝 //拒绝的时候只会走这A if("none".equals(itemType)){//拒绝 Log.i(tag, "type="+type+" 我被拒绝!!!"); } if("to".equals(itemType)){//我收到被对方删除 Log.i(tag, "type="+type+" 我收到被对方删除"); } }else if(type.equals("unsubscribed")) {//对方把我删除了 //删除的时候 会走A,同时再走一次这 if("none".equals(itemType)){// 我被删除 ,双方关系解除************************** Log.i(tag, "type="+type+" 我被删除的!!!"); } }else if(type.equals("available")) {//对方告诉我他在线 // presence = new Presence(Presence.Type.available); // presence.setTo(presence.getFrom()); // connection.sendPacket(presence); } }else if(packet instanceof AuthMechanism) { } } };