IC8 Python API:RLPy RUdpClient
Contents
- 1 Description
- 2 Constructor & Destructor
- 3 Member Functions
- 3.1 Connect (self, strIP, uPort)
- 3.2 Disconnect (self)
- 3.3 GetData (self, pBuffer)
- 3.4 GetDataAt (self, nIndex, pBuffer)
- 3.5 GetDataCount (self)
- 3.6 GetDataSize (self, *args)
- 3.7 GetMaximumDataCount (self)
- 3.8 IsConnected (self)
- 3.9 JoinMulticastGroup (self, strIP)
- 3.10 RegisterCallback (self, pCallback)
- 3.11 SendData (self, pBuffer, nDataSize, strIP, uPort)
- 3.12 SetMaximumDataCount (self, nCount)
- 3.13 UnregisterCallback (self)
- 4 Properties
Description
This class is used to receive UDP data. The User Datagram Protocol allow sending messages across networks without connections. The RUdpClientis used to create to receive UDP messages. This class use queue to store the received data. The developer can set the buffer size for storing the maximum data counts by using SetMaximumDataCount, the default value is 60. When the total data counts received is greater than the maximum buffer counts, the previously received data will be removed. In order to fetch data, a specified index must be provided to get the data which developer wants in the buffer. Then a container must be created of the same size as the data, then data copied to the container by using GetDataSize and GetData.
Constructor & Destructor
__init__ (self)
Initializes a new udp client instance.
Member Functions
Connect (self, strIP, uPort)
Connect to a designated server. Returns RLPy.RStatus.Success when connected, however, this does not mean that the connection was successful, just means that a connection has been made. Upon receiving IP format error, returns a RLPy.RStatus.Failure. See Also: IsConnected, Disconnect
Parameters
- strIP
- uPort
Sample code
Calls `RLPy.RUdpClient.SendData` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
# if connect success
data = b'helloiClone'
data_size = len(data)
udp_client.SendData(bytearray(data), data_size)
Sample code
Calls `RLPy.RUdpClient.JoinMulticastGroup` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
# if connect success
udp_client.JoinMulticastGroup( self.ip_address )
Sample code
Calls `RLPy.RUdpClient.GetDataSize` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
# if connect success and data received
data_size = udp_client.GetDataSize()
Print(data_size)
Sample code
Demonstrates calls to `RLPy.RUdpClient.Disconnect` and `RLPy.RUdpClient.IsConnected` using the example's inputs.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
print(udp_client.IsConnected())
# Disconnect from network
udp_client.Disconnect()
Sample code
Calls `RLPy.RUdpClient.GetDataCount` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
# if connect success and data received
data_count = udp_client.GetDataCount()
Sample code
Calls `RLPy.RUdpClient.GetMaximumDataCount` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# Connect to server
udp_client.Connect("127.0.0.1", 802)
# If connect success and data received
udp_client.SetMaximumDataCount(100)
print(udp_client.GetMaximumDataCount()) # 100
Sample code
Calls `RLPy.RUdpClient.SetMaximumDataCount` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
# if connect success and data received
udp_client.SetMaximumDataCount(100)
print(udp_client.GetMaximumDataCount()) # 100
Disconnect (self)
Disconnect from the server.
Sample code
Demonstrates calls to `RLPy.RUdpClient.Disconnect` and `RLPy.RUdpClient.IsConnected` using the example's inputs.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
print(udp_client.IsConnected())
# Disconnect from network
udp_client.Disconnect()
GetData (self, pBuffer)
Get the latest data to buffer. Currently an iClone network system needs to first fetch the data size, create a byte array of an equal size, and use GetData to fill this byte array buffer.
Parameters
- pBuffer
GetDataAt (self, nIndex, pBuffer)
Get the data to pBuffer according to the specific index. The size of the data for the given index must be pre-fetched in order to create a byte array of an identitical size; Then GetDataAt can be used to retrieve the data to fill this buffer. An index of 0 fetches the first (oldest) data.
Parameters
- nIndex
- pBuffer
GetDataCount (self)
Get the counts of data in the buffer. The maximum value is determined by SetMaximumDataCount (default: 60).
Sample code
Calls `RLPy.RUdpClient.GetDataCount` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
# if connect success and data received
data_count = udp_client.GetDataCount()
GetDataSize (self, *args)
Get the latest data's size.
Parameters
- args
Sample code
Calls `RLPy.RUdpClient.GetDataSize` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
# if connect success and data received
data_size = udp_client.GetDataSize()
Print(data_size)
GetMaximumDataCount (self)
Get buffer max count. See Also: SetMaximumDataCount
Sample code
Calls `RLPy.RUdpClient.GetMaximumDataCount` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# Connect to server
udp_client.Connect("127.0.0.1", 802)
# If connect success and data received
udp_client.SetMaximumDataCount(100)
print(udp_client.GetMaximumDataCount()) # 100
Sample code
Calls `RLPy.RUdpClient.SetMaximumDataCount` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
# if connect success and data received
udp_client.SetMaximumDataCount(100)
print(udp_client.GetMaximumDataCount()) # 100
IsConnected (self)
Get the current connection status of the client.
Sample code
Demonstrates calls to `RLPy.RUdpClient.Disconnect` and `RLPy.RUdpClient.IsConnected` using the example's inputs.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
print(udp_client.IsConnected())
# Disconnect from network
udp_client.Disconnect()
JoinMulticastGroup (self, strIP)
Join the multicast group at a specific IP address. Use Qt QUdpSocket::joinMulticastGroup mechanism to add more groups to the UDP client. The UDP client must enter bound state by being connected in the first place.
Parameters
- strIP
Sample code
Calls `RLPy.RUdpClient.JoinMulticastGroup` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
# if connect success
udp_client.JoinMulticastGroup( self.ip_address )
RegisterCallback (self, pCallback)
Register network TCP event callback. See Also: UnregisterCallback
Parameters
- pCallback
SendData (self, pBuffer, nDataSize, strIP, uPort)
Write data to the Server.
Parameters
- pBuffer
- nDataSize
- strIP
- uPort
Sample code
Calls `RLPy.RUdpClient.SendData` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
# if connect success
data = b'helloiClone'
data_size = len(data)
udp_client.SendData(bytearray(data), data_size)
SetMaximumDataCount (self, nCount)
Set buffer the maximum amount of received data (default: 60). See Also: GetMaximumDataCount
Parameters
- nCount
Sample code
Calls `RLPy.RUdpClient.GetMaximumDataCount` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# Connect to server
udp_client.Connect("127.0.0.1", 802)
# If connect success and data received
udp_client.SetMaximumDataCount(100)
print(udp_client.GetMaximumDataCount()) # 100
Sample code
Calls `RLPy.RUdpClient.SetMaximumDataCount` with the inputs shown in the example.
def run_script():
import RLPy
udp_client = RLPy.RUdpClient()
# connect to server
udp_client.Connect("127.0.0.1", 802)
# if connect success and data received
udp_client.SetMaximumDataCount(100)
print(udp_client.GetMaximumDataCount()) # 100
UnregisterCallback (self)
Unregister network Udp event callback.
Properties
thisown
Indicates whether this SWIG proxy owns the underlying C++ object.