Update Files

This commit is contained in:
2025-01-22 16:18:30 +01:00
parent ed4603cf95
commit a36294b518
16718 changed files with 2960346 additions and 0 deletions

View File

@ -0,0 +1,16 @@
from lnx.logicnode.lnx_nodes import *
class NetworkClientNode(LnxLogicTreeNode):
"""Network client to connect to an existing host"""
bl_idname = 'LNNetworkClientNode'
bl_label = 'Create Client'
lnx_version = 1
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxStringSocket', 'Url', default_value="ws://127.0.0.1:8001")
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxDynamicSocket', 'Connection')

View File

@ -0,0 +1,35 @@
from lnx.logicnode.lnx_nodes import *
class NetworkCloseConnectionNode(LnxLogicTreeNode):
"""Close connection on the network"""
bl_idname = 'LNNetworkCloseConnectionNode'
bl_label = 'Close Connection'
lnx_version = 1
property0: HaxeBoolProperty(
'property0',
name="To Null",
description="Close the connection and set to null",
default=False)
property1: HaxeEnumProperty(
'property1',
items = [('client', 'Client', 'Close client connection on network'),
('host', 'Host', 'Close host connection on the network'),
('securehost', 'Secure Host', 'Close secure host connection on the network')],
name='', default='client')
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxDynamicSocket', 'Connection')
self.add_output('LnxNodeSocketAction', 'Out')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
layout.prop(self, 'property1')

View File

@ -0,0 +1,92 @@
from lnx.logicnode.lnx_nodes import *
class NetworkEventNode(LnxLogicTreeNode):
"""Triggers an event from the network getting both message data and sender ID"""
bl_idname = 'LNNetworkEventNode'
bl_label = 'Network Event'
lnx_version = 1
@staticmethod
def get_enum_id_value(obj, prop_name, value):
return obj.bl_rna.properties[prop_name].enum_items[value].identifier
@staticmethod
def get_count_in(type_name):
return {
'client': 0,
'host': 1,
'securehost': 2
}.get(type_name, 0)
def get_enum(self):
return self.get('property0', 0)
def set_enum(self, value):
# Checking the selection of each type
select_current = self.get_enum_id_value(self, 'property0', value)
select_prev = self.property0
#Check if type changed
if select_prev != select_current:
for i in self.inputs:
self.inputs.remove(i)
# Arguements for type Client
if (self.get_count_in(select_current) == 0):
self.add_input('LnxStringSocket', 'Url', default_value="ws://127.0.0.1:8001")
# Arguements for type Host
if (self.get_count_in(select_current) == 1):
self.add_input('LnxStringSocket', 'Domain', default_value="127.0.0.1")
self.add_input('LnxIntSocket', 'Port', default_value=8001)
# Arguements for type Secure Host
if (self.get_count_in(select_current) == 2):
self.add_input('LnxStringSocket', 'Domain', default_value="127.0.0.1")
self.add_input('LnxIntSocket', 'Port', default_value=8001)
self['property0'] = value
property0: HaxeEnumProperty(
'property0',
items = [('client', 'Client', 'Network client Event listener'),
('host', 'Host', 'Network host Event listener'),
('securehost', 'Secure Host', 'Network secure host Event listener')],
name='',
default='client',
set=set_enum,
get=get_enum)
property1: HaxeEnumProperty(
'property1',
items = [('onopen', 'OnOpen', 'Listens to onOpen event'),
('onmessage', 'OnMessage', 'Listens to onMessage event'),
('onerror', 'OnError', 'Listens to onError event'),
('onclose', 'OnClose', 'Listens to onClose event')],
name='',
default='onopen')
def __init__(self):
array_nodes[str(id(self))] = self
def lnx_init(self, context):
#self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxStringSocket', 'Url', default_value="ws://127.0.0.1:8001")
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxDynamicSocket', 'ID')
self.add_output('LnxDynamicSocket', 'Data')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
layout.prop(self, 'property1')

View File

@ -0,0 +1,57 @@
from lnx.logicnode.lnx_nodes import *
class NetworkHostNode(LnxLogicTreeNode):
"""Network host for other clients to connect"""
bl_idname = 'LNNetworkHostNode'
bl_label = 'Create Host'
lnx_version = 1
ssl_ind = 4
def update_ssl(self, context):
"""This is a helper method to allow declaring the `secure`
property before the update_sockets() method. It's not required
but then you would need to move the declaration of `secure`
further down."""
self.update_sockets(context)
property0: HaxeBoolProperty(
'property0',
name="Secure",
description="Enable SSL encryption",
default=False,
update=update_ssl
)
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxStringSocket', 'Domain', default_value="127.0.0.1")
self.add_input('LnxIntSocket', 'Port', default_value=8001)
self.add_input('LnxIntSocket', 'Max Conn.', default_value=25)
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxDynamicSocket', 'Connection')
self.update_sockets(context)
def update_sockets(self, context):
# It's bad to remove from a list during iteration so we use
# this helper list here
remove_list = []
# Remove dynamically placed input sockets
for i in range(NetworkHostNode.ssl_ind, len(self.inputs)):
remove_list.append(self.inputs[i])
for i in remove_list:
self.inputs.remove(i)
# Add dynamic input sockets
if self.property0:
self.add_input('LnxStringSocket', 'Certificate')
self.add_input('LnxStringSocket', 'Private Key')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')

