public static MsgHead parseMsg(byte[] data)throws Exception{
		int totalLen=data.length+4;//Ϣܳ
		java.io.ByteArrayInputStream bins=new java.io.ByteArrayInputStream(data);//תΪڴ
		java.io.DataInputStream dins=new java.io.DataInputStream(bins);
		byte msgType= dins.readByte();//ȡϢ
		int dest=dins.readInt();//ȡĿjk
		int src=dins.readInt();//ȡԴjk
		   MsgHead msgHead=new MsgHead();//Ϣͷݸֵ
		   msgHead.setTotalLen(totalLen);
		   msgHead.setType(msgType);
		   msgHead.setDest(dest);
		   msgHead.setSrc(src);
		if(msgType==IMsgConstance.command_login){//½
			String pwd=readString(dins,10);
			MsgLogin ml=new MsgLogin();
			copyHead(msgHead,ml);//Ϣͷ
			ml.setPwd(pwd);
			return ml;
			
		}
		else if(msgType==IMsgConstance.command_login_resp){//½Ӧ
			byte state=dins.readByte();//ȡ״ֶ̬Σһֽ
			MsgLoginResp ml=new MsgLoginResp();
			copyHead(msgHead,ml);//Ϣͷ
		    ml.setState(state);
			return ml;
			
		}else if(msgType==IMsgConstance.command_reg){
			MsgReg mr=new MsgReg();
			copyHead(msgHead,mr);
			String nikeName=readString(dins,10);
			mr.setNikeName(nikeName);
			String pwd=readString(dins,10);
			mr.setPwd(pwd);
			return mr;
	      }
		else if(msgType==IMsgConstance.command_reg_resp){
			MsgRegResp mr=new MsgRegResp();
			copyHead(msgHead,mr);
			mr.setState(dins.readByte());
			return mr;
	      }
		else if(msgType==IMsgConstance.command_chatText){//½Ӧ
			int len=totalLen-4-1-4-4;//ֽڵĳ
			String content=readString(dins,len);//ȡַ
			MsgChatText ml=new MsgChatText();
			copyHead(msgHead,ml);
		    ml.setMsgContent(content);
			return ml;
			
		}
		else if(msgType==IMsgConstance.command_chatFile){//ļݰ
			String fileName=readString(dins,256);//ȡļݰ
			int fileLen=totalLen-4-1-4-4-256;//ļֽڵĳ
			MsgChatFile ml=new MsgChatFile();
			copyHead(msgHead,ml);
		    ml.setFileName(fileName);
		    byte[] fileData=new byte[fileLen];
		    dins.readFully(fileData);
		    ml.setFileData(fileData);
			return ml;
		}else if(msgType==IMsgConstance.command_find_resp){
			MsgFindResp mf=new MsgFindResp();
			copyHead(msgHead,mf);
			int userCount=dins.readInt();
			for(int i=0;i<userCount;i++){
				String nakeName=readString(dins,10);
				int jkNum=dins.readInt();
				UserInfo user=new UserInfo(jkNum,nakeName);
				mf.addUserInfo(user);
			}
			return mf;
		}
		else if(msgType==IMsgConstance.command_teamList){//бݰ
			MsgTeamList mbl=new MsgTeamList();
			copyHead(msgHead,mbl);
			int listCount=dins.readInt();//ʶм
			List<TeamInfo> teamLists=new ArrayList();  
			while(listCount>0){
				  listCount--;
			  String teamName=readString(dins,10);//ȡһ
			  TeamInfo team=new TeamInfo(teamName);//һ
			  byte JKCount=dins.readByte();//мû
			  while(JKCount>0){
			  JKCount--;
			  int  jkNum=dins.readInt();//ȡһûjk
			  String budyNikeName=readString(dins,10);//ȡûس
			  UserInfo ui=new UserInfo(jkNum,budyNikeName);
			  team.addBudy(ui);
			  }
			  teamLists.add(team);
			  }
			mbl.setTeamLists(teamLists);
			return mbl;
		}
		//Ӻ
		 else if(msgType==IMsgConstance.command_addFriend){
			 MsgAddFriend mf=new MsgAddFriend();
				copyHead(msgHead,mf);
				int jkNum=dins.readInt();//Ҫĺѵĺ
				mf.setFriendJkNum(jkNum);
				return mf;
	        }
      //ӺѵӦ
		 else if(msgType==IMsgConstance.command_addFriend_Resp){
			 MsgAddFriendResp mfr=new MsgAddFriendResp();
			 copyHead(msgHead,mfr);
			  int jkNum=dins.readInt();//Ҫĺѵĺ
			 String nkName=readString(dins,10);
			 mfr.setFriendJkNum(jkNum);
			 mfr.setFriendNikeName(nkName);
			 return mfr;
		}
		else if(msgType==IMsgConstance.command_offLine
			||msgType==IMsgConstance.command_onLine
			||msgType==IMsgConstance.command_find){//Ϣ
				return msgHead;
			}
		else{
		 String logMsg="δ֪Ϣͣ޷:type:"+msgType;
		 LogTools.ERROR(ToolsParseMsg.class, logMsg);//¼־
		}
		return null;
	}