The clojure telehash
project<https://www.assembla.com/code/clj-telehash/git/nodes>includes
a chat application as one of the samples. I have been attempting
to port it to run in the
browser<http://will.tip.dhappy.org/lib/telehash/demo/chat/>as a rhino
script executing in a java applet.
The application never finds any other switches (counterpartySwitchForEndFound
is never called). I'm hoping that maybe someone here can tell me what I'm
missing.
var InterestingEndsHolderImpl =
Packages.telehash.switchimpl.api.InterestingEndsHolderImpl
var ApplicationPortImpl =
Packages.telehash.switchimpl.api.ApplicationPortImpl
var interestingEndsHolder = new InterestingEndsHolderImpl()
var applicationPort = new ApplicationPortImpl()
var SwitchListener = Packages.telehash.api.SwitchListener
var TelexListener = Packages.telehash.api.TelexListener
applicationPort.addSwitchListener( new SwitchListener( {
counterpartySwitchForEndFound : function( hash, counterpartySwitch ) {
print( "counterpartySwitchForEndFound: " + hash )
if( ! applicationPort.hash( self ).equals( hash ) ) {
interestingEndsHolder.put( hash, counterpartySwitch )
if( counterpartySwitch.isConnected() ) {
print( "Switch Connected: " + counterpartySwitch.getIP() +
":" + counterpartySwitch.getPort() )
}
var telexListenerScope = counterpartySwitch.addTelexListener(
new TelexListener( {
receivedTelex : function( telex ) {
print( 'Recieved telex:' )
if( telex.containsKey( 'simplechat' ) ) {
var chat_telex = telex.get( 'simplechat' )
print( contactName + ": " + chat_telex.get( 'msg'
).toString() )
}
}
} ) )
}
}
} ) )
applicationPort.startSwitch()
print( "Adding Own End: " + applicationPort.hash( username ) )
applicationPort.addOwnEnd( applicationPort.hash( username ) )
print( "Adding Other End: " + applicationPort.hash( contactName ) )
applicationPort.addOtherEnd( applicationPort.hash( contactName ) )
You can run this code by checking out the git
repo<https://github.com/wholcomb/telehash-demo>and running: java
-classpath
/usr/share/java/js.jar:/usr/share/java/jline.jar:lib/telehash/jar
org.mozilla.javascript.tools.shell.Main test/clj-telehash/rhino
Currently it outputs:
Adding Own End: 3e3e5802bd4cad8e29e144b515307d8204a3202a
Adding Other End: da6645f6e22bf5f75974dc7eed5fcd6160d6b51e
"Starting other threads ..."
I've run
wireshark<http://will.tip.dhappy.org/lib/telehash/demo/chat/packet/log>and
there is definitely traffic. Any help would be much appreciated.
-Will
_______________________________________________
p2p-hackers mailing list
[email protected]
http://lists.zooko.com/mailman/listinfo/p2p-hackers