#VRML V2.0 utf8
# X3D-to-VRML-97 XSL translation autogenerated by X3dToVrml97.xslt
# https://www.web3d.org/x3d/content/X3dToVrml97.xslt
# Generated using XSLT processor: Saxonica
# [X3D] VRML V3.1 utf8
# 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 [
exposedField SFBool enabled TRUE
exposedField SFNode metadata NULL # [appinfo] X3DMetadataObject node type only
# Metadata initialization node is NULL
eventOut SFBool isActive
field SFNode connection NULL # [appinfo] Connection node only
# Default Connection node goes here
eventIn SFString httpRequest
eventOut MFString httpResponse
field 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
eventIn SFString textInput # [appinfo] ROUTE StringSensor output here
### Warning: ProtoInterface is unreferenced in ProtoBody with no corresponding IS/connect/@protoField
eventOut MFString textOutput # [appinfo] ROUTE this output to Text node string field
# TODO: can we get consistent type for textInput?
] {
DEF NetworkSensorScript Script {
### Warning: Script field 'enabled' has accessType 'inputOutput' (exposedField), which is only allowed in X3D Script node, not VRML97 Script node. Using exposedField anyway, may cause errors.
exposedField SFBool enabled IS enabled
### Warning: Script field 'metadata' has accessType 'inputOutput' (exposedField), which is only allowed in X3D Script node, not VRML97 Script node. Using exposedField anyway, may cause errors.
exposedField SFNode metadata IS metadata
eventOut SFBool isActive IS isActive
field SFNode connection IS connection # [appinfo] Connection node only
eventIn SFString httpRequest IS httpRequest
eventOut MFString httpResponse IS httpResponse
field 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 [
exposedField SFBool enabled TRUE
### Warning: ProtoInterface is unreferenced in ProtoBody with no corresponding IS/connect/@protoField
exposedField SFNode metadata NULL
# Metadata initialization node is NULL
eventOut SFBool isActive
exposedField 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
field SFInt32 protocol 0
exposedField SFTime timeOut 0
eventIn SFBool secure
] {
DEF ConnectionScript Script {
### Warning: Script field 'enabled' has accessType 'inputOutput' (exposedField), which is only allowed in X3D Script node, not VRML97 Script node. Using exposedField anyway, may cause errors.
exposedField SFBool enabled IS enabled
eventOut SFBool isActive IS isActive
### Warning: Script field 'url' has accessType 'inputOutput' (exposedField), which is only allowed in X3D Script node, not VRML97 Script node. Using exposedField anyway, may cause errors.
exposedField MFString url IS url
field SFInt32 protocol IS protocol
### Warning: Script field 'timeOut' has accessType 'inputOutput' (exposedField), which is only allowed in X3D Script node, not VRML97 Script node. Using exposedField anyway, may cause errors.
exposedField SFTime timeOut IS timeOut
eventIn 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.