|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.perforce.p4java.impl.mapbased.rpc.packet.RpcPacket
public class RpcPacket
Describes the format of, and implements a bunch of methods for, Perforce RPC packets as pushed across the wire between Perforce clients and servers.
Each RPC packet consists of the following elements (as cribbed from the C++ API code and byte-level TCP/IP packet analysis done on p4 server network traffic):
Note that the order of individual fields within the overall scheme is theoretically unimportant (with the obvious exception of the preamble, which has to be first), but there may be unknown server dependencies on element order, so we try to closely follow the C++ API's ordering in our implementation.
Note that RPC packets are not in any way synonymous with TCP packets or any underlying transport layer packet mechanism -- text packets can span TCP packets or several RPC packets can be packed into a single TCP packet, for example.
Field Summary | |
---|---|
static int |
DEFAULT_RPC_PACKET_BUFFER_SIZE
|
static int |
RPC_LENGTH_FIELD_LENGTH
Length in bytes of the RPC packet length fields. |
static String |
TRACE_PREFIX
|
Method Summary | |
---|---|
static RpcPacket |
constructRpcPacket(RpcFunctionSpec funcName,
Map<String,Object> args,
ExternalEnv env)
Construct an RPC packet for a user command. |
static RpcPacket |
constructRpcPacket(RpcFunctionSpec funcName,
String realName,
String[] args,
ExternalEnv env)
Construct an RPC packet for a user command. |
static RpcPacket |
constructRpcPacket(RpcPacketPreamble preamble,
byte[] bytes,
boolean isUnicodeServer,
Charset charset)
Construct an RPC packet from the passed-in preamble, bytes, and charset. |
static RpcPacket |
constructRpcPacket(RpcPacketPreamble preamble,
byte[] bytes,
boolean isUnicodeServer,
Charset charset,
RpcPacketFieldRule fieldRule,
IFilterCallback filterCallback)
Construct an RPC packet from the passed-in preamble, bytes, charset and fieldRule. |
static RpcPacket |
constructRpcPacket(String funcName,
Map<String,Object> args,
ExternalEnv env)
Construct an RPC packet for a user command. |
static int |
decodeInt4(byte[] bytes)
Decode a Java int from the passed-in 4 byte Perforce encoded integer value. |
static byte[] |
encodeInt4(int i)
Return a four byte array ready for sending across the wire that represents in Perforce standard wire form the integer passed in. |
ExternalEnv |
getEnv()
|
String |
getFuncNameString()
|
Map<String,Object> |
getMapArgs()
|
int |
getPacketLength()
|
Map<String,Object> |
getResultsMap()
|
String[] |
getStrArgs()
|
void |
setEnv(ExternalEnv env)
|
void |
setFuncNameString(String funcNameString)
|
void |
setMapArgs(Map<String,Object> mapArgs)
|
void |
setPacketLength(int packetLength)
|
void |
setResultsMap(Map<String,Object> resultsMap)
|
void |
setStrArgs(String[] strArgs)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_RPC_PACKET_BUFFER_SIZE
public static final int RPC_LENGTH_FIELD_LENGTH
public static final String TRACE_PREFIX
Method Detail |
---|
public static byte[] encodeInt4(int i)
Used extensively in the Perforce RPC protocol to encode ints before sending them across the wire.
public static int decodeInt4(byte[] bytes)
Used extensively in the Perforce RPC protocol to decode ints coming in off the wire. Note that we have to go to some length to convince Java that we want unsigned byte (it's amazing that Java still doesn't have unsigned integral types...); this helps explain the seemingly-redundant "& 0xFF"'s in the code below.
public static RpcPacket constructRpcPacket(RpcFunctionSpec funcName, String realName, String[] args, ExternalEnv env)
funcName
- non-null function nameargs
- potentially-null function arguments as a string arrayenv
- potentially-null command environment
public static RpcPacket constructRpcPacket(RpcFunctionSpec funcName, Map<String,Object> args, ExternalEnv env)
funcName
- non-null function nameargs
- potentially-null function arguments in map formenv
- potentially-null command environment
public static RpcPacket constructRpcPacket(String funcName, Map<String,Object> args, ExternalEnv env)
funcName
- non-null function nameargs
- potentially-null function arguments in map formenv
- potentially-null command environment
public static RpcPacket constructRpcPacket(RpcPacketPreamble preamble, byte[] bytes, boolean isUnicodeServer, Charset charset)
public static RpcPacket constructRpcPacket(RpcPacketPreamble preamble, byte[] bytes, boolean isUnicodeServer, Charset charset, RpcPacketFieldRule fieldRule, IFilterCallback filterCallback)
public Map<String,Object> getResultsMap()
public void setResultsMap(Map<String,Object> resultsMap)
public String getFuncNameString()
public void setFuncNameString(String funcNameString)
public int getPacketLength()
public void setPacketLength(int packetLength)
public String[] getStrArgs()
public void setStrArgs(String[] strArgs)
public Map<String,Object> getMapArgs()
public void setMapArgs(Map<String,Object> mapArgs)
public ExternalEnv getEnv()
public void setEnv(ExternalEnv env)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |