<
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"
"
http://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"
"
http://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>
<!--
MessageOutput ROUTE:
[
from TextListener.textOutput to string
]
-->
<
Text DEF='
MessageOutput'
string='
NetworkSensor messages will appear here'
solid='
true'>
<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'
containerField='
children'>
<
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 -->
<!--
TextListener ROUTE:
[
from textOutput to MessageOutput.string
]
-->
<
ProtoInstance name='
NetworkSensor'
DEF='
TextListener'
containerField='
children'>
<
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 -->
<!--
TextSender ROUTE:
[
from KeyboardDetector.finalText to textInput
]
-->
<
ProtoInstance name='
NetworkSensor'
DEF='
TextSender'
containerField='
children'>
<
fieldValue name='
connection'>
</
fieldValue>
<
fieldValue name='
channelId'
value='
78'/>
</
ProtoInstance>
<!--
KeyboardDetector ROUTE:
[
from finalText to TextSender.textInput
]
-->
<
StringSensor DEF='
KeyboardDetector'
enabled='
true'
deletionAllowed='
true'/>
<
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. -->