public static byte[] packMsg(MsgHead msg)throws IOException{
		//ڴ
		java.io.ByteArrayOutputStream bous=new java.io.ByteArrayOutputStream();
		java.io.DataOutputStream dous=new java.io.DataOutputStream(bous);
		 writeHead(dous,msg);//дϢͷ,Ϣͷṹͬ
		int msgType=msg.getType();//ȡϢͱʶ
       if(msgType==IMsgConstance.command_login){//½
			 MsgLogin ml=(MsgLogin)msg;
			 writeString(dous,10,ml.getPwd());
		}
		else if(msgType==IMsgConstance.command_login_resp){//½Ӧ
			 MsgLoginResp mlr=(MsgLoginResp)msg;
			 dous.writeByte(mlr.getState());			
		}
		else if(msgType==IMsgConstance.command_reg){//ע
			 MsgReg ml=(MsgReg)msg;
			 writeString(dous,10,ml.getNikeName());
			 writeString(dous,10,ml.getPwd());
		}
		else if(msgType==IMsgConstance.command_reg_resp){//עӦ
			MsgRegResp mr=(MsgRegResp)msg;
			 dous.writeByte(mr.getState());
	      }
		else if(msgType==IMsgConstance.command_chatText){//½Ӧ
			 MsgChatText mt=(MsgChatText)msg;
			 dous.write(mt.getMsgContent().getBytes());
		}
		else if(msgType==IMsgConstance.command_chatFile){//ļݰ
			 MsgChatFile mt=(MsgChatFile)msg;
			 writeString(dous,256,mt.getFileName());
			 dous.write(mt.getFileData());//дļ
		}
		else if(msgType==IMsgConstance.command_find_resp){
			MsgFindResp mf=(MsgFindResp)msg;
			List<UserInfo> users=mf.getUsers();
			dous.writeInt(users.size());
			for(UserInfo user:users){
				writeString(dous,10,user.getNikeName());
				dous.writeInt(user.getJkNum());
			}
		}
		else if(msgType==IMsgConstance.command_teamList){//бݰ
			MsgTeamList mdb= (MsgTeamList)msg;
			 List<TeamInfo> teams=mdb.getTeamLists();
			 int listsCount=teams.size();//
			 //джٸ
			 dous.writeInt(listsCount);
			 for(TeamInfo team:teams){
				 //дһ
				 writeString(dous,10,team.getName());
				   List<UserInfo> users=team.getBudyList();
				 //джٸѶ
				 dous.writeByte(users.size());
				 for(UserInfo user:users){
					 //дÿһѵjk
					 dous.writeInt(user.getJkNum());
					 //дÿһѵس
					 writeString(dous,10,user.getNikeName());
				 }
			 }
		} //Ӻ:      
		 else if(msgType==IMsgConstance.command_addFriend){
			 MsgAddFriend mt=(MsgAddFriend)msg;
			 //Ҫĺѵĺ
			 dous.writeInt(mt.getFriendJkNum());
	        }//ӺѵӦ:
		 else if(msgType==IMsgConstance.command_addFriend_Resp){
			 MsgAddFriendResp mt=(MsgAddFriendResp)msg;
			 dous.writeInt(mt.getFriendJkNum());//Ҫĺѵĺ
			 writeString(dous,10,mt.getFriendNikeName());
		}
		 else if(msgType==IMsgConstance.command_offLine
			||msgType==IMsgConstance.command_onLine
			||msgType==IMsgConstance.command_find){//Ϣ
			 
	 }else{
    String logMsg="δ֪Ϣͣ޷:type:"+msgType;
	LogTools.ERROR(ToolsCreateMsg.class, logMsg);//¼־
		  }
         dous.flush();
		byte[] data=bous.toByteArray();
		return data;//ش,Է㷢
	}