📄 mbasesession.java
字号:
package net.jumperz.app.MDoorman;
import java.io.IOException;
import java.net.Socket;
import java.io.*;
import net.jumperz.util.*;
import net.jumperz.io.MBuffer;
public class MBaseSession
{
public static final String[] stateString = new String[]{
"Connected",
"Receiving Request",
"Modifying Request",
"Connecting To Server",
"Connected To Server",
"Sending Request",
"Receiving Response",
"Modifying Response",
"Sending Response",
"Completed",
"Error",
"Stream Closed",
"Loaded From File"
};
public static final int C_CONNECTED = 0;
public static final int RQ_RCVNG = 1;
public static final int RQ_MODIFY = 2;
public static final int S_CONNECTING = 3;
public static final int S_CONNECTED = 4;
public static final int RQ_SNDNG = 5;
public static final int RS_RCVNG = 6;
public static final int RS_MODIFY = 7;
public static final int RS_SNDNG = 8;
public static final int COMPLETED = 9;
public static final int ERROR = 10;
public static final int STREAM_CLOSED = 11;
public static final int LOAD_FROM_FILE = 12;
protected String cSocketString = "-";
protected String sSocketString = "-";
protected String time;
protected String method = "-";
protected String statusCode = "-";
protected MBuffer responseBuffer;
protected String uri;
protected int state;
protected byte[] requestByte = new byte[]{};
protected boolean xmlFlag = true;
public static int bufSize = 1024 * 100; //100KB
// --------------------------------------------------------------------------------
public void setXmlFlag( boolean b )
{
xmlFlag = b;
}
// --------------------------------------------------------------------------------
public void setTime( String s )
{
time = s;
}
// --------------------------------------------------------------------------------
public String getStateString()
{
return "";
}
// --------------------------------------------------------------------------------
public void sendRequest()
{
}
// --------------------------------------------------------------------------------
public void sendResponse()
{
}
// --------------------------------------------------------------------------------
public void errorClose()
{
}
// --------------------------------------------------------------------------------
public String getTime()
{
return time;
}
// --------------------------------------------------------------------------------
public void setState( int i )
{
state = i;
}
// --------------------------------------------------------------------------------
public int getState()
{
return state;
}
// --------------------------------------------------------------------------------
public String getMethod()
{
return method;
}
// --------------------------------------------------------------------------------
public String getStatusCode()
{
return statusCode;
}
// --------------------------------------------------------------------------------
public void setStatusCode( String s )
{
statusCode = s;
}
// --------------------------------------------------------------------------------
public void setMethod( String s )
{
method = s;
}
// --------------------------------------------------------------------------------
public void setRequestByte( byte[] b )
{
if( xmlFlag )
{
return;
}
requestByte = b;
}
// --------------------------------------------------------------------------------
public byte[] getRequestByte()
{
if( xmlFlag )
{
return new byte[]{};
}
return requestByte;
}
// --------------------------------------------------------------------------------
public void setResponseByte( byte[] b )
{
if( xmlFlag )
{
return;
}
try
{
if( responseBuffer != null )
{
responseBuffer.close();
}
responseBuffer = new MBuffer( bufSize );
responseBuffer.write( b );
responseBuffer.close();
}
catch( IOException e )
{
e.printStackTrace();
}
}
// --------------------------------------------------------------------------------
public byte[] getResponseByte()
{
if( xmlFlag )
{
return new byte[]{};
}
try
{
if( responseBuffer != null )
{
return responseBuffer.getBytes();
}
else
{
return new byte[]{};
}
}
catch( IOException e )
{
e.printStackTrace();
return new byte[]{};
}
}
// --------------------------------------------------------------------------------
public String getRequestString()
{
xmlFlag = false;
String s = MStringUtil.byteToHexString( getRequestByte() );
xmlFlag = true;
return s;
}
// --------------------------------------------------------------------------------
public void setRequestString( String s )
{
requestByte = MStringUtil.hexStringToByteArray( s );
}
// --------------------------------------------------------------------------------
public String getResponseString()
throws IOException
{
xmlFlag = false;
String s = MStringUtil.byteToHexString( getResponseByte() );
xmlFlag = true;
return s;
}
// --------------------------------------------------------------------------------
public void setResponseString( String s )
throws IOException
{
if( xmlFlag )
{
byte[] buffer = MStringUtil.hexStringToByteArray( s );
responseBuffer = new MBuffer( bufSize );
responseBuffer.write( buffer );
responseBuffer.close();
}
else
{
return;
}
}
// --------------------------------------------------------------------------------
public String getUri()
{
return uri;
}
// --------------------------------------------------------------------------------
public void setUri( String uri )
{
this.uri = uri;
}
// --------------------------------------------------------------------------------
public void setCSocketString( String s )
{
cSocketString = s;
}
// --------------------------------------------------------------------------------
public String getCSocketString()
{
return cSocketString;
}
// --------------------------------------------------------------------------------
public void setSSocketString( String s )
{
sSocketString = s;
}
public String getSSocketString()
{
return sSocketString;
}
// --------------------------------------------------------------------------------
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -