zoukankan      html  css  js  c++  java
  • xmpp这一段蛋疼的 坑,

    1,注释的地方 如果放出来,会 出现发送两遍消息的错觉,

    2,并且消息的 id有一模一样的,如果 刚好用这个做 id的话 会出现 主键约束,而 离线消息只能插入一条的情况,

    - (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message

    {

        TTLog(@"receive message -----------------%@",message);

        IMMessageInfo *iMessageInfo = [[IMRootManagershareManager]xmppMessageToChatMessage:message stateFlag:RECEIVE_SUCCESS];

        [[DBcontrolsharedDBControl] saveIMMessage:iMessageInfo];

        

        NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:message, IM_MESSAGE_BODY, nil];

        [[NSNotificationCenterdefaultCenter] postNotificationName:IM_MESSAGE_RECEIVEobject:selfuserInfo:userInfo];

        

        if([UIApplicationsharedApplication].applicationState == UIApplicationStateBackground){

            [selfpushLocalNotification:message];

        }

    //    if([message hasReceiptRequest]){

    //        XMPPMessage *responseMessage = [message generateReceiptResponse];

    //        NSXMLElement *body = [NSXMLElement elementWithName:@"body"];

    //        [body setStringValue:@"r"];

    //        [responseMessage addChild:body];

    //        [xmppStream sendElement:responseMessage];

    //    }

        if ([message isChatMessageWithBody]) {

            NSString *messageID = [ChatVoiceRecorderVC getCurrentTimeString];

            [message addAttributeWithName:@"id" stringValue:messageID];

            TTLog(@" message with id-----------------%@",message);

     

          

        }

       

    }

  • 相关阅读:
    Java基本数据类型
    Java位运算符
    Java条件编译
    Groovy学习笔记(二)
    Groovy学习笔记(一)
    Java开发环境搭建
    Java接口回调
    [精华][推荐]CAS SSO单点登录服务端客户端实例
    CAS SSO单点登录实例
    分布式架构springcloud+redis+springmvc+springboot
  • 原文地址:https://www.cnblogs.com/guligei/p/3645138.html
Copyright © 2011-2022 走看看