Java Code Examples for net.fs.utils.ByteIntConvert

The following examples show how to use net.fs.utils.ByteIntConvert. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: NSS   Source File: DataMessage.java    License: Apache License 2.0 6 votes vote down vote up
public void create(int timeId){
	this.timeId=timeId;
	dpData=new byte[this.length+16+8];
	ByteShortConvert.toByteArray(ver, dpData, 0);  //add: ver
	ByteShortConvert.toByteArray(sType, dpData, 2);  //add: service type
	
	ByteIntConvert.toByteArray(connectId, dpData, 4); //add: sequence
	ByteIntConvert.toByteArray(clientId, dpData, 8); //add: sequence
	
	ByteIntConvert.toByteArray(this.sequence, dpData, 12); //add: sequence
	ByteShortConvert.toByteArray((short) this.length, dpData, 16); //add:length
	ByteIntConvert.toByteArray(this.timeId, dpData, 18); //add: sequence
	System.arraycopy(this.data, 0, dpData, 22, this.length);
	dp=new DatagramPacket(dpData,dpData.length);
	dp.setAddress(dstAddress);
	dp.setPort(dstPort);
	
}
 
Example 2
Source Project: finalspeed-91yun   Source File: DataMessage.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void create(int timeId){
	this.timeId=timeId;
	dpData=new byte[this.length+16+8];
	ByteShortConvert.toByteArray(ver, dpData, 0);  //add: ver
	ByteShortConvert.toByteArray(sType, dpData, 2);  //add: service type
	
	ByteIntConvert.toByteArray(connectId, dpData, 4); //add: sequence
	ByteIntConvert.toByteArray(clientId, dpData, 8); //add: sequence
	
	ByteIntConvert.toByteArray(this.sequence, dpData, 12); //add: sequence
	ByteShortConvert.toByteArray((short) this.length, dpData, 16); //add:length
	ByteIntConvert.toByteArray(this.timeId, dpData, 18); //add: sequence
	System.arraycopy(this.data, 0, dpData, 22, this.length);
	dp=new DatagramPacket(dpData,dpData.length);
	dp.setAddress(dstAddress);
	dp.setPort(dstPort);
	
}
 
Example 3
Source Project: finalspeed   Source File: DataMessage.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void create(int timeId) {
    this.timeId = timeId;
    dpData = new byte[this.length + 16 + 8];
    ByteShortConvert.toByteArray(ver, dpData, 0);  //add: ver
    ByteShortConvert.toByteArray(sType, dpData, 2);  //add: service type

    ByteIntConvert.toByteArray(connectId, dpData, 4); //add: sequence
    ByteIntConvert.toByteArray(clientId, dpData, 8); //add: sequence

    ByteIntConvert.toByteArray(this.sequence, dpData, 12); //add: sequence
    ByteShortConvert.toByteArray((short) this.length, dpData, 16); //add:length
    ByteIntConvert.toByteArray(this.timeId, dpData, 18); //add: sequence
    System.arraycopy(this.data, 0, dpData, 22, this.length);
    dp = new DatagramPacket(dpData, dpData.length);
    dp.setAddress(dstAddress);
    dp.setPort(dstPort);

}
 
Example 4
Source Project: NSS   Source File: AckListMessage.java    License: Apache License 2.0 5 votes vote down vote up
public AckListMessage(DatagramPacket dp){
	this.dp=dp;
	dpData=dp.getData();
	ver=ByteShortConvert.toShort(dpData, 0);
	sType=ByteShortConvert.toShort(dpData, 2);
	connectId=ByteIntConvert.toInt(dpData, 4);
	clientId=ByteIntConvert.toInt(dpData, 8);
	
	
	lastRead=ByteIntConvert.toInt(dpData, 4+8);
	int sum=ByteShortConvert.toShort(dpData, 8+8);
	ackList=new ArrayList<Integer>();
	int t=0;
	for(int i=0;i<sum;i++){
		t=10+4*i;
		int sequence=ByteIntConvert.toInt(dpData, t+8);
		ackList.add(sequence);
	}
	////#MLog.println("LLLLLLLLLLLLLL "+dp.getLength()+" "+ackList.size());
	t=10+4*sum-4;
	r1=ByteIntConvert.toInt(dpData, t+4+8);
	s1=ByteIntConvert.toInt(dpData, t+8+8);

	r2=ByteIntConvert.toInt(dpData, t+12+8);
	s2=ByteIntConvert.toInt(dpData, t+16+8);

	r3=ByteIntConvert.toInt(dpData, t+20+8);
	s3=ByteIntConvert.toInt(dpData, t+24+8);

	////#MLog.println("aaaaaaaaa"+r3+"kkkkkkk "+s3);
}
 