View File

@ -0,0 +1,27 @@
from lnx.logicnode.lnx_nodes import *
class NetworkHostCloseClientNode(LnxLogicTreeNode):
"""Close a client from a host connection by ID"""
bl_idname = 'LNNetworkHostCloseClientNode'
bl_label = 'Host Close Client'
lnx_version = 1
property0: HaxeBoolProperty(
'property0',
name="Secure",
description="Secure host connection",
default=False,
)
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxDynamicSocket', 'Connection')
self.add_input('LnxStringSocket', 'ID')
self.add_output('LnxNodeSocketAction', 'Out')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')

View File

@ -0,0 +1,29 @@
from lnx.logicnode.lnx_nodes import *
class NetworkHostGetIpNode(LnxLogicTreeNode):
"""Return an IP from the ID of a connection"""
bl_idname = 'LNNetworkHostGetIpNode'
bl_label = 'Host Get IP'
lnx_version = 1
property0: HaxeBoolProperty(
'property0',
name="Secure",
description="Secure host connection",
default=False,
)
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxDynamicSocket', 'Connection')
self.add_input('LnxStringSocket', 'ID')
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxStringSocket', 'IP')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')

View File

@ -0,0 +1,114 @@
from lnx.logicnode.lnx_nodes import *
class NetworkHttpRequestNode(LnxLogicTreeNode):
"""Network HTTP Request.
@option Get/ Post: Use HTTP GET or POST methods.
@input In: Action input.
@input Url: Url as string.
@input Headers: Headers as a Haxe map.
@input Parameters: Parameters for the request as Haxe map.
@seeNode Create Map
@input Print Error: Print Error in console.
@input Data: Data to send. Any type.
@input Bytes: Is the data sent as bytes or as a string.
@output Out: Multi-functional output. Type of output given by `Callback Type`.
@output Callback Type: Type of output.
0 = Node Executed
1 = Status Callback
2 = Bytes Data Response Callback
3 = String Data Response Callback
4 = Error String Callback
@utput Status: Status value
@utput Response: Response value
@output Error: Error
"""
bl_idname = 'LNNetworkHttpRequestNode'
bl_label = 'Http Request'
lnx_version = 2
default_inputs_count = 5
@staticmethod
def get_enum_id_value(obj, prop_name, value):
return obj.bl_rna.properties[prop_name].enum_items[value].identifier
@staticmethod
def get_count_in(type_name):
return {
'get': 0,
'post': 1
}.get(type_name, 0)
def get_enum(self):
return self.get('property0', 0)
def set_enum(self, value):
select_current = self.get_enum_id_value(self, 'property0', value)
select_prev = self.property0
if select_prev == select_current:
return
if (self.get_count_in(select_current) == 0):
idx = 0
for inp in self.inputs:
if idx >= self.default_inputs_count:
self.inputs.remove(inp)
idx += 1
self['property0'] = value
else:
self.add_input('LnxDynamicSocket', 'Data')
self.add_input('LnxBoolSocket', 'Bytes')
self['property0'] = value
property0: HaxeEnumProperty(
'property0',
items = [('get', 'Get', 'Http get request'),
('post', 'Post', 'Http post request')],
name='', default='get',
set=set_enum,
get=get_enum)
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxStringSocket', 'Url')
self.add_input('LnxDynamicSocket', 'Headers')
self.add_input('LnxDynamicSocket', 'Parameters')
self.add_input('LnxBoolSocket', 'Print Error')
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxIntSocket', 'Callback Type')
self.add_output('LnxIntSocket', 'Status')
self.add_output('LnxDynamicSocket', 'Response')
self.add_output('LnxStringSocket', 'Error')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
if self.lnx_version not in (0, 1):
raise LookupError()
return NodeReplacement(
'LNNetworkHttpRequestNode', self.lnx_version, 'LNNetworkHttpRequestNode', 2,
in_socket_mapping = {0:0, 1:1}, out_socket_mapping={0:0}
)

View File

