Package edu.internet2.ndt
Class Protocol
java.lang.Object
edu.internet2.ndt.Protocol
public class Protocol extends Object
Class aggregating operations that can be performed for
sending/receiving/reading Protocol messages
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
close()
Method to close open Streamsint
readn(Message msgParam, int iParamAmount)
Populate Message byte array with specific number of bytes of data from socket input streamint
recv_msg(Message msgParam)
Receive message at end-point of socketvoid
send_json_login_msg(byte bParamType, byte[] bParamToSend)
Send protocol messages given their type and data byte arrayvoid
send_json_msg(byte bParamType, byte bParamToSend)
Send message given its Type and data bytevoid
send_json_msg(byte bParamType, byte[] bParamToSend)
Send protocol messages given their type and data byte arrayvoid
send_msg(byte bParamType, byte bParamToSend)
Send message given its Type and data bytevoid
send_msg(byte bParamType, byte[] bParamToSend)
Send protocol messages given their type and data byte arrayvoid
setJsonSupport(boolean jsonSupport)
-
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- Since:
- 0.9.45
-
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
-
close
public void close()Method to close open Streams -
setJsonSupport
public void setJsonSupport(boolean jsonSupport)
-