Example 5
Source Project: NSS   Source File: CloseMessage_Stream.java    License: Apache License 2.0 5 votes vote down vote up
public CloseMessage_Stream(int connectId,int clientId,int closeOffset){
	byte[] dpData=new byte[16];
	this.clientId=clientId;
	this.connectId=connectId;
	ByteShortConvert.toByteArray(ver, dpData, 0);  //add: ver
	ByteShortConvert.toByteArray(sType, dpData, 2);  //add: service type
	ByteIntConvert.toByteArray(connectId, dpData, 4); //add: sequence
	ByteIntConvert.toByteArray(clientId, dpData, 8); //add: sequence
	ByteIntConvert.toByteArray(closeOffset, dpData, 12); //add: sequence
	dp=new DatagramPacket(dpData,dpData.length);
	////#MLog.println("vCloseMessageaaa"+clientId+"v");
}
 
Example 6
Source Project: NSS   Source File: CloseMessage_Stream.java    License: Apache License 2.0 5 votes vote down vote up
public CloseMessage_Stream(DatagramPacket dp){
	this.dp=dp;
	dpData=dp.getData();
	ver=ByteShortConvert.toShort(dpData, 0);
	sType=ByteShortConvert.toShort(dpData, 2);
	
	connectId=ByteIntConvert.toInt(dpData, 4);
	clientId=ByteIntConvert.toInt(dpData, 8);
	closeOffset=ByteIntConvert.toInt(dpData, 12);
	////#MLog.println("vCloseMessagebbb"+clientId+"v");
}
 
Example 7
Source Project: NSS   Source File: PingMessage.java    License: Apache License 2.0 5 votes vote down vote up
public PingMessage(int connectId,int clientId,int pingId,int downloadSpeed,int uploadSpeed){
	ByteShortConvert.toByteArray(ver, dpData, 0);  //add: ver
	ByteShortConvert.toByteArray(sType, dpData, 2);  //add: service type
	ByteIntConvert.toByteArray(connectId, dpData, 4); //add: sequence
	ByteIntConvert.toByteArray(clientId, dpData, 8); //add: sequence
	ByteIntConvert.toByteArray(pingId, dpData, 12); //add: sequence
	ByteShortConvert.toByteArray((short) (downloadSpeed/1024), dpData, 16);
	ByteShortConvert.toByteArray((short) (uploadSpeed/1024), dpData, 18);
	dp=new DatagramPacket(dpData,dpData.length);
}
 
Example 8
Source Project: NSS   Source File: PingMessage.java    License: Apache License 2.0 5 votes vote down vote up
public PingMessage(DatagramPacket dp){
	this.dp=dp;
	dpData=dp.getData();
	ver=ByteShortConvert.toShort(dpData, 0);
	sType=ByteShortConvert.toShort(dpData, 2);
	connectId=ByteIntConvert.toInt(dpData, 4);
	clientId=ByteIntConvert.toInt(dpData, 8);
	pingId=ByteIntConvert.toInt(dpData, 12);
	downloadSpeed=ByteShortConvert.toShort(dpData, 16);
	uploadSpeed=ByteShortConvert.toShort(dpData, 18);
}
 
