Skip to content

Instantly share code, notes, and snippets.

@kenwebb
Last active October 9, 2018 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenwebb/c8e973166fd2a14f5ef42e7413870801 to your computer and use it in GitHub Desktop.
Save kenwebb/c8e973166fd2a14f5ef42e7413870801 to your computer and use it in GitHub Desktop.
PI - Hello World - WebRTC
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Tue Oct 09 2018 12:12:30 GMT-0400 (Eastern Daylight Time)-->
<XholonWorkbook>
<Notes><![CDATA[
Xholon
------
Title: PI - Hello World - WebRTC
Description:
Url: http://www.primordion.com/Xholon/gwt/
InternalName: c8e973166fd2a14f5ef42e7413870801
Keywords:
My Notes
--------
October 9, 2018
In this workbook I:
- create a simple Hello World app, with ports between a Hello node and a World node
- run it as a complete app in a single web page
- add a Processing Instruction (PI) with separate instructions for "Hello" and for "World"
- run the app with &ver=Hello on one web page
- then run the same app with &ver=World on another web page, possibly in another type of browser, and possibly on another computer
- move the system Avatar between pages
http://127.0.0.1:8888/XholonWebRTC.html?app=PI%20-%20Hello%20World%20-%20WebRTC&src=lstr&gui=none
http://127.0.0.1:8888/XholonWebRTC.html?app=PI%20-%20Hello%20World%20-%20WebRTC&src=lstr&gui=none&localid0=PIAble101&ver=Hello
http://127.0.0.1:8888/XholonWebRTC.html?app=PI%20-%20Hello%20World%20-%20WebRTC&src=lstr&gui=none&remoteid0=PIAble101&ver=World
Note that I use XholonWebRTC.html for all versions. This .html file loads the PeerJS JavaScript library.
It doesn't work if the workbook name (PI%20-%20Hello%20World%20-%20WebRTC) is part of the localid, where ver=World
- my PeerJs.java shortens it to 18 characters "PI - Hello World -"; maybe the trailing "-" causes a problem?
this works:
http://127.0.0.1:8888/XholonWebRTC.html?app=c8e973166fd2a14f5ef42e7413870801&src=gist&gui=none&localid0=PIAble104&ver=Hello
http://127.0.0.1:8888/XholonWebRTC.html?app=c8e973166fd2a14f5ef42e7413870801&src=gist&gui=none&remoteid0=PIAble104&ver=World
revisions:
---------
1. simple stand-alone Hello World app, able to run in a single web page
the ports are set up for local connection
2. add xmlreader-patch PI to xholonClassDetails in Class Details
add xmlreader-patch PI to PhysicalSystem in Composite Structure Hierarchy
the simple stand-alone Hello World app can still run in a single web page
running it as two separate apps (&ver=Hello and &ver=World) doesn't work yet
3. the WebRTC connection works if I use the gist id
I was able to send the system Avatar from the Hello app to the World app, with both running on different pages in Chrome
It also works if Hello runs on Chrome and World runs on Firefox
]]></Notes>
<_-.XholonClass>
<PhysicalSystem/>
<HelloWorldSystem/>
<Hello/>
<World/>
</_-.XholonClass>
<xholonClassDetails>
<?xmlreader-patch
{
"Hello":
[
{"op":"remove", "sel":"./World"},
{"op":"replace", "sel":"./Hello/port/@name", "content":"trop"},
{"op":"replace", "sel":"./Hello/port/@connector", "content":"RemoteNodeService-PeerJS,localid0,delete,3,delete,9000,/"}
],
"World":
[
{"op":"remove", "sel":"./Hello"},
{"op":"replace", "sel":"./World/port/@connector", "content":"RemoteNodeService-PeerJS,remoteid0,delete,3,delete,9000,/"}
]
}
?>
<Hello xhType="XhtypePureActiveObject">
<port name="port" index="0" connector="ancestor::HelloWorldSystem/World"/>
</Hello>
<World xhType="XhtypePureActiveObject">
<port name="port" index="0" connector="ancestor::HelloWorldSystem/Hello"/>
</World>
<Avatar><Color>red</Color></Avatar>
</xholonClassDetails>
<PhysicalSystem>
<?xmlreader-patch
{
"Hello":
[
{"op":"remove", "sel":"./HelloWorldSystem/World"}
],
"World":
[
{"op":"remove", "sel":"./HelloWorldSystem/Hello"}
]
}
?>
<HelloWorldSystem>
<Annotation>Hello and World cooperate to create Hello World!</Annotation>
<Hello/>
<World/>
</HelloWorldSystem>
<Animate duration="1" selection="#xhanim" xpath="./PhysicalSystem/HelloWorldSystem" efParams="{&quot;selection&quot;:&quot;#xhanim&quot;,&quot;sort&quot;:&quot;disable&quot;,&quot;width&quot;:400,&quot;height&quot;:400,&quot;mode&quot;:&quot;tween&quot;,&quot;labelContainers&quot;:true,&quot;includeId&quot;:true,&quot;shape&quot;:&quot;circle&quot;,&quot;maxChars&quot;:5,&quot;togglePortColors&quot;:false}"/>
</PhysicalSystem>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg">
<g>
<title>HelloWorldSystem</title>
<rect id="PhysicalSystem/HelloWorldSystem" fill="#98FB98" height="50" width="50" x="25" y="0"/>
<g>
<title>Hello</title>
<rect id="PhysicalSystem/HelloWorldSystem/Hello" fill="#6AB06A" height="50" width="10" x="80" y="0"/>
</g>
</g>
</svg>
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient>
</XholonWorkbook>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment