<?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>
<meta name='titlecontent=' NetworkSensorConnectionPrototypes.x3d '/>
<meta name='descriptioncontent='Prototypes for NetworkSensor and Connection nodes'/>
<meta name='creatorcontent='Don Brutzman, Chris Thorne, Don McGregor, Shun-Yun Hu'/>
<meta name='createdcontent='14 March 2008'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name=' warning content=' under development '/>
<meta name='referencecontent=' NetworkSensorConnectionNodes.html '/>
<meta name='referencecontent=' http://www.xj3d.org/tutorials/general_sai.html '/>
<meta name='referencecontent=' https://www.web3d.org/x3d/specifications/ISO-IEC-CD-19775-2.2/Part02/X3D_SAI.html '/>
<meta name='referencecontent=' https://www.web3d.org/x3d/specifications/ISO-IEC-19777-2-X3DLanguageBindings-Java/Part2/X3D_Java.html '/>
<meta name='subjectcontent='Prototypes for NetworkSensor and Connection nodes'/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Basic/Networking/NetworkSensorConnectionPrototypes.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: ConnectionScript, KeyboardDetector, MessageOutput, NetworkSensorScript, OurNetworkChannel, TextListener, TextSender

Index for ProtoDeclare definitions: Connection, NetworkSensor
-->
<Scene>
<WorldInfo title='NetworkSensorConnectionPrototypes.x3d'/>
<ProtoDeclare name='NetworkSensor'>
<ProtoInterface>
<field name='enabledtype='SFBoolvalue='trueaccessType='inputOutput'/>
<field name='metadatatype='SFNodeaccessType='inputOutput'
 appinfo='X3DMetadataObject node type only' >
<!-- Metadata initialization node is NULL -->
</field>
<field name='isActivetype='SFBoolaccessType='outputOnly'/>
<field name='connectiontype='SFNodeaccessType='initializeOnly'
 appinfo='Connection node only' >
<!-- Default Connection node goes here -->
</field>
<field name='httpRequesttype='SFStringaccessType='inputOnly'/>
<field name='httpResponsetype='MFStringaccessType='outputOnly'/>
<field name='channelIdtype='SFStringvalue='trueaccessType='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='textInputtype='SFStringaccessType='inputOnly'
 appinfo='ROUTE StringSensor output here' />

<field name='textOutputtype='MFStringaccessType='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='enabledtype='SFBoolaccessType='inputOutput'/>
<field name='metadatatype='SFNodeaccessType='inputOutput'/>
<field name='isActivetype='SFBoolaccessType='outputOnly'/>
<field name='connectiontype='SFNodeaccessType='initializeOnly'
 appinfo='Connection node only' />

<field name='httpRequesttype='SFStringaccessType='inputOnly'/>
<field name='httpResponsetype='MFStringaccessType='outputOnly'/>
<field name='channelIdtype='SFStringaccessType='initializeOnly'/>
<IS>
<connect nodeField='enabledprotoField='enabled'/>
<connect nodeField='metadataprotoField='metadata'/>
<connect nodeField='isActiveprotoField='isActive'/>
<connect nodeField='connectionprotoField='connection'/>
<connect nodeField='httpRequestprotoField='httpRequest'/>
<connect nodeField='httpResponseprotoField='httpResponse'/>
<connect nodeField='channelIdprotoField='channelId'/>
</IS>
</Script>
<!-- Subsequent nodes do not render, but still must be a valid X3D subgraph -->
</ProtoBody>
</ProtoDeclare>
<ProtoDeclare name='Connection'>
<ProtoInterface>
<field name='enabledtype='SFBoolvalue='trueaccessType='inputOutput'/>
<field name='metadatatype='SFNodeaccessType='inputOutput'>
<!-- Metadata initialization node is NULL -->
</field>
<field name='isActivetype='SFBoolaccessType='outputOnly'/>
<field name='urltype='MFStringvalue=' "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='protocoltype='SFInt32value='0accessType='initializeOnly'/>
<field name='timeOuttype='SFTimevalue='0accessType='inputOutput'/>
<field name='securetype='SFBoolaccessType='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='enabledtype='SFBoolaccessType='inputOutput'/>
<field name='isActivetype='SFBoolaccessType='outputOnly'/>
<field name='urltype='MFStringaccessType='inputOutput'/>
<field name='protocoltype='SFInt32accessType='initializeOnly'/>
<field name='timeOuttype='SFTimeaccessType='inputOutput'/>
<field name='securetype='SFBoolaccessType='inputOnly'/>
<IS>
<connect nodeField='enabledprotoField='enabled'/>
<connect nodeField='isActiveprotoField='isActive'/>
<connect nodeField='urlprotoField='url'/>
<connect nodeField='protocolprotoField='protocol'/>
<connect nodeField='timeOutprotoField='timeOut'/>
<connect nodeField='secureprotoField='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>
<!-- ROUTE information for MessageOutput node:  [from TextListener.textOutput to string ] -->
<Text DEF='MessageOutputstring='"NetworkSensor messages will appear here"'>
<FontStyle justify='"MIDDLE" "MIDDLE"'/>
</Text>
<Appearance>
<Material ambientIntensity='0.25diffuseColor='0.374008 0 0.748016shininess='0.4specularColor='0.909091 0.909091 0.909091transparency='0.35'/>
</Appearance>
</Shape>
<!-- Only need a single Connection definition for this example -->
<ProtoInstance name='ConnectionDEF='OurNetworkChannel'>
<fieldValue name='urlvalue=' "x3dp://localhost:80" '/>
<!-- protocol 1=http -->
<fieldValue name='protocolvalue='1'/>
<fieldValue name='timeOutvalue='10'/>
<fieldValue name='securevalue='false'/>
</ProtoInstance>
<!-- Here is the listener that connects and sends strings to the Text node -->
<!-- ROUTE information for TextListener node:  [from textOutput to MessageOutput.string ] -->
<ProtoInstance name='NetworkSensorDEF='TextListener'>
<fieldValue name='connection'>
<ProtoInstance USE=' OurNetworkChannel'/>
</fieldValue>
<fieldValue name='channelIdvalue='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 -->
<!-- ROUTE information for TextSender node:  [from KeyboardDetector.finalText to textInput ] -->
<ProtoInstance name='NetworkSensorDEF='TextSender'>
<fieldValue name='connection'>
<ProtoInstance USE=' OurNetworkChannel'/>
</fieldValue>
<fieldValue name='channelIdvalue='78'/>
</ProtoInstance>
<!-- ROUTE information for KeyboardDetector node:  [from finalText to TextSender.textInput ] -->
<StringSensor DEF='KeyboardDetector'/>

< 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>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: ConnectionScript, KeyboardDetector, MessageOutput, NetworkSensorScript, OurNetworkChannel, TextListener, TextSender

Index for ProtoDeclare definitions: Connection, NetworkSensor
-->

Event Graph ROUTE Table entries with 2 ROUTE connections total, showing X3D event-model relationships for this scene.

Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.

KeyboardDetector
StringSensor
finalText
SFString

ROUTE
event to
(1)
TextSender
ProtoInstance
textInput
SFString


OurNetworkChannel
ProtoInstance
Connection
No ROUTE connection found for output from this node.
Contains SFNode/MFNode field with indirect access to other nodes. 


TextListener
ProtoInstance
textOutput
MFString

ROUTE
event to
(1)
MessageOutput
Text
string
MFString


      TextSender
ProtoInstance
NetworkSensor
No ROUTE connection found for output from this node.
Contains SFNode/MFNode field with indirect access to other nodes. 


-->

<!-- 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> -->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->