Example 9
Source Project: NSS   Source File: CloseMessage_Conn.java    License: Apache License 2.0 5 votes vote down vote up
public CloseMessage_Conn(int connectId,int clientId){
	byte[] dpData=new byte[12];
	this.clientId=clientId;
	this.connectId=connectId;
	ByteShortConvert.toByteArray(ver, dpData, 0);
	ByteShortConvert.toByteArray(sType, dpData, 2);
	ByteIntConvert.toByteArray(connectId, dpData, 4);
	ByteIntConvert.toByteArray(clientId, dpData, 8);
	dp=new DatagramPacket(dpData,dpData.length);
}
 
Example 10
Source Project: NSS   Source File: CloseMessage_Conn.java    License: Apache License 2.0 5 votes vote down vote up
public CloseMessage_Conn(DatagramPacket dp){
	this.dp=dp;
	dpData=dp.getData();
	ver=ByteShortConvert.toShort(dpData, 0);
	sType=ByteShortConvert.toShort(dpData, 2);
	connectId=ByteIntConvert.toInt(dpData, 4);
	clientId=ByteIntConvert.toInt(dpData, 8);
}
 
Example 11
Source Project: NSS   Source File: DataMessage.java    License: Apache License 2.0 5 votes vote down vote up
public DataMessage(DatagramPacket dp){
	this.dp=dp;
	dpData=dp.getData();
	ver=ByteShortConvert.toShort(dpData, 0);
	sType=ByteShortConvert.toShort(dpData, 2);
	
	connectId=ByteIntConvert.toInt(dpData, 4);
	clientId=ByteIntConvert.toInt(dpData, 8);
	
	sequence=ByteIntConvert.toInt(dpData, 12);
	length=ByteShortConvert.toShort(dpData, 16);
	timeId=ByteIntConvert.toInt(dpData, 18);
	data=new byte[length];
	System.arraycopy(dpData, 22, data, 0, length);
}
 
Example 12
Source Project: NSS   Source File: PingMessage2.java    License: Apache License 2.0 5 votes vote down vote up
public PingMessage2(int connectId,int clientId,int pingId){
	ByteShortConvert.toByteArray(ver, dpData, 0);  //add: ver
	ByteShortConvert.toByteArray(sType, dpData, 2);  //add: service type
	ByteIntConvert.toByteArray(connectId, dpData, 4); //add: sequence
	ByteIntConvert.toByteArray(clientId, dpData, 8); //add: sequence
	ByteIntConvert.toByteArray(pingId, dpData, 12); //add: sequence
	dp=new DatagramPacket(dpData,dpData.length);
}
 
Example 13
Source Project: NSS   Source File: PingMessage2.java    License: Apache License 2.0 5 votes vote down vote up
public PingMessage2(DatagramPacket dp){
	this.dp=dp;
	dpData=dp.getData();
	ver=ByteShortConvert.toShort(dpData, 0);
	sType=ByteShortConvert.toShort(dpData, 2);
	connectId=ByteIntConvert.toInt(dpData, 4);
	clientId=ByteIntConvert.toInt(dpData, 8);
	pingId=ByteIntConvert.toInt(dpData, 12);
}
 
Example 14
public AckListMessage(DatagramPacket dp){
	this.dp=dp;
	dpData=dp.getData();
	ver=ByteShortConvert.toShort(dpData, 0);
	sType=ByteShortConvert.toShort(dpData, 2);
	connectId=ByteIntConvert.toInt(dpData, 4);
	clientId=ByteIntConvert.toInt(dpData, 8);
	
	
	lastRead=ByteIntConvert.toInt(dpData, 4+8);
	int sum=ByteShortConvert.toShort(dpData, 8+8);
	ackList=new ArrayList<Integer>();
	int t=0;
	for(int i=0;i<sum;i++){
		t=10+4*i;
		int sequence=ByteIntConvert.toInt(dpData, t+8);
		ackList.add(sequence);
	}
	////#MLog.println("LLLLLLLLLLLLLL "+dp.getLength()+" "+ackList.size());
	t=10+4*sum-4;
	r1=ByteIntConvert.toInt(dpData, t+4+8);
	s1=ByteIntConvert.toInt(dpData, t+8+8);

	r2=ByteIntConvert.toInt(dpData, t+12+8);
	s2=ByteIntConvert.toInt(dpData, t+16+8);

	r3=ByteIntConvert.toInt(dpData, t+20+8);
	s3=ByteIntConvert.toInt(dpData, t+24+8);

	////#MLog.println("aaaaaaaaa"+r3+"kkkkkkk "+s3);
}
 
