P2P Export - Nodes - Patch
This commit is contained in:
@ -4,19 +4,71 @@ class CreateLeenkxNode(LnxLogicTreeNode):
|
||||
"""Create Leenkx"""
|
||||
bl_idname = 'LNCreateLeenkxNode'
|
||||
bl_label = 'Create Leenkx'
|
||||
bl_description = 'Create Leenkx'
|
||||
bl_description = ('Open a Leenkx peer connection on the given swarm identifier')
|
||||
lnx_category = 'Leenkx'
|
||||
lnx_version = 1
|
||||
|
||||
def update_sockets(self, context):
|
||||
if not self.inputs:
|
||||
return
|
||||
links = {}
|
||||
for socket in self.inputs:
|
||||
for link in socket.links:
|
||||
links.setdefault(socket.name, []).append(
|
||||
(link.from_node, link.from_socket))
|
||||
for socket in self.inputs[2:]:
|
||||
self.inputs.remove(socket)
|
||||
if (self.property0 == 'datachannel'
|
||||
and self.property2 != 'inherit'):
|
||||
self.add_input('LnxNodeSocketArray', 'ICE Servers')
|
||||
if self.property3 != 'inherit':
|
||||
self.add_input('LnxNodeSocketArray', 'Trackers')
|
||||
tree = self.id_data
|
||||
for socket in self.inputs:
|
||||
if socket.name in links:
|
||||
for from_node, from_socket in links[socket.name]:
|
||||
tree.links.new(from_socket, socket)
|
||||
|
||||
property0: HaxeEnumProperty('property0',
|
||||
items=[('wire', 'Wire', 'BitTorrent wire protocol transport (default)'),
|
||||
('datachannel', 'DataChannel', 'WebRTC data channels for browser/krom peers - shows the ICE Servers input')],
|
||||
name='Transport', default='wire', update=update_sockets)
|
||||
|
||||
property1: HaxeBoolProperty('property1',
|
||||
name='Gossip', description='Relay mode - forward messages to all connected peers', default=False)
|
||||
|
||||
property2: HaxeEnumProperty('property2',
|
||||
items=[('inherit', 'Inherit', 'Use the built-in STUN server list; no ICE Servers input'),
|
||||
('add', 'Add', 'Merge the ICE Servers input on top of the built-in STUN servers'),
|
||||
('override', 'Override', 'Replace the ICE server list with the ICE Servers input')],
|
||||
name='ICE Servers', default='inherit', update=update_sockets)
|
||||
|
||||
property3: HaxeEnumProperty('property3',
|
||||
items=[('inherit', 'Inherit', 'Use the project torrent tracker list; no Trackers input'),
|
||||
('add', 'Add', 'Merge the Trackers input on top of the project tracker list'),
|
||||
('override', 'Override', 'Replace the announce tracker list with the Trackers input')],
|
||||
name='Trackers', default='inherit', update=update_sockets)
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxStringSocket', 'Url', default_value="8001")
|
||||
self.add_input('LnxStringSocket', 'Channel', default_value='8001')
|
||||
if (self.property0 == 'datachannel'
|
||||
and self.property2 != 'inherit'):
|
||||
self.add_input('LnxNodeSocketArray', 'ICE Servers')
|
||||
if self.property3 != 'inherit':
|
||||
self.add_input('LnxNodeSocketArray', 'Trackers')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
self.add_output('LnxDynamicSocket', 'Connection')
|
||||
self.add_output('LnxDynamicSocket', 'ID')
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop(self, 'property0')
|
||||
layout.prop(self, 'property1')
|
||||
if self.property0 == 'datachannel':
|
||||
layout.prop(self, 'property2')
|
||||
layout.prop(self, 'property3')
|
||||
|
||||
|
||||
def register():
|
||||
add_category('Leenkx', icon='ORIENTATION_CURSOR')
|
||||
|
||||
Reference in New Issue
Block a user