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
-
-
Method Summary
All Methods Instance Methods Concrete Methods 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 Detail
-
Protocol
public Protocol(Socket ctlSocketParam) throws IOException
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 Detail
-
send_msg
public void send_msg(byte bParamType, byte bParamToSend) throws IOException
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
public void send_json_msg(byte bParamType, byte bParamToSend) throws IOException
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
public void send_json_msg(byte bParamType, byte[] bParamToSend) throws IOException
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
public void send_json_login_msg(byte bParamType, byte[] bParamToSend) throws IOException
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
public void send_msg(byte bParamType, byte[] bParamToSend) throws IOException
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
public int readn(Message msgParam, int iParamAmount) throws IOException
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
public int recv_msg(Message msgParam) throws IOException
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)
-
-