Example 15
public CloseMessage_Stream(int connectId,int clientId,int closeOffset){
	byte[] dpData=new byte[16];
	this.clientId=clientId;
	this.connectId=connectId;
	ByteShortConvert.toByteArray(ver, dpData, 0);  //add: ver
	ByteShortConvert.toByteArray(sType, dpData, 2);  //add: service type
	ByteIntConvert.toByteArray(connectId, dpData, 4); //add: sequence
	ByteIntConvert.toByteArray(clientId, dpData, 8); //add: sequence
	ByteIntConvert.toByteArray(closeOffset, dpData, 12); //add: sequence
	dp=new DatagramPacket(dpData,dpData.length);
	////#MLog.println("vCloseMessageaaa"+clientId+"v");
}
 
Example 16
public CloseMessage_Stream(DatagramPacket dp){
	this.dp=dp;
	dpData=dp.getData();
	ver=ByteShortConvert.toShort(dpData, 0);
	sType=ByteShortConvert.toShort(dpData, 2);
	
	connectId=ByteIntConvert.toInt(dpData, 4);
	clientId=ByteIntConvert.toInt(dpData, 8);
	closeOffset=ByteIntConvert.toInt(dpData, 12);
	////#MLog.println("vCloseMessagebbb"+clientId+"v");
}
 
Example 17
Source Project: finalspeed-91yun   Source File: PingMessage.java    License: GNU General Public License v2.0 5 votes vote down vote up
public PingMessage(int connectId,int clientId,int pingId,int downloadSpeed,int uploadSpeed){
	ByteShortConvert.toByteArray(ver, dpData, 0);  //add: ver
	ByteShortConvert.toByteArray(sType, dpData, 2);  //add: service type
	ByteIntConvert.toByteArray(connectId, dpData, 4); //add: sequence
	ByteIntConvert.toByteArray(clientId, dpData, 8); //add: sequence
	ByteIntConvert.toByteArray(pingId, dpData, 12); //add: sequence
	ByteShortConvert.toByteArray((short) (downloadSpeed/1024), dpData, 16);
	ByteShortConvert.toByteArray((short) (uploadSpeed/1024), dpData, 18);
	dp=new DatagramPacket(dpData,dpData.length);
}
 
Example 18
Source Project: finalspeed-91yun   Source File: PingMessage.java    License: GNU General Public License v2.0 5 votes vote down vote up
public PingMessage(DatagramPacket dp){
	this.dp=dp;
	dpData=dp.getData();
	ver=ByteShortConvert.toShort(dpData, 0);
	sType=ByteShortConvert.toShort(dpData, 2);
	connectId=ByteIntConvert.toInt(dpData, 4);
	clientId=ByteIntConvert.toInt(dpData, 8);
	pingId=ByteIntConvert.toInt(dpData, 12);
	downloadSpeed=ByteShortConvert.toShort(dpData, 16);
	uploadSpeed=ByteShortConvert.toShort(dpData, 18);
}
 
Example 19
public CloseMessage_Conn(int connectId,int clientId){
	byte[] dpData=new byte[12];
	this.clientId=clientId;
	this.connectId=connectId;
	ByteShortConvert.toByteArray(ver, dpData, 0);
	ByteShortConvert.toByteArray(sType, dpData, 2);
	ByteIntConvert.toByteArray(connectId, dpData, 4);
	ByteIntConvert.toByteArray(clientId, dpData, 8);
	dp=new DatagramPacket(dpData,dpData.length);
}
 
Example 20
public CloseMessage_Conn(DatagramPacket dp){
	this.dp=dp;
	dpData=dp.getData();
	ver=ByteShortConvert.toShort(dpData, 0);
	sType=ByteShortConvert.toShort(dpData, 2);
	connectId=ByteIntConvert.toInt(dpData, 4);
	clientId=ByteIntConvert.toInt(dpData, 8);
}
 
Example 21
Source Project: finalspeed-91yun   Source File: DataMessage.java    License: GNU General Public License v2.0 5 votes vote down vote up
public DataMessage(DatagramPacket dp){
	this.dp=dp;
	dpData=dp.getData();
	ver=ByteShortConvert.toShort(dpData, 0);
	sType=ByteShortConvert.toShort(dpData, 2);
	
	connectId=ByteIntConvert.toInt(dpData, 4);
	clientId=ByteIntConvert.toInt(dpData, 8);
	
	sequence=ByteIntConvert.toInt(dpData, 12);
	length=ByteShortConvert.toShort(dpData, 16);
	timeId=ByteIntConvert.toInt(dpData, 18);
	data=new byte[length];
	System.arraycopy(dpData, 22, data, 0, length);
}
 
Example 22
public PingMessage2(int connectId,int clientId,int pingId){
	ByteShortConvert.toByteArray(ver, dpData, 0);  //add: ver
	ByteShortConvert.toByteArray(sType, dpData, 2);  //add: service type
	ByteIntConvert.toByteArray(connectId, dpData, 4); //add: sequence
	ByteIntConvert.toByteArray(clientId, dpData, 8); //add: sequence
	ByteIntConvert.toByteArray(pingId, dpData, 12); //add: sequence
	dp=new DatagramPacket(dpData,dpData.length);
}
 
Example 23
public PingMessage2(DatagramPacket dp){
	this.dp=dp;
	dpData=dp.getData();
	ver=ByteShortConvert.toShort(dpData, 0);
	sType=ByteShortConvert.toShort(dpData, 2);
	connectId=ByteIntConvert.toInt(dpData, 4);
	clientId=ByteIntConvert.toInt(dpData, 8);
	pingId=ByteIntConvert.toInt(dpData, 12);
}
 
Example 24
Source Project: finalspeed   Source File: AckListMessage.java    License: GNU General Public License v2.0 5 votes vote down vote up
public AckListMessage(DatagramPacket dp) {
    this.dp = dp;
    dpData = dp.getData();
    ver = ByteShortConvert.toShort(dpData, 0);
    sType = ByteShortConvert.toShort(dpData, 2);
    connectId = ByteIntConvert.toInt(dpData, 4);
    clientId = ByteIntConvert.toInt(dpData, 8);


    lastRead = ByteIntConvert.toInt(dpData, 4 + 8);
    int sum = ByteShortConvert.toShort(dpData, 8 + 8);
    ackList = new ArrayList<>();
    int t;
    for (int i = 0; i < sum; i++) {
        t = 10 + 4 * i;
        int sequence = ByteIntConvert.toInt(dpData, t + 8);
        ackList.add(sequence);
    }
    ////#MLog.println("LLLLLLLLLLLLLL "+dp.getLength()+" "+ackList.size());
    t = 10 + 4 * sum - 4;
    r1 = ByteIntConvert.toInt(dpData, t + 4 + 8);
    s1 = ByteIntConvert.toInt(dpData, t + 8 + 8);

    r2 = ByteIntConvert.toInt(dpData, t + 12 + 8);
    s2 = ByteIntConvert.toInt(dpData, t + 16 + 8);

    r3 = ByteIntConvert.toInt(dpData, t + 20 + 8);
    s3 = ByteIntConvert.toInt(dpData, t + 24 + 8);

    ////#MLog.println("aaaaaaaaa"+r3+"kkkkkkk "+s3);
}
 
Example 25
public CloseMessage_Stream(int connectId, int clientId, int closeOffset) {
    byte[] dpData = new byte[16];
    this.clientId = clientId;
    this.connectId = connectId;
    ByteShortConvert.toByteArray(ver, dpData, 0);  //add: ver
    ByteShortConvert.toByteArray(sType, dpData, 2);  //add: service type
    ByteIntConvert.toByteArray(connectId, dpData, 4); //add: sequence
    ByteIntConvert.toByteArray(clientId, dpData, 8); //add: sequence
    ByteIntConvert.toByteArray(closeOffset, dpData, 12); //add: sequence
    dp = new DatagramPacket(dpData, dpData.length);
    ////#MLog.println("vCloseMessageaaa"+clientId+"v");
}
 
Example 26
public CloseMessage_Stream(DatagramPacket dp) {
    this.dp = dp;
    dpData = dp.getData();
    ver = ByteShortConvert.toShort(dpData, 0);
    sType = ByteShortConvert.toShort(dpData, 2);

    connectId = ByteIntConvert.toInt(dpData, 4);
    clientId = ByteIntConvert.toInt(dpData, 8);
    closeOffset = ByteIntConvert.toInt(dpData, 12);
    ////#MLog.println("vCloseMessagebbb"+clientId+"v");
}
 
Example 27
Source Project: finalspeed   Source File: PingMessage.java    License: GNU General Public License v2.0 5 votes vote down vote up
public PingMessage(int connectId, int clientId, int pingId, int downloadSpeed, int uploadSpeed) {
    ByteShortConvert.toByteArray(ver, dpData, 0);  //add: ver
    ByteShortConvert.toByteArray(sType, dpData, 2);  //add: service type
    ByteIntConvert.toByteArray(connectId, dpData, 4); //add: sequence
    ByteIntConvert.toByteArray(clientId, dpData, 8); //add: sequence
    ByteIntConvert.toByteArray(pingId, dpData, 12); //add: sequence
    ByteShortConvert.toByteArray((short) (downloadSpeed / 1024), dpData, 16);
    ByteShortConvert.toByteArray((short) (uploadSpeed / 1024), dpData, 18);
    dp = new DatagramPacket(dpData, dpData.length);
}
 
Example 28
Source Project: finalspeed   Source File: PingMessage.java    License: GNU General Public License v2.0 5 votes vote down vote up
public PingMessage(DatagramPacket dp) {
    this.dp = dp;
    dpData = dp.getData();
    ver = ByteShortConvert.toShort(dpData, 0);
    sType = ByteShortConvert.toShort(dpData, 2);
    connectId = ByteIntConvert.toInt(dpData, 4);
    clientId = ByteIntConvert.toInt(dpData, 8);
    pingId = ByteIntConvert.toInt(dpData, 12);
    downloadSpeed = ByteShortConvert.toShort(dpData, 16);
    uploadSpeed = ByteShortConvert.toShort(dpData, 18);
}
 
Example 29
Source Project: finalspeed   Source File: CloseMessage_Conn.java    License: GNU General Public License v2.0 5 votes vote down vote up
public CloseMessage_Conn(int connectId, int clientId) {
    byte[] dpData = new byte[12];
    this.clientId = clientId;
    this.connectId = connectId;
    ByteShortConvert.toByteArray(ver, dpData, 0);
    ByteShortConvert.toByteArray(sType, dpData, 2);
    ByteIntConvert.toByteArray(connectId, dpData, 4);
    ByteIntConvert.toByteArray(clientId, dpData, 8);
    dp = new DatagramPacket(dpData, dpData.length);
}
 
Example 30
Source Project: finalspeed   Source File: CloseMessage_Conn.java    License: GNU General Public License v2.0 5 votes vote down vote up
public CloseMessage_Conn(DatagramPacket dp) {
    this.dp = dp;
    dpData = dp.getData();
    ver = ByteShortConvert.toShort(dpData, 0);
    sType = ByteShortConvert.toShort(dpData, 2);
    connectId = ByteIntConvert.toInt(dpData, 4);
    clientId = ByteIntConvert.toInt(dpData, 8);
}