<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN" "https://www.web3d.org/specifications/x3d-3.1.dtd">
<X3D profile='Immersive'
version='3.1'
xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
xsd:noNamespaceSchemaLocation
='
https://www.web3d.org/specifications/x3d-3.1.xsd
'
>
<head>
</head>
<!--
-->
<Scene>
<WorldInfo title='NetworkSensorConnectionPrototypes.x3d'/>
<ProtoDeclare name='NetworkSensor'>
<ProtoInterface>
<field name='enabled' type='SFBool' value='true' accessType='inputOutput'/>
<field name='metadata' type='SFNode' accessType='inputOutput'
appinfo='X3DMetadataObject node type only'
>
<!-- Metadata initialization node is NULL -->
</field>
<field name='isActive' type='SFBool' accessType='outputOnly'/>
<field name='connection' type='SFNode' accessType='initializeOnly'
appinfo='Connection node only'
>
<!-- Default Connection node goes here -->
</field>
<field name='httpRequest' type='SFString' accessType='inputOnly'/>
<field name='httpResponse' type='MFString' accessType='outputOnly'/>
<field name='channelId' type='SFString' value='true' accessType='initializeOnly'/>
<!-- TODO: how to handle user-defined fields? -->
<!-- perhaps corresponding MFString arrays for fieldName, fieldType, fieldAccessType, fieldInitialValues -->
<!-- for now we'll simply try to get a MFString field to work -->
<field name='textInput' type='SFString' accessType='inputOnly'
appinfo='ROUTE StringSensor output here'
/>
<field name='textOutput' type='MFString' accessType='outputOnly'
appinfo='ROUTE this output to Text node string field'
/>
<!-- TODO: can we get consistent type for textInput? -->
</ProtoInterface>
<ProtoBody>
<!-- First node determines node type of prototype -->
<Script DEF='NetworkSensorScript'
url='
"NetworkSensorScript.class" "https://www.web3d.org/x3d/content/examples/Networking/NetworkSensorScript.class" '
>
<field name='enabled' type='SFBool' accessType='inputOutput'/>
<field name='metadata' type='SFNode' accessType='inputOutput'/>
<field name='isActive' type='SFBool' accessType='outputOnly'/>
<field name='connection' type='SFNode' accessType='initializeOnly'
appinfo='Connection node only'
/>
<field name='httpRequest' type='SFString' accessType='inputOnly'/>
<field name='httpResponse' type='MFString' accessType='outputOnly'/>
<field name='channelId' type='SFString' accessType='initializeOnly'/>
<IS>
<connect nodeField='enabled' protoField='enabled'/>
<connect nodeField='metadata' protoField='metadata'/>
<connect nodeField='isActive' protoField='isActive'/>
<connect nodeField='connection' protoField='connection'/>
<connect nodeField='httpRequest' protoField='httpRequest'/>
<connect nodeField='httpResponse' protoField='httpResponse'/>
<connect nodeField='channelId' protoField='channelId'/>
</IS>
</Script>
<!-- Subsequent nodes do not render, but still must be a valid X3D subgraph -->
</ProtoBody>
</ProtoDeclare>
<ProtoDeclare name='Connection'>
<ProtoInterface>
<field name='enabled' type='SFBool' value='true' accessType='inputOutput'/>
<field name='metadata' type='SFNode' accessType='inputOutput'>
<!-- Metadata initialization node is NULL -->
</field>
<field name='isActive' type='SFBool' accessType='outputOnly'/>
<field name='url' type='MFString' value='
"x3dp://localhost:80"
' accessType='inputOutput'/>
<!-- 1 for HTTP, 2 for HTTP 1.1, 3 for TCP/IP, 4 for UDP, 5 for multicast -->
<!-- spec TODO: change these code numbers to string enumerations instead -->
<field name='protocol' type='SFInt32' value='0' accessType='initializeOnly'/>
<field name='timeOut' type='SFTime' value='0' accessType='inputOutput'/>
<field name='secure' type='SFBool' accessType='inputOnly'/>
</ProtoInterface>
<ProtoBody>
<!-- First node determines node type of prototype -->
<Script DEF='ConnectionScript'
url='
"ConnectionScript.class" "https://www.web3d.org/x3d/content/examples/Networking/ConnectionScript.class" '
>
<field name='enabled' type='SFBool' accessType='inputOutput'/>
<field name='isActive' type='SFBool' accessType='outputOnly'/>
<field name='url' type='MFString' accessType='inputOutput'/>
<field name='protocol' type='SFInt32' accessType='initializeOnly'/>
<field name='timeOut' type='SFTime' accessType='inputOutput'/>
<field name='secure' type='SFBool' accessType='inputOnly'/>
<IS>
<connect nodeField='enabled' protoField='enabled'/>
<connect nodeField='isActive' protoField='isActive'/>
<connect nodeField='url' protoField='url'/>
<connect nodeField='protocol' protoField='protocol'/>
<connect nodeField='timeOut' protoField='timeOut'/>
<connect nodeField='secure' protoField='secure'/>
</IS>
</Script>
<!-- Subsequent nodes do not render, but still must be a valid X3D subgraph -->
</ProtoBody>
</ProtoDeclare>
<!-- We'll put our initial example next. First the listener will output networked messages to a Text node -->
<Shape>
<FontStyle justify='"MIDDLE" "MIDDLE"'/>
</Text>
<Appearance>
<Material ambientIntensity='0.25' diffuseColor='0.374008 0 0.748016' shininess='0.4' specularColor='0.909091 0.909091 0.909091' transparency='0.35'/>
</Appearance>
</Shape>
<!-- Only need a single Connection definition for this example -->
<ProtoInstance name='Connection' DEF='OurNetworkChannel'>
<fieldValue name='url' value='
"x3dp://localhost:80"
'/>
<!-- protocol 1=http -->
<fieldValue name='protocol' value='1'/>
<fieldValue name='timeOut' value='10'/>
<fieldValue name='secure' value='false'/>
</ProtoInstance>
<!-- Here is the listener that connects and sends strings to the Text node -->
<fieldValue name='connection'>
</fieldValue>
<fieldValue name='channelId' value='78'/>
</ProtoInstance>
<!-- TODO: once a single string can successfully be sent, insert an intermediate Script to remember last 10 strings -->
<
ROUTE
fromNode='
TextListener' fromField='textOutput' toNode='
MessageOutput' toField='string'/>
<!-- Now capture text from local keyboard, send to scenes listening to this network connection -->
<fieldValue name='connection'>
</fieldValue>
<fieldValue name='channelId' value='78'/>
</ProtoInstance>
<
ROUTE
fromNode='
KeyboardDetector' fromField='finalText' toNode='
TextSender' toField='textInput'/>
<!-- done. we should now be able to type text and have it appear in the output for whoever's using the same scene. -->
</Scene>
</X3D>
<!--
-->
-->
<!--
Online at
https://www.web3d.org/x3d/content/examples/Basic/Networking/NetworkSensorConnectionPrototypesIndex.html
-->
<!--
Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/Networking/NetworkSensorConnectionPrototypes.x3d
-->
<!--
Color legend: X3D terminology
<X3dNode
DEF='idName' field='value'/>
matches XML terminology
<XmlElement
DEF='idName' attribute='value'/>
(Light-blue background: event-based behavior node or statement)
(Grey background inside box: inserted documentation)
(Magenta background: X3D Extensibility)
<ProtoInstance
name='ProtoName'>
<field
name='fieldName'/> </ProtoInstance>
-->
<!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->