java.lang.Object
edu.internet2.ndt.Protocol
Class aggregating operations that can be performed for sending/receiving/reading Protocol messages.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final InputStreamControl messages read from the test server.private final OutputStreamControl messages sent to the test server.private booleanTrue when the server supports JSON output.Constructor Summary
Method Summary
All MethodsModifier and TypeMethodDescriptionvoidclose()Method to close open Streams.intPopulate Message byte array with specific number of bytes of data from socket input stream.intReceive message at end-point of socket.voidsend_json_login_msg(byte bParamType, byte[] bParamToSend) Send protocol messages given their type and data byte array.voidsend_json_msg(byte bParamType, byte bParamToSend) Send message given its Type and data byte.voidsend_json_msg(byte bParamType, byte[] bParamToSend) Send protocol messages given their type and data byte array.voidsend_msg(byte bParamType, byte bParamToSend) Send message given its Type and data byte.voidsend_msg(byte bParamType, byte[] bParamToSend) Send protocol messages given their type and data byte array.voidsetJsonSupport(boolean jsonSupport) Choose whether parameter maps are sent as JSON objects or as length-prefixed base64 blobs.
Field Details
_ctlInStream
Control messages read from the test server._ctlOutStream
Control messages sent to the test server.jsonSupport
private boolean jsonSupportTrue when the server supports JSON output.
Constructor Details
Protocol
Constructor that accepts socket over which to communicate as parameter.- Parameters:
ctlSocketParam- socket used to send the protocol messages over- Throws:
IOException- if Input/Output streams cannot be read from/written into correctly
Method Details
send_msg
Send message given its Type and data byte.- Parameters:
bParamType- Control Message TypebParamToSend- Data value to send- Throws:
IOException- If data cannot be successfully written to the Output Stream
send_json_msg
Send message given its Type and data byte.- Parameters:
bParamType- Control Message TypebParamToSend- Data value to send- Throws:
IOException- If data cannot be successfully written to the Output Stream
send_json_msg
Send protocol messages given their type and data byte array.- Parameters:
bParamType- Control Message TypebParamToSend- Data value array to send- Throws:
IOException- If data cannot be successfully written to the Output Stream
send_json_login_msg
Send protocol messages given their type and data byte array.- Parameters:
bParamType- Control Message TypebParamToSend- Data value array to send- Throws:
IOException- If data cannot be successfully written to the Output Stream
send_msg
Send protocol messages given their type and data byte array.- Parameters:
bParamType- Control Message TypebParamToSend- Data value array to send- Throws:
IOException- If data cannot be successfully written to the Output Stream
readn
Populate Message byte array with specific number of bytes of data from socket input stream.- Parameters:
msgParam- Message object to be populatediParamAmount- specified number of bytes to be read- Returns:
- integer number of bytes populated
- Throws:
IOException- If data cannot be successfully read from the Input Stream
recv_msg
Receive message at end-point of socket.- Parameters:
msgParam- Message object- Returns:
- integer with values:
a) Success:
- value=0 : successfully read expected number of bytes.
b) Error:
- value= 1 : Error reading ctrl-message length and data type itself, since NDTP-control packet has to be at the least 3 octets long
- value= 3 : Error, mismatch between "length" field of ctrl-message and actual data read
- Throws:
IOException- if the read fails
close
public void close()Method to close open Streams.setJsonSupport
public void setJsonSupport(boolean jsonSupport) Choose whether parameter maps are sent as JSON objects or as length-prefixed base64 blobs. Defaults to true.- Parameters:
jsonSupport- whether to enable JSON support