<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN" "http://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 =' http://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='22 October 2018'/>
<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=' http://www.web3d.org/x3d/specifications/ISO-IEC-CD-19775-2.2/Part02/X3D_SAI.html '/>
<meta name='referencecontent=' http://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=' http://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>
<!-- -->
<Scene>
<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" "http://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" "http://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='TextListenerfromField='textOutputtoNode='MessageOutputtoField='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='KeyboardDetectorfromField='finalTexttoNode='TextSendertoField='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>
<!--

Index for ProtoDeclare definitions : Connection, NetworkSensor

Index for DEF nodes : ConnectionScript, KeyboardDetector, MessageOutput, NetworkSensorScript, OurNetworkChannel, TextListener, TextSender
-->

<!-- Color key: <X3dNode DEF='idName' field='value'/> matches <XmlElement DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)
    <Prototype name='ProtoName'> <field name='fieldName'/> </Prototype> -->

<!-- Additional help information about X3D scenes: X3D Resources, X3D Scene Authoring Hints and X3D Tooltips -->