@ -0,0 +1,33 @@
from lnx.logicnode.lnx_nodes import *
class NetworkMessageParserNode(LnxLogicTreeNode):
"""Parses message type from data packet"""
bl_idname = 'LNNetworkMessageParserNode'
bl_label = 'Message Parser'
lnx_version = 1
property0: HaxeEnumProperty(
'property0',
items = [('string', 'String', 'Event for a string over the network'),
('vector', 'Vector', 'Event for a vector over the network'),
('float', 'Float', 'Event for a float over the network'),
('integer', 'Integer', 'Event for an integer over the network'),
('boolean', 'Boolean', 'Event for a boolean over the network'),
('transform', 'Transform', 'Event for a transform over the network'),
('rotation', 'Rotation', 'Event for a rotation over the network')],
name='', default='string')
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxStringSocket', 'API')
self.add_input('LnxDynamicSocket', 'Data')
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxDynamicSocket', 'API')
self.add_output('LnxDynamicSocket', 'Data')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')

View File

@ -0,0 +1,28 @@
from lnx.logicnode.lnx_nodes import *
class NetworkOpenConnectionNode(LnxLogicTreeNode):
"""Open connection on the network"""
bl_idname = 'LNNetworkOpenConnectionNode'
bl_label = 'Open Connection'
lnx_version = 1
property0: HaxeEnumProperty(
'property0',
items = [('client', 'Client', 'Open client connection on network'),
('host', 'Host', 'Open host connection on the network'),
('securehost', 'Secure Host', 'Open secure host connection on the network')],
name='', default='client')
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxDynamicSocket', 'Connection')
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxDynamicSocket', 'Connection')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')

View File

@ -0,0 +1,108 @@
from lnx.logicnode.lnx_nodes import *
class NetworkSendMessageNode(LnxLogicTreeNode):
"""Send messages directly to a host as a client or to all of the
network clients connected to a host send messages directly"""
bl_idname = 'LNNetworkSendMessageNode'
bl_label = 'Send Message'
lnx_version = 1
ind = 4
@staticmethod
def get_enum_id_value(obj, prop_name, value):
return obj.bl_rna.properties[prop_name].enum_items[value].identifier
@staticmethod
def get_count_in(type_name):
return {
'client': 0,
'host': 1,
'securehost': 2
}.get(type_name, 0)
def get_enum(self):
return self.get('property0', 0)
def set_enum(self, value):
# Checking the selection of each type
select_current = self.get_enum_id_value(self, 'property0', value)
select_prev = self.property0
#Check if type changed
if select_prev != select_current:
for i in self.inputs:
self.inputs.remove(i)
# Arguements for type Client
if (self.get_count_in(select_current) == 0):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxDynamicSocket', 'Connection')
self.add_input('LnxStringSocket', 'API')
self.add_input('LnxDynamicSocket', 'Data')
# Arguements for type Host
if (self.get_count_in(select_current) == 1):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxDynamicSocket', 'Connection')
self.add_input('LnxStringSocket', 'API')
self.add_input('LnxDynamicSocket', 'Data')
self.add_input('LnxStringSocket', 'ID')
self.add_input('LnxBoolSocket', 'Send All')
# Arguements for type Secure Host
if (self.get_count_in(select_current) == 2):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxDynamicSocket', 'Connection')
self.add_input('LnxStringSocket', 'API')
self.add_input('LnxDynamicSocket', 'Data')
self.add_input('LnxStringSocket', 'ID')
self.add_input('LnxBoolSocket', 'Send All')
self['property0'] = value
property0: HaxeEnumProperty(
'property0',
items = [('client', 'Client', 'Network client Event listener'),
('host', 'Host', 'Network host Event listener'),
('securehost', 'Secure Host', 'Network secure host Event listener')],
name='',
default='client',
set=set_enum,
get=get_enum)
property1: HaxeEnumProperty(
'property1',
items = [('string', 'String', 'Send a string over the network to one or all of the clients'),
('vector', 'Vector', 'Send a vector over the network to one or all of the clients'),
('float', 'Float', 'Send a float over the network to one or all of the clients'),
('integer', 'Integer', 'Send an integer over the network to one or all of the clients'),
('boolean', 'Boolean', 'Send a boolean over the network to one or all of the clients'),
('transform', 'Transform', 'Send a transform over the network to one or all of the clients'),
('rotation', 'Rotation', 'Send a rotation over the network to one or all of the clients')],
name='',
default='string')
def __init__(self):
array_nodes[str(id(self))] = self
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxDynamicSocket', 'Connection')
self.add_input('LnxStringSocket', 'API')
self.add_input('LnxDynamicSocket', 'Data')
self.add_output('LnxNodeSocketAction', 'Out')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
layout.prop(self, 'property1')

View File

@ -0,0 +1 @@