#X3D V3.1 utf8
# X3D-to-ClassicVRML XSL translation autogenerated by X3dToVrml97.xslt
# https://www.web3d.org/x3d/content/X3dToVrml97.xslt
# Generated using XSLT processor: Saxonica
PROFILE Immersive
# [X3D] version=3.1
# [X3D] noNamespaceSchemaLocation=https://www.web3d.org/specifications/x3d-3.1.xsd
# [head]
META "title" "NetworkSensorConnectionPrototypes.x3d"
META "description" "Prototypes for NetworkSensor and Connection nodes"
META "creator" "Don Brutzman, Chris Thorne, Don McGregor, Shun-Yun Hu"
META "created" "14 March 2008"
META "modified" "20 October 2019"
META "warning" "under development"
META "reference" "NetworkSensorConnectionNodes.html"
META "reference" "http://www.xj3d.org/tutorials/general_sai.html"
META "reference" "https://www.web3d.org/x3d/specifications/ISO-IEC-CD-19775-2.2/Part02/X3D_SAI.html"
META "reference" "https://www.web3d.org/x3d/specifications/ISO-IEC-19777-2-X3DLanguageBindings-Java/Part2/X3D_Java.html"
META "subject" "Prototypes for NetworkSensor and Connection nodes"
META "identifier" "https://www.web3d.org/x3d/content/examples/Basic/Networking/NetworkSensorConnectionPrototypes.x3d"
META "generator" "X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
META "license" "../license.html"
# [Scene] ========== ========== ==========
NavigationInfo { type [ "EXAMINE" "ANY" ] } ### Default X3D NavigationInfo
WorldInfo {
title "NetworkSensorConnectionPrototypes.x3d"
}
PROTO NetworkSensor [
inputOutput SFBool enabled TRUE
inputOutput SFNode metadata NULL # [appinfo] X3DMetadataObject node type only
# Metadata initialization node is NULL
outputOnly SFBool isActive
initializeOnly SFNode connection NULL # [appinfo] Connection node only
# Default Connection node goes here
inputOnly SFString httpRequest
outputOnly MFString httpResponse
initializeOnly SFString channelId "true"
# 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
### Warning: ProtoInterface is unreferenced in ProtoBody with no corresponding IS/connect/@protoField
inputOnly SFString textInput # [appinfo] ROUTE StringSensor output here
### Warning: ProtoInterface is unreferenced in ProtoBody with no corresponding IS/connect/@protoField
outputOnly MFString textOutput # [appinfo] ROUTE this output to Text node string field
# TODO: can we get consistent type for textInput?
] {
DEF NetworkSensorScript Script {
inputOutput SFBool enabled IS enabled
inputOutput SFNode metadata IS metadata
outputOnly SFBool isActive IS isActive
initializeOnly SFNode connection IS connection # [appinfo] Connection node only
inputOnly SFString httpRequest IS httpRequest
outputOnly MFString httpResponse IS httpResponse
initializeOnly SFString channelId IS channelId
### Warning: Script attribute directOutput='true' usually needed when field(s) of type SFNode/MFNode are present. directOutput false means Script is not allowed to modify referenced nodes.
url [ "NetworkSensorScript.class" "https://www.web3d.org/x3d/content/examples/Networking/NetworkSensorScript.class"
]
}
}
PROTO Connection [
inputOutput SFBool enabled TRUE
### Warning: ProtoInterface is unreferenced in ProtoBody with no corresponding IS/connect/@protoField
inputOutput SFNode metadata NULL
# Metadata initialization node is NULL
outputOnly SFBool isActive
inputOutput MFString url [
"x3dp://localhost:80"
]
# 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
initializeOnly SFInt32 protocol 0
inputOutput SFTime timeOut 0
inputOnly SFBool secure
] {
DEF ConnectionScript Script {
inputOutput SFBool enabled IS enabled
outputOnly SFBool isActive IS isActive
inputOutput MFString url IS url
initializeOnly SFInt32 protocol IS protocol
inputOutput SFTime timeOut IS timeOut
inputOnly SFBool secure IS secure
url [ "ConnectionScript.class" "https://www.web3d.org/x3d/content/examples/Networking/ConnectionScript.class"
]
}
}
# We'll put our initial example next. First the listener will output networked messages to a Text node
Shape {
geometry DEF MessageOutput Text {
string [ "NetworkSensor messages will appear here" ]
fontStyle FontStyle {
justify [ "MIDDLE" "MIDDLE" ]
}
}
appearance Appearance {
material Material {
ambientIntensity 0.25
diffuseColor 0.374008 0 0.748016
shininess 0.4
specularColor 0.909091 0.909091 0.909091
transparency 0.35
}
}
}
# Only need a single Connection definition for this example
DEF OurNetworkChannel Connection {
# protocol 1=http
url [ "x3dp://localhost:80" ]
protocol 1
timeOut 10
secure ### Error: ProtoInstance Connection fieldValue 'secure' has accessType inputOnly and cannot be initialized.
FALSE
}
# Here is the listener that connects and sends strings to the Text node
DEF TextListener NetworkSensor {
connection [
USE OurNetworkChannel
]
channelId "78"
}
# TODO: once a single string can successfully be sent, insert an intermediate Script to remember last 10 strings
ROUTE TextListener.textOutput TO MessageOutput.string
# Now capture text from local keyboard, send to scenes listening to this network connection
DEF TextSender NetworkSensor {
connection [
USE OurNetworkChannel
]
channelId "78"
}
DEF KeyboardDetector StringSensor {
}
ROUTE KeyboardDetector.finalText TO TextSender.textInput
# done. we should now be able to type text and have it appear in the output for whoever's using the same scene.