⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userinterface.java

📁 短信开发汇总
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
             DataInputStream data=new DataInputStream(new ByteArrayInputStream(buffer.getRecvBuffer()));
             int PacketLen=0;
             int CommandID=0;
             try{
                 PacketLen=data.readInt();
                 CommandID=data.readInt();
             }
             catch(Exception ex){
                 GlobalVar.WriteSysLog("userinterface","sgipsend",ex,GlobalVar.SYSTEM_BASE_ERROR_0);
                 nErrorCode.setErrorCodeString("接收submit resp 消息失败");
                 comm.CloseSocket();
                 return 1;
             }
             switch(CommandID){
                 case GlobalVar.ID_SGIP_TRACE:
                 case GlobalVar.ID_SGIP_TRACE_RESP:
                     count ++;
                     if(count==5){
                         nErrorCode.setErrorCodeString("发送submit后连续收到5条Trace消息");
                         comm.CloseSocket();
                         return 1;
                     }
                     continue;
                 case GlobalVar.ID_SGIP_SUBMIT_RESP:
                     SGIP_SubmitResp submit_resp=new SGIP_SubmitResp();
                     ret=submit_resp.parseBuffer(buffer.getRecvBuffer());
                     if(ret!=0){
                         nErrorCode.setErrorCodeString("收到错误的submit_resp 格式");
                         comm.CloseSocket();
                         return 1;
                     }
                     if(submit_resp.getResult()==0){
                         nErrorCode.setErrorCodeString("SGIPSEND发送单条成功!");
                         break;
                     }
                     else{
                         nErrorCode.setErrorCodeString("SGIPSEND 发送消息失败,服务器返回值="+Integer.toString(submit_resp.getResult()));
                         nErrorCode.setErrorCodeValue(submit_resp.getResult());
                         return 1;
                     }
                 default:
                     GlobalVar.WriteSysLog("UserInterface","SGIPSend","recv command unknows",GlobalVar.SYSTEM_BASE_ERROR_0);
                     comm.CloseSocket();
                     return 1;
                 }
                 break;
             }
         comm.CloseSocket();
         return 0;
     }
     public int SGIPDeliver(int nTimeOut,DeliverResp result,ErrorCode nErrorCode){
         if(nErrorCode==null){
             GlobalVar.WriteSysLog("UserInterface","SGIPDeliver","nErrorCode is null!",GlobalVar.SYSTEM_BASE_ERROR_0);
             return 1;
         }
         if(result==null){
             nErrorCode.setErrorCodeString("result is null");
             return 1;
         }
         if(nTimeOut <=20 || nTimeOut >60){
             nTimeOut=30;
         }
         int ret=0;
         if(recv_comm.socket==null){
             ret=recv_comm.LoginSGIP(2,nErrorCode);
             if(ret!=0){
                 return 1;
             }
         }
         ret=recv_comm.setSoTimeout(nTimeOut);
         if(ret!=0){
             nErrorCode.setErrorCodeString("设置timeout 失败");
             recv_comm.CloseSocket();
             return 1;
         }
         for(;;){
             ret=recv_comm.synRecvData(recv_buffer);
             if(ret!=0){
                 nErrorCode.setErrorCodeString("接收deliver消息失败");
                 recv_comm.CloseSocket();
                 return 1;
             }
             DataInputStream data=new DataInputStream(new ByteArrayInputStream(recv_buffer.getRecvBuffer()));
             int PacketLen=0;
             int CommandID=0;
             try{
                 PacketLen=data.readInt();
                 CommandID=data.readInt();
             }
             catch(Exception ex){
                 GlobalVar.WriteSysLog("UserInterface","SMGPDeliver",ex,GlobalVar.SYSTEM_BASE_ERROR_0);
                 nErrorCode.setErrorCodeString("接收deliver消息失败");
                 recv_comm.CloseSocket();
                 return 1;
             }
             switch(CommandID){
          /*   case GlobalVar.ID_SGIP_REPORT:
                 SGIP_Report report=new SGIP_Report();
                 ret=report.parseBuffer(recv_buffer.getRecvBuffer());
                 if(ret!=0){
                     nErrorCode.setErrorCodeString("收到错误的report格式");
                     recv_comm.CloseSocket();
                     return 1;
                 }
                 */
             case GlobalVar.ID_SGIP_DELIVER:
                 SGIP_Deliver deliver=new SGIP_Deliver();
                 ret=deliver.parseBuffer(recv_buffer.getRecvBuffer());
                 if(ret!=0){
                     nErrorCode.setErrorCodeString("收到错误的deliver格式");
                     recv_comm.CloseSocket();
                     return 1;
                 }
                 SGIP_DeliverResp deliver_resp=new SGIP_DeliverResp();
                 deliver_resp.head.PacketLength=deliver_resp.Length();
                 deliver_resp.head.RequestID=GlobalVar.ID_SGIP_DELIVER_RESP;
                 deliver_resp.head.Seq1=deliver.getSeq1();
                 deliver_resp.head.Seq2=deliver.getSeq2();
                 deliver_resp.head.Seq3=deliver.getSeq3();
                 deliver_resp.Result=0;
                 ret=deliver_resp.WriteProtocolData(recv_comm.getDataOutputStream());
                 if(ret!=0){
                     nErrorCode.setErrorCodeString("发送deliver resp 消息失败");
                     recv_comm.CloseSocket();
                     return 1;
                 }
                 ret=recv_comm.FlushOutputData();
                 if(ret!=0){
                     nErrorCode.setErrorCodeString("发送Deliver resp 消息失败");
                     recv_comm.CloseSocket();
                     return 1;
                 }
                 result.setSPNumber(deliver.getSPNumber());
                 result.setUserNumber(deliver.getUserNumber());
                 result.setTPpid(deliver.getTP_pid());
                 result.setTPudhi(deliver.getTP_udhi());
                 result.setMessageCoding(deliver.getMessageCoding());
                 result.setMessageLength(deliver.getMessageLength());
                 result.setMessageContent(deliver.getMessageContent());
                 result.setReserve(deliver.getReserve());
                 nErrorCode.setErrorCodeString("SGIPDeliver成功!");
                 return 0;
             default:
                 GlobalVar.WriteSysLog("UserInterface","SMGPDeliver","receive command unknown",GlobalVar.SYSTEM_BASE_ERROR_0);
                 nErrorCode.setErrorCodeString("收到错误的Command!");
                 recv_comm.CloseSocket();
                 return 1;
             }
         }
     }
     public int SGIPReport(int nTimeOut,ReportResp result,ErrorCode nErrorCode){
         if(nErrorCode==null){
             GlobalVar.WriteSysLog("UserInterface","SGIPReport","nErrorCode is null!",GlobalVar.SYSTEM_BASE_ERROR_0);
             return 1;
         }
         if(result==null){
             nErrorCode.setErrorCodeString("result is null");
             return 1;
         }
         if(nTimeOut <=20 || nTimeOut >60){
             nTimeOut=30;
         }
         int ret=0;
         if(recv_comm.socket==null){
             ret=recv_comm.LoginSGIP(1,nErrorCode);
             if(ret!=0){
                 return 1;
             }
         }
         ret=recv_comm.setSoTimeout(nTimeOut);
         if(ret!=0){
             nErrorCode.setErrorCodeString("设置timeout 失败");
             recv_comm.CloseSocket();
             return 1;
         }
         for(;;){
             ret=recv_comm.synRecvData(recv_buffer);
             if(ret!=0){
                 nErrorCode.setErrorCodeString("接收Report消息失败");
                 recv_comm.CloseSocket();
                 return 1;
             }
             DataInputStream data=new DataInputStream(new ByteArrayInputStream(recv_buffer.getRecvBuffer()));
             int PacketLen=0;
             int CommandID=0;
             try{
                 PacketLen=data.readInt();
                 CommandID=data.readInt();
             }
             catch(Exception ex){
                 GlobalVar.WriteSysLog("UserInterface","SMGPReport",ex,GlobalVar.SYSTEM_BASE_ERROR_0);
                 nErrorCode.setErrorCodeString("接收report消息失败");
                 recv_comm.CloseSocket();
                 return 1;
             }
             switch(CommandID){
          /*   case GlobalVar.ID_SGIP_REPORT:
                 SGIP_Report report=new SGIP_Report();
                 ret=report.parseBuffer(recv_buffer.getRecvBuffer());
                 if(ret!=0){
                     nErrorCode.setErrorCodeString("收到错误的report格式");
                     recv_comm.CloseSocket();
                     return 1;
                 }
                 */
             case GlobalVar.ID_SGIP_REPORT:
                 SGIP_Report report=new SGIP_Report();
                 ret=report.parseBuffer(recv_buffer.getRecvBuffer());
                 if(ret!=0){
                     nErrorCode.setErrorCodeString("收到错误的report格式");
                     recv_comm.CloseSocket();
                     return 1;
                 }
                 SGIP_ReportResp report_resp=new SGIP_ReportResp();
                 report_resp.head.PacketLength=report_resp.Length();
                 report_resp.head.RequestID=GlobalVar.ID_SGIP_REPORT_RESP;
                 report_resp.head.Seq1=report.getSeq1();
                 report_resp.head.Seq2=report.getSeq2();
                 report_resp.head.Seq3=report.getSeq3();
                 report_resp.Result=0;
                 ret=report_resp.WriteProtocolData(recv_comm.getDataOutputStream());
                 if(ret!=0){
                     nErrorCode.setErrorCodeString("发送Report resp 消息失败");
                     recv_comm.CloseSocket();
                     return 1;
                 }
                 ret=recv_comm.FlushOutputData();
                 if(ret!=0){
                     nErrorCode.setErrorCodeString("发送Report resp 消息失败");
                     recv_comm.CloseSocket();
                     return 1;
                 }
                 result.setSubmitSequenceNumber(report.getSubmitSequenceNumber());
                 result.setReportType(report.getReportType());
                 result.setUserNumber(report.getUserNumber());
                 result.setState(report.getState());
                 result.setErrorCode(report.getErrorCode());
                 result.setReserve(report.getReserve());
                 nErrorCode.setErrorCodeString("SGIPReport成功!");
                 return 0;
             default:
                 GlobalVar.WriteSysLog("UserInterface","SMGPReport","receive command unknown",GlobalVar.SYSTEM_BASE_ERROR_0);
                 nErrorCode.setErrorCodeString("收到错误的Command!");
                 recv_comm.CloseSocket();
                 return 1;
             }
         }
     }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -