You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(7) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <rep...@mo...> - 2005-01-19 03:38:53
|
Author: mod-pubsub-developer
Date: Tue Jan 18 10:16:25 2005
New Revision: 24
Modified:
flash_repubsub/README
Log:
Fixed a typo in unsubscribe example. Added clarification in subscribe example.
Modified: flash_repubsub/README
==============================================================================
--- flash_repubsub/README (original)
+++ flash_repubsub/README Tue Jan 18 10:16:25 2005
@@ -206,6 +206,7 @@
routeId = myRepubsubClient.subscribe("/what/alerts", onMessage, {do_max_age:"infinity"}, onSubscribeStatus);
// or: myRepubsubClient.subscribe("/what/alerts", onMessage);
// or: myRepubsubClient.subscribe("/what/alerts");
+ // or: myRepubsubClient.subscribe("/what/alerts", undefined, undefined, onSubscribeStatus);
unsubscribe(kn_route_location:String, statusHandler):void
@@ -232,7 +233,7 @@
trace("onUnsubscribeStatus: [" + message.status + "]");
}
- myRepubsubClient.unsubscribe(routeId, onSubscribeStatus);
+ myRepubsubClient.unsubscribe(routeId, onUnsubscribeStatus);
// or: myRepubsubClient.unsubscribe(routeId);
|
|
From: <rep...@mo...> - 2005-01-18 01:37:39
|
Author: mod-pubsub-developer
Date: Mon Jan 17 09:09:09 2005
New Revision: 23
Modified:
kn_server/twisted_pubsub/pubsub.py
Log:
Send terminating null byte on FlashTunnel.heartbeat().
Modified: kn_server/twisted_pubsub/pubsub.py
==============================================================================
--- kn_server/twisted_pubsub/pubsub.py (original)
+++ kn_server/twisted_pubsub/pubsub.py Mon Jan 17 09:09:09 2005
@@ -792,7 +792,9 @@
"""
def encode(self, dict):
return SimpleTunnel.encode(self, dict) + chr(0)
-
+
+ def heartbeat(self):
+ return SimpleTunnel.heartbeat(self) + chr(0)
class JavaScriptTunnel(Tunnel):
"""
|
|
From: <rep...@mo...> - 2005-01-18 00:12:47
|
Author: mod-pubsub-developer Date: Mon Jan 17 07:43:43 2005 New Revision: 22 Added: flash_repubsub/ flash_repubsub/LICENSE flash_repubsub/README flash_repubsub/classes/ flash_repubsub/classes/repubsub/ flash_repubsub/classes/repubsub/AutoReconnectClient.as flash_repubsub/classes/repubsub/Callback.as flash_repubsub/classes/repubsub/Client.as flash_repubsub/classes/repubsub/Hex.as flash_repubsub/classes/repubsub/HttpRequest.as flash_repubsub/classes/repubsub/IClient.as flash_repubsub/classes/repubsub/IMessageListener.as flash_repubsub/classes/repubsub/ITransport.as flash_repubsub/classes/repubsub/ITunnelListener.as flash_repubsub/classes/repubsub/SimpleRequest.as flash_repubsub/classes/repubsub/SimpleTunnel.as flash_repubsub/classes/repubsub/StatusHandlerWrapper.as flash_repubsub/classes/repubsub/StringUtil.as flash_repubsub/classes/repubsub/Transport.as flash_repubsub/classes/repubsub/UrlParse.as flash_repubsub/classes/repubsub/XmlSocketConnection.as flash_repubsub/classes/repubsub/test/ flash_repubsub/classes/repubsub/test/AS2UnitRepubsubClientTests.fla = (contents, props changed) flash_repubsub/classes/repubsub/test/Config.as flash_repubsub/classes/repubsub/test/DerivedClient.as flash_repubsub/classes/repubsub/test/LiveTests.as flash_repubsub/classes/repubsub/test/MockMessageListener.as flash_repubsub/classes/repubsub/test/MockTransport.as flash_repubsub/classes/repubsub/test/README flash_repubsub/classes/repubsub/test/TestCallback.as flash_repubsub/classes/repubsub/test/TestClient.as flash_repubsub/classes/repubsub/test/TestHex.as flash_repubsub/classes/repubsub/test/TestHttpRequest.as flash_repubsub/classes/repubsub/test/TestSimpleRequest.as flash_repubsub/classes/repubsub/test/TestStatusHandlerWrapper.as flash_repubsub/classes/repubsub/test/TestStringUtil.as flash_repubsub/classes/repubsub/test/TestTransport.as flash_repubsub/classes/repubsub/test/TestUrlParse.as flash_repubsub/examples/ flash_repubsub/examples/Echo.fla (contents, props changed) flash_repubsub/examples/EchoAutoReconnect.fla (contents, props chang= ed) flash_repubsub/examples/HelloWorld.fla (contents, props changed) flash_repubsub/examples/HelloWorldAutoReconnect.fla (contents, props= changed) flash_repubsub/examples/HelloWorldMessageObject.fla (contents, props= changed) flash_repubsub/examples/HelloWorldRegisterCallbacks.fla (contents, p= rops changed) flash_repubsub/examples/HelloWorldStatusCallbacks.fla (contents, pro= ps changed) Log: Upload flash_repubsub ActionScript2 client library. Added: flash_repubsub/LICENSE =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- (empty file) +++ flash_repubsub/LICENSE Mon Jan 17 07:43:43 2005 @@ -0,0 +1,44 @@ +FLASH REPUBSUB LICENSE NOTICE=0D +_____________________________=0D +=0D +The flash_repubsub ActionScript2 client library is distributed under=0D +the standard BSD license [1] and copyright 2005 Planar Systems, Inc.,=0D +unless otherwise stated in the source file.=0D +=0D +[1] http://www.opensource.org/licenses/bsd-license.php=0D +=0D +The license text follows:=0D +=0D +=0D +Copyright (c) 2005, Planar Systems, Inc.=0D +All rights reserved.=0D +=0D +Redistribution and use in source and binary forms, with or without=0D +modification, are permitted provided that the following conditions=0D +are met:=0D +=0D + 1. Redistributions of source code must retain the above copyright =0D + notice, this list of conditions and the following disclaimer. =0D +=0D + 2. Redistributions in binary form must reproduce the above =0D + copyright notice, this list of conditions and the following =0D + disclaimer in the documentation and/or other materials =0D + provided with the distribution. =0D +=0D + 3. Neither the name of Planar Systems, Inc. nor the names of its =0D + contributors may be used to endorse or promote products derived =0D + from this software without specific prior written permission. =0D +=0D +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS =0D +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT =0D +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR =0D +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLANAR SYSTEMS,=0D +INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, =0D +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT =0D +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, =0D +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY =0D +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT =0D +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE =0D +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.=0D +=0D +=0D Added: flash_repubsub/README =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- (empty file) +++ flash_repubsub/README Mon Jan 17 07:43:43 2005 @@ -0,0 +1,343 @@ +FLASH REPUBSUB README=0D +_____________________=0D +=0D +=0D +The Flash repubsub client allows you to connect to repubsub servers to p= ublish =0D +and subscribe to repubsub topics from within Flash applications.=0D +=0D +This is a Flash ActionScript 2.0 library, thus you will need to develop = your =0D +content in a Flash development environment that supports AS2 (e.g., Macr= omedia =0D +Flash MX Professional 2004).=0D +=0D +The library has been tested with repubsub version 0.2.7, however it may = work =0D +with other mod_pubsub servers that support the FlashTunnel.=0D +=0D +=0D +=0D +S E T U P=0D +---------=0D +=0D +In order to develop Flash content that uses the repubsub client, you mus= t =0D +place the repubsub directory (found in the classes directory) within you= r=0D +classpath. For example, (depending on OS) copy the repubsub directory to= :=0D +=0D + Macintosh OS X=0D + Hard Drive/Users/USER/Library/Application Support/Macromedia/=0D + Flash MX 2004/LANGUAGE_CODE/Configuration/Classes=0D +=0D + Windows 2000, Windows XP:=0D + C:\Documents and Settings\USER\Local Settings\Application Data\=0D + Macromedia\Flash MX 2004\LANGUAGE_CODE\Configuration\Classes=0D +=0D +For example, the hierarchy (on Windows) would look like:=0D +=0D + C:\Documents and Settings\=0D + <username>\=0D + Local Settings\=0D + Application Data\=0D + Macromedia\=0D + Flash MX 2004\=0D + en\=0D + Configuration\=0D + Classes\=0D + repubsub\=0D + test\=0D +=0D +=0D +=0D +U S A G E=0D +---------=0D +=0D +The Flash repubsub client is accessed through either the repubsub.Client= or =0D +the repubsub.AutoReconnectClient classes.=0D +=0D +=0D + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0D + class repubsub.Client=0D + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0D +=0D + --------------------------- =0D + repubsub.Client Constructor =0D + ---------------------------=0D +=0D + repubsub.Client(serverUrl:String)=0D +=0D + Constructs an instance of the repubsub client object. Takes the = server =0D + URL as a parameter. Note, connection doesn't happen until the fi= rst =0D + publish or subscribe call. =0D +=0D + Example:=0D + var myRepubsubClient =3D repubsub.Client("http://localhost:808= 0/kn");=0D +=0D +=0D + ------------------------------=0D + repubsub.Client Event Handlers=0D + ------------------------------=0D +=0D + onMessage(message:Object):Void=0D + ------------------------------=0D +=0D + Message handler. Called when a new message arrives. May be overr= idden =0D + on specific subscriptions. Assign a function with the same signa= ture =0D + to register for callbacks.=0D +=0D + Example:=0D + myRepubsubClient.onMessage =3D function(message) { =0D + trace(message.kn_payload); =0D + }=0D +=0D +=0D + onStatus(message:Object):Void=0D + -----------------------------=0D +=0D + Status handler. Called with status response to a repubsub reques= t. May =0D + be overridden on specific publish, subscribe, or unsubscribe.=0D +=0D + Example:=0D + myRepubsubClient.onStatus =3D function(message) {=0D + trace("onStatus: [" + message.status + "]");=0D + if ("200" =3D=3D message.status.split(" ", 1)[0]) {=0D + // success...=0D + }=0D + }=0D +=0D +=0D + onConnect():Void=0D + ----------------=0D +=0D + Called when connection established to the repubsub server.=0D +=0D + Example:=0D + myRepubsubClient.onConnect =3D function() { =0D + trace("Connected"); =0D + }=0D +=0D +=0D + onDisconnect():Void=0D + -------------------=0D +=0D + Called when the connection to the repubsub server is lost.=0D +=0D + Example:=0D + myRepubsubClient.onDisconnect =3D function() { =0D + trace("Disconnected"); =0D + }=0D +=0D +=0D + onHeartbeat():Void=0D + ------------------=0D +=0D + Called each time the server sends a heartbeat.=0D +=0D + Example:=0D + myRepubsubClient.onHeartbeat =3D function() { =0D + trace("Heartbeat"); =0D + }=0D +=0D +=0D + -----------------------=0D + repubsub.Client Methods=0D + -----------------------=0D +=0D + publish(topic:String, message, statusHandler:Object):String=0D + -----------------------------------------------------------=0D +=0D + Publishes a message to a topic.=0D +=0D + Parameters:=0D + topic - the target topic, e.g., "/what/alerts"=0D + message - Either a string or an object. If an object then me= mber =0D + variables of object will be passed in message. Passing a= =0D + kn_payload string is equivalent to passing an object wit= h the =0D + variable set to the string value. The message parameter = =0D + may also be a number or a boolean, in which case it will= =0D + be converted into a string.=0D + statusHandler (optional) - Status handler for this call. Ove= rrides =0D + Client.onStatus (if set) for this particular call. The p= arameter =0D + may be a function or an object with an onStatus(message)= member =0D + function.=0D +=0D + Returns:=0D + Returns the generated kn_id for the published message. You m= ay also =0D + set your own kn_id in the message, e.g. message.kn_id =3D "m= yid".=0D +=0D + Example: =0D + function onPublishStatus(message) {=0D + trace("onPublishStatus: [" + message.status + "]");=0D + }=0D + var kn_id;=0D + kn_id =3D myRepubsubClient.publish("/what/World", "Hello Wor= ld", onPublishStatus);=0D + // or: myRepubsubClient.publish("/what/World", {kn_payload:"= Hello World, kn_expires:"+300"}, onPublishStatus); =0D + // or: myRepubsubClient.publish("/what/World", "Hello World"= ); =0D +=0D +=0D + subscribe(topic:String, msgCallback, options, statusHandler):String=0D + -------------------------------------------------------------------=0D +=0D + Subscribes to a topic.=0D +=0D + Parameters:=0D + topic - the name of the topic to subscribe to e.g., "/what/a= lerts"=0D + msgCallback (optional) - an optional callback function or ob= ject =0D + with an onMessage(msg) function. Overrides Client.onMess= age. =0D + options (optional) - an object with members that will augmen= t or =0D + override attributes of the subscribe message. For exampl= e,=0D + can use to set do_max_age: var options =3D {do_max_age:"= infinity"};=0D + =0D + statusHandler (optional) - Status handler for this call. Ove= rrides =0D + Client.onStatus (if set) for this particular call. The p= arameter =0D + may be a function or an object with an onStatus(message)= member =0D + function.=0D +=0D + Returns:=0D + Returns kn_route_location for this subscription. Must pass =0D + kn_route_location to unsubscribe.=0D +=0D + Example: =0D + function onMessage(message) {=0D + trace(message.kn_payload);=0D + trace(message.myCustomHeader);=0D + }=0D + function onSubscribeStatus(message) {=0D + trace("onSubscribeStatus: [" + message.status + "]");=0D + }=0D + =0D + var routeId;=0D + routeId =3D myRepubsubClient.subscribe("/what/alerts", onMes= sage, {do_max_age:"infinity"}, onSubscribeStatus); =0D + // or: myRepubsubClient.subscribe("/what/alerts", onMessage)= ;=0D + // or: myRepubsubClient.subscribe("/what/alerts");=0D + =0D +=0D + unsubscribe(kn_route_location:String, statusHandler):void=0D + ---------------------------------------------------------=0D +=0D + Unsubscribes from a subscribed topic=0D +=0D + Parameters:=0D + kn_route_location - the route id returned by subscribe()=0D + statusHandler (optional) - Status handler for this call. Ove= rrides =0D + Client.onStatus (if set) for this particular call. The p= arameter =0D + may be a function or an object with an onStatus(message)= member =0D + function.=0D +=0D + Returns:=0D + Void=0D +=0D + Example: =0D + var routeId =3D myRepubsubClient.subscribe("/what/alerts");=0D +=0D + // ... Some time later ...=0D +=0D + function onUnsubscribeStatus(message) {=0D + trace("onUnsubscribeStatus: [" + message.status + "]");=0D + }=0D +=0D + myRepubsubClient.unsubscribe(routeId, onSubscribeStatus); = =0D + // or: myRepubsubClient.unsubscribe(routeId); =0D +=0D +=0D + connect():Void=0D + --------------=0D +=0D + Explicitly connect to the server. Usually not necessary to call = this =0D + function, as connect() is called from publish, subscribe, and =0D + unsubscribe, if not already connected to the server. Use the =0D + AutoReconnectClient class to automatically reconnect on disconne= ct.=0D +=0D +=0D + disconnect():Void=0D + -----------------=0D +=0D + Disconnect from the server.=0D +=0D +=0D + isConnected():Boolean=0D + ------------------=0D +=0D + Returns true if connected to the server.=0D +=0D +=0D + getTunnelUrl():String=0D + ---------------------=0D +=0D + Returns the tunnel url.=0D +=0D +=0D +=0D + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=0D + class repubsub.AutoReconnectClient extends repubsub.Client=0D + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=0D +=0D + repubsub.AutoReconnectClient is a subclass of repubsub.Client that =0D + automatically attempts to reconnect to the server if the connection ge= ts =0D + dropped. The repubsub.Client usage (see above) applies to =0D + repubsub.AutoReconnectClient.=0D +=0D + ---------------------------------------- =0D + repubsub.AutoReconnectClient Constructor =0D + ----------------------------------------=0D +=0D + repubsub.AutoReconnectClient(serverUrl:String, retryIntervalSeconds:= Number)=0D +=0D + Constructs an instance of the repubsub AutoReconnectClient objec= t. =0D + Unlike repubsub.Client AutoReconnectClient will try to connect t= o the =0D + server immediately upon construction.=0D +=0D + Parameters:=0D + serverUrl - the url of the repubsub server=0D + retryIntervalSeconds (optional) - if the connection isn't es= tablished=0D + within retryIntervalSeconds then it will retry. If not s= upplied =0D + then a default interval will be used.=0D + =0D + Example:=0D + var myRepubsubClient =3D repubsub.Client("http://localhost:808= 0/kn");=0D +=0D +=0D +=0D +E X A M P L E S=0D +---------------=0D +=0D +Hello World example:=0D +=0D + /*=0D + HelloWorld Flash repubsub example=0D + =0D + Simple example. Subscribes to "World" topic and then sends a =0D + "Hello World" message to the "World" topic.=0D + =0D + If successful then onMessage() will trace the "Hello World" message.=0D + */=0D +=0D + // Initialize client with server address.=0D + repubsubClient =3D new repubsub.Client("http://localhost:8080/kn")= ; =0D +=0D + // Handle subscription messages=0D + function onMessage(message) {=0D + trace("onMessage: [" + message.kn_payload + "]");=0D + }=0D +=0D + var worldTopic =3D "/what/flash/example/World";=0D +=0D + // Subscribe to "World" topic=0D + var routeId =3D repubsubClient.subscribe(worldTopic, onMessage);=0D +=0D + // Publish "Hello World" message to "world" topic=0D + repubsubClient.publish(worldTopic, "Hello World");=0D +=0D + stop();=0D +=0D +=0D +See the examples directory for other simple examples.=0D +=0D +=0D +=0D +C R E D I T S=0D +-------------=0D +=0D +The Flash repubsub ActionScript2 client library was written by Patrick T= hompson =0D +and made available (under copyright and BSD licensing) by Planar Systems= , Inc.=0D +=0D +The design of the library was motivated by Ben Sittler's Python client l= ibrary =0D +pubsublib.py.=0D +=0D +=0D Added: flash_repubsub/classes/repubsub/AutoReconnectClient.as =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- (empty file) +++ flash_repubsub/classes/repubsub/AutoReconnectClient.as Mon Jan 17 07:= 43:43 2005 @@ -0,0 +1,108 @@ +=EF=BB=BF/* +Copyright (c) 2005, Planar Systems, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright=20 + notice, this list of conditions and the following disclaimer.=20 + + 2. Redistributions in binary form must reproduce the above=20 + copyright notice, this list of conditions and the following=20 + disclaimer in the documentation and/or other materials=20 + provided with the distribution.=20 + + 3. Neither the name of Planar Systems, Inc. nor the names of its=20 + contributors may be used to endorse or promote products derived=20 + from this software without specific prior written permission. =20 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLANAR SYSTEMS, +INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/* +* AutoReconnectClient class. +*=20 +* Client subclass. Automatically reconnects if gets disconnected. +* When connecting, keeps retrying until successful. +*=20 +*/ + +import repubsub.Client; + + +class repubsub.AutoReconnectClient extends Client +{ + static var _defaultRetryIntervalSeconds:Number =3D 15; + private var _retryIntervalSeconds:Number; + private var _retryIntervalId; + private var _doReconnect:Boolean; +=09 + // Constructor.=20 + function AutoReconnectClient(serverUrl:String, retryIntervalSeconds:= Number) { + // serverUrl is something like http://127.0.0.1:8080/kn + super(serverUrl); + if (undefined !=3D retryIntervalSeconds) { + this._retryIntervalSeconds =3D retryIntervalSeconds; + } else {=20 + this._retryIntervalSeconds =3D _defaultRetryIntervalSeconds; + } + this._retryIntervalId =3D undefined; + this.connect(); + } +=09 + function connect():Void { + this._doReconnect =3D true; + if (!this._connected) { + var retryInterval =3D 1000 * this._retryIntervalSeconds; + if (undefined =3D=3D this._retryIntervalId) { + this._retryIntervalId =3D setInterval(this, "_retryIntervalCallback"= , retryInterval); + } + super.disconnect();=20 + super._connect(); + } + } =20 + =09 + function disconnect():Void { + this._doReconnect =3D false; + this._clearInterval(); + super.disconnect(); + } =20 + =20 + function _onStartTunnel():Void { + this._clearInterval(); + super._onStartTunnel(); + } + =20 + function _onStopTunnel():Void { + super._onStopTunnel(); + if (this._doReconnect) { + this.connect(); + } + } + + private function _retryIntervalCallback():Void { + if (!this._connected) { + this.connect(); + } else { + this._clearInterval(); + } + }=20 +=09 + private function _clearInterval():Void { + clearInterval(this._retryIntervalId); + this._retryIntervalId =3D undefined; + } +} Added: flash_repubsub/classes/repubsub/Callback.as =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- (empty file) +++ flash_repubsub/classes/repubsub/Callback.as Mon Jan 17 07:43:43 2005 @@ -0,0 +1,75 @@ +=EF=BB=BF/* +Copyright (c) 2005, Planar Systems, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright=20 + notice, this list of conditions and the following disclaimer.=20 + + 2. Redistributions in binary form must reproduce the above=20 + copyright notice, this list of conditions and the following=20 + disclaimer in the documentation and/or other materials=20 + provided with the distribution.=20 + + 3. Neither the name of Planar Systems, Inc. nor the names of its=20 + contributors may be used to endorse or promote products derived=20 + from this software without specific prior written permission. =20 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLANAR SYSTEMS, +INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/* +* Callback class +*=20 +* Wraps callback functions and objects. +* +*/ + +class repubsub.Callback { + private var _callbackObject:Object; + private var _callbackFunc:Function; + private var _functionName:String; + + function Callback(callback, functionName:String) { + switch (typeof callback) { + case "undefined": + throw new Error("Callback - invalid callback specificati= on"); + break; + case "function": + _callbackFunc =3D callback; + break; + case "object": + if (undefined =3D=3D functionName || null =3D=3D functio= nName || "" =3D=3D functionName) { + throw new Error("Callback - invalid function name"); + } + _callbackObject =3D callback; + _functionName =3D functionName; + break; + default: + throw new Error("Callback - invalid callback specificati= on"); + } =20 + } + =20 + function call(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, = arg10) { + if (undefined !=3D _callbackObject) { + _callbackObject[_functionName](arg1, arg2, arg3, arg4, arg5,= arg6, arg7, arg8, arg9, arg10); + } else { + _callbackFunc(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8= , arg9, arg10); + } + } + =20 +} \ No newline at end of file Added: flash_repubsub/classes/repubsub/Client.as =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- (empty file) +++ flash_repubsub/classes/repubsub/Client.as Mon Jan 17 07:43:43 2005 @@ -0,0 +1,414 @@ +=EF=BB=BF/* +Copyright (c) 2005, Planar Systems, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright=20 + notice, this list of conditions and the following disclaimer.=20 + + 2. Redistributions in binary form must reproduce the above=20 + copyright notice, this list of conditions and the following=20 + disclaimer in the documentation and/or other materials=20 + provided with the distribution.=20 + + 3. Neither the name of Planar Systems, Inc. nor the names of its=20 + contributors may be used to endorse or promote products derived=20 + from this software without specific prior written permission. =20 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLANAR SYSTEMS, +INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/* +* Client class. +*=20 +* Primary interface to repubsub. +*=20 +*/ + +import repubsub.IClient; +import repubsub.IMessageListener; +import repubsub.ITunnelListener; +import repubsub.ITransport; +import repubsub.StatusHandlerWrapper; +import repubsub.Transport; +import repubsub.Callback; +import repubsub.UrlParse; + +class repubsub.Client=20 + implements IClient, IMessageListener, ITunnelListener +{ + public var onMessage:Function =3D undefined; // signature: f(mess= age:Object):Void + public var onHeartbeat:Function =3D undefined; // signature: f():Vo= id + public var onStatus:Function =3D undefined; // signature: f(mess= age:Object):Void + public var onConnect:Function =3D undefined; // signature: f():Vo= id + public var onDisconnect:Function =3D undefined; // signature: f():Vo= id + + static var _KN_ROUTES_ =3D "/kn_routes/"; + =20 + private var _serverUrl:String; + private var _host:String; + private var _port:Number; + private var _tunnelUrl:String; + private var _randomStr:String; + private var _requestQueue:Array; + private var _messageHandlerMap:Object; + private var _connected:Boolean; + private var _connecting:Boolean; + private var _transport:ITransport; + + =20 + // Constructor.=20 + function Client(serverUrl:String) {=20 + // serverUrl is something like http://127.0.0.1:8080/kn + this._serverUrl =3D serverUrl; + =20 + // check url, if invalid then exception will be thrown, if ok th= en extract host and port + var urlParts:Array =3D UrlParse.parseUrl(serverUrl); + this._host =3D urlParts[0]; + this._port =3D urlParts[1]; + =20 + this._randomStr =3D randomString(); + this._requestQueue =3D new Array(); + this._messageHandlerMap =3D new Object(); + this._connected =3D false; + this._connecting =3D false; + =20 + // create transport + this._transport =3D undefined; + =20 + // create journal url + this._tunnelUrl =3D _serverUrl + "/who/anonymous/s/" + randomStr= ing() + "/kn_journal"; + } + + function getTunnelUrl():String { + return this._tunnelUrl; + } + =20 + // publish - enqueue a "notify" request to submit to the server" + // + // Usage: kn_id =3D publish("/what/imagepublish",{kn_payload:"spa= ceman.jpg"},myStatusHandler); + // Params: + // returns kn_id: the generated kn_id (you may also set the k= n_id in the message) + // topic: the string representing the target topic + // message: an object with with attributes for each message e= lement, i.e. a map + // statusHandler: (optional) an object with an onStatus(Objec= t m) method + // + // Default do_method is "notify", but may be overridden in messag= e object parameter + function publish(topic:String, message, statusHandler):String { + if (undefined =3D=3D topic || null =3D=3D topic) { + throw new Error("Client:publish() - topic param undefined"); + } + =20 + if (undefined =3D=3D message) { + message =3D {}; + } +=20 + // if message is a string, number, or boolean then create new me= ssage with kn_payload set to message string + if (typeof message !=3D "object") { + var messageString:String =3D message.toString(); + message =3D {kn_payload : messageString}; + } + + var statusHandlerCallback:Callback =3D this._createCallback(stat= usHandler, "onStatus"); + =20 + var requestMessage:Object =3D { + kn_to : this._canonicalizeTopic(topic), + do_method : "notify", + kn_id : this._randomStr + } + + // copy message (parameter) properties to request message =20 + for (var prop:String in message) { + requestMessage[prop] =3D message[prop]; + } +=20 + requestMessage.kn_to =3D this._canonicalizeTopic(requestMessage.= kn_to); =20 + =20 + this._enqueue(requestMessage, statusHandlerCallback); + =20 + return requestMessage.kn_id; + } + =20 + // subscribe() + // Subscribe to a topic. Returns kn_route_location needed to unsubs= cribe. + // + // -topic is the name of the topic to subscribe to e.g., /what/im= agepublish + // -msgCallback is an optional callback function or object with a= n onMessage() function, overrides this.onMessage() + // -options is an object whose properties will be added to the su= bscribe message + // -statusHandler is an optional callback function or object with= an onStatus() function, overrides this.onStatus() + // for this subscription. + function subscribe(topic:String, msgCallback, options, statusHandler= ):String { + var messageCallback:Callback =3D this._createCallback(msgCallbac= k, "onMessage"); + var statusHandlerCallback:Callback =3D this._createCallback(stat= usHandler, "onStatus"); + =20 + // set base message + var requestMessage =3D { + kn_from : topic, + kn_to : messageCallback, + do_method : "route", + kn_id : randomString() + } + =20 + // copy properties from options object (if defined) + for (var prop in options) { + requestMessage[prop] =3D options[prop]; + } =20 + =20 + requestMessage.kn_from =3D this._canonicalizeTopic(requestMessag= e.kn_from); + + // requestMessage.kn_uri is the route URI. + if (undefined =3D=3D requestMessage.kn_uri) { + requestMessage.kn_uri =3D requestMessage.kn_from + _KN_ROUTE= S_ + requestMessage.kn_id; + } + =20 + // if kn_to wasn't overridden by options object then set callbac= k handler and set kn_to to tunnel url + if (typeof requestMessage.kn_to !=3D "string") { + this._addMessageHandler(requestMessage.kn_uri, requestMessag= e.kn_to); + requestMessage.kn_to =3D this.getTunnelUrl(); =20 + } + =20 + this._enqueue(requestMessage, statusHandlerCallback); + =20 + return requestMessage.kn_uri; + } + + + // unsubscribe()) + // Unsubscribes to a topic that was previously subscibed to. + // -kn_route_location is the route id returned by subscribe() + // -statusHandler is an optional callback function or object wit= h an onStatus() function, overrides this.onStatus() + // for this call. + // + function unsubscribe(kn_route_location:String, statusHandler):Void { + var statusHandlerCallback:Callback =3D this._createCallback(stat= usHandler, "onStatus"); + if (-1 =3D=3D kn_route_location.indexOf(_KN_ROUTES_)) { + statusHandlerCallback.call( + { + status : "400 Bad Request", + kn_payload : "Invalid route id... use route id retur= ned by subscribe()." + } + ); + return; + } + =20 + var routeIdParts =3D kn_route_location.split(_KN_ROUTES_); + var kn_from =3D routeIdParts[0]; // topic to unsubscribe from + var kn_id =3D routeIdParts[1]; // kn_id + + var requestMessage =3D { + kn_from: this._canonicalizeTopic(kn_from), + kn_to : "", + do_method : "route", + kn_id : kn_id, + kn_expires : "+5" + }=20 + + this._enqueue(requestMessage, statusHandlerCallback); + }=20 + =20 + function connect():Void { + if (!this._connected) { + this.disconnect(); + this._connect(); + } + } =20 +=09 + function disconnect():Void { + this._connecting =3D false; + if (this._connected) { + this._transport.stopTunnel(); + this._connected =3D false; + } + delete this._transport; + } =20 + =20 + function isConnected():Boolean { + return this._connected; + } + =20 + =20 + private function _dispatch(message:Object) { + var kn_route_location =3D message.kn_route_location; =20 + if (undefined !=3D kn_route_location) { + var messageHandler:Callback =3D this._getMessageHandler(kn_r= oute_location); + if (undefined !=3D messageHandler) { + messageHandler.call(message);=20 + } else { + throw new Error("Client._dispatch: no message handler de= fined for kn_route_location =3D " + kn_route_location); + } + } + } =20 + =20 + function _onMessage(message:Object):Void { + this._dispatch(message); + } + =20 + function _onHeartbeat():Void { + this.onHeartbeat(); + } + =20 + function _onStartTunnel():Void { + this._connected =3D true; + this._connecting =3D false; + this.onConnect(); + this._process(); + } + =20 + function _onStopTunnel():Void { + this._connected =3D false; + this._connecting =3D false; + this.onDisconnect(); + } + + function _onRequestComplete(kn_status_from:String):Void { + // make sure message handler cleaned up + this._removeMessageHandler(kn_status_from); + } + =20 + private function _addMessageHandler(kn_route_location:String, handle= r:Callback):Void { + // note: handler should have onMessage(message:String) method + this._messageHandlerMap[kn_route_location] =3D handler; + } + =20 + private function _removeMessageHandler(kn_route_location:String) { + this._messageHandlerMap[kn_route_location] =3D undefined;=20 + } + =20 + private function _getMessageHandler(kn_route_location:String):Callba= ck { + return this._messageHandlerMap[kn_route_location];=20 + } + =20 + // message is the message object to enqueue, statusHandler is an "on= Status" callback object + private function _enqueue(message:Object, statusHandler:Callback) { + var messageCopy:Object =3D { + kn_status_from : randUri(), + kn_response_format : "flash", + kn_status_to : this._tunnelUrl + } + =20 + for (var prop:String in message) { + messageCopy[prop] =3D message[prop]; + } + =20 + var kn_status_from:String =3D messageCopy["kn_status_from"]; + =20 + // wrap status handler so that it can be called like any other m= essage handler + var wrapper =3D new StatusHandlerWrapper(this, kn_status_from, s= tatusHandler); + var wrapperCallback:Callback =3D new Callback(wrapper, "onMessag= e"); + this._addMessageHandler(kn_status_from, wrapperCallback); + =20 + this._requestQueue.push(messageCopy); + this._process(); + =20 + return messageCopy["kn_status_from"]; + } + =20 + private function _process() { + if (!this._connected) { // not connected + if (!this._connecting) { + this._connect(); + return; + } + } else { // connected + var message:Object; + while (message =3D _requestQueue.shift(), message !=3D undefined) { + this._transport.sendMessage(message); + } + } + } + =20 + private function _connect() { + if (!this._connected) { + if (!this._connecting) { + this._connecting =3D true; + var message =3D { + do_method : "route", + kn_from : this._tunnelUrl, + kn_to : "javascript:", + kn_status_from : randUri(), + kn_response_format : "flash" + } + var kn_status_from =3D message.kn_status_from; + =20 + var onStatusCallback =3D new Callback(this, "onStatus"); + var wrapper =3D new StatusHandlerWrapper(this, kn_status= _from, onStatusCallback); + var wrapperCallback:Callback =3D new Callback(wrapper, "= onMessage"); + this._addMessageHandler(kn_status_from, wrapperCallback)= ; + + this._transport =3D new Transport(this._serverUrl, this, this); = =20 + this._transport.startTunnel(message); + } + } + } =20 + + private function _createCallback(callback, defaultFunctionName):Call= back { + var callbackObject:Callback; + switch (typeof callback) { + case "undefined": + // default is to call defaultFunctionName function assig= ned to client (or implemented in child) + callbackObject =3D new Callback(this, defaultFunctionNam= e); + break; + case "function": + // if function then set callback to function + callbackObject =3D new Callback(callback); + break; + case "object": + // if object then set callback to callback[defaultFuncti= onName](); + callbackObject =3D new Callback(callback, defaultFunctio= nName); + break; + default: + throw new Error("Client._createCallback: invalid callbac= k parameter"); + }=20 + return callbackObject; + } + + private function _canonicalizeTopic(topic) { + if (undefined =3D=3D topic) { + throw new Error("Client._canonicalizeTopic: undefined topic")= ;=20 + } + =20 + if (topic.indexOf("http://") =3D=3D 0) { + var urlParts:Array; + // make sure we can parse url + urlParts =3D UrlParse.parseUrl(topic); + var host =3D urlParts[0]; + var port =3D urlParts[1]; + var path =3D urlParts[2]; + // make sure host and port matches the server + if (host !=3D this._host || port !=3D this._port) { + throw new Error("Client._canonicalizeTopic - url host an= d port must match server"); + } + return topic; + }=20 + =20 + if (topic.charAt(0) !=3D "/") { + topic =3D "/" + topic; + } + =20 + return UrlParse.constructUrl(this._host, this._port, topic); + } + =20 + =20 + static function randUri():String { + return "javascript://tempuri.org/" + randomString(); + } + =20 + static function randomString():String { + return Math.random().toString().substring(2,11); + } + =20 +} Added: flash_repubsub/classes/repubsub/Hex.as =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- (empty file) +++ flash_repubsub/classes/repubsub/Hex.as Mon Jan 17 07:43:43 2005 @@ -0,0 +1,91 @@ +=EF=BB=BF/* +Copyright (c) 2005, Planar Systems, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright=20 + notice, this list of conditions and the following disclaimer.=20 + + 2. Redistributions in binary form must reproduce the above=20 + copyright notice, this list of conditions and the following=20 + disclaimer in the documentation and/or other materials=20 + provided with the distribution.=20 + + 3. Neither the name of Planar Systems, Inc. nor the names of its=20 + contributors may be used to endorse or promote products derived=20 + from this software without specific prior written permission. =20 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLANAR SYSTEMS, +INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/* +* Hex class +*=20 +* Hex manipulation functions +*=20 +*/ + +class repubsub.Hex { + =20 + // convert a character to character code represented as hex value (a= s string) + static function charToHex(char:String):String { + var charCode:Number =3D char.charCodeAt(0); + if (char.length !=3D 1) throw new Error("HttpRequest:charToHex()= - more than one character"); + if (charCode > 255) throw new Error("HttpRequest:charToHex() - c= haracter out of range " + char); + =20 + return hexDigit(charCode / 16) + hexDigit(charCode % 16); + } + + // convert a one or two digit hex string to corresponding character + static function hexToChar(hexStr:String):String { + if (hexStr.length > 2 || hexStr.length < 1) { + throw new Error("HttpRequest:hexToChar() - invalid hex strin= g"); + } =20 + if (hexStr.length =3D=3D 1) { + return String.fromCharCode(hexValue(hexStr.charAt(0))); + } else { + return String.fromCharCode( + hexValue(hexStr.charAt(0)) * 16 + hexValue(hexStr.charAt= (1)) =20 + ); + } + } =20 + =20 + // convert integer 0-15 to corresponding hex number (as string) + static function hexDigit(dec:Number):String { + if (dec < 0 || dec > 15) throw new Error("HttpRequest:hexDigit()= - out of range"); + var charCode0:Number =3D "0".charCodeAt(0); + var charCodeA:Number =3D "A".charCodeAt(0); + return dec < 10 ? String.fromCharCode(charCode0+dec) : String.fr= omCharCode(charCodeA+(dec-10)); + } + =20 + // convert hex character to number value + static function hexValue(hexChar:String):Number { + if (hexChar.length !=3D 1) { + throw new Error("HttpRequest:hexVal() - invalid char"); + } + hexChar =3D hexChar.toUpperCase(); + var hexValue:Number =3D "0123456789ABCDEF".indexOf(hexChar); + if (-1 =3D=3D hexValue) { + throw new Error("HttpRequest:hexValue() - invalid char"); + } + return hexValue; + } =20 + =20 + +} + + Added: flash_repubsub/classes/repubsub/HttpRequest.as =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- (empty file) +++ flash_repubsub/classes/repubsub/HttpRequest.as Mon Jan 17 07:43:43 20= 05 @@ -0,0 +1,203 @@ +=EF=BB=BF/* +Copyright (c) 2005, Planar Systems, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright=20 + notice, this list of conditions and the following disclaimer.=20 + + 2. Redistributions in binary form must reproduce the above=20 + copyright notice, this list of conditions and the following=20 + disclaimer in the documentation and/or other materials=20 + provided with the distribution.=20 + + 3. Neither the name of Planar Systems, Inc. nor the names of its=20 + contributors may be used to endorse or promote products derived=20 + from this software without specific prior written permission. =20 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLANAR SYSTEMS, +INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/* +* HttpRequest class +*=20 +* +*=20 +*/ + +import repubsub.IXmlSocketListener; +import repubsub.Hex; +import repubsub.UrlParse; + +class repubsub.HttpRequest { + =20 + private var _url:String; + private var _host:String; + private var _port:Number; + private var _path:String; + private var _method:String; + private var _body:String; + private var _headers:Object; + + function HttpRequest(url:String, method:String, body:String, headers= :Object) { + if (undefined =3D=3D url || null =3D=3D url) { + throw new Error("HttpRequest() - URL null or undefined"); + } + =20 + this._url =3D url; + this._path =3D ""; + this._host =3D null; + this._port =3D 0; + =20 + if (undefined !=3D method && null !=3D method) { + method =3D method.toUpperCase(); + if ("GET" =3D=3D method || "POST" =3D=3D method) { + _method =3D method + } else { + throw new Error("HttpRequest() - Unhandled Http verb: " = + method); + } + } else { + this._method =3D "GET"; // default + } + =20 + if (undefined !=3D headers && null !=3D headers) { + this._headers =3D headers; + } else { + this._headers =3D new Object(); + } + + if (undefined !=3D body && null !=3D body) { + this._body =3D body; + } else { + this._body =3D ""; + } =20 + =20 + this._parseUrl(); + } + =20 + function getUrl():String { + return this._url; + } + =20 + function getHost():String { + return this._host; + } + =20 + function getPort():Number { + return this._port; + } + =20 + function getPath():String { + return this._path; + } + =20 + function getMethod():String { + return _method; + } + =20 + function getBody():String { + return this._body; + } + =20 + function getHeaders():Object { + return this._headers; + } + + // format http request + function formatRequest():String { =20 + var method =3D this.getMethod(); + var url =3D this.getUrl(); + var host =3D this.getHost(); + var headers =3D this.getHeaders(); + var path =3D this.getPath(); + var body =3D this.getBody(); + + var request =3D ""; =20 + if ("POST" =3D=3D method) { + request +=3D "POST " + path + " HTTP/1.0\r\n"; + request +=3D "Host: " + host + "\r\n"; + request +=3D "Content-Length: " + body.length + "\r\n"; + // add headers + for (var prop in headers) { + request +=3D prop + ": " + headers[prop] + "\r\n"; + } + request +=3D "\r\n"; + request +=3D body; + } else if ("GET" =3D=3D method) { + request +=3D "GET " + path + " HTTP/1.0\r\n"; + request +=3D "Host: " + host + "\r\n"; + // add headers + for (var prop in headers) { + request +=3D prop + ": " + headers[prop] + "\r\n"; + } =20 + } else { + throw new Error("HttpRequest.formatRequest() - Unsupported m= ethod: " + method); + } + + return request; =20 + } =20 + =20 + // Default implementations of XmlSocketListener functions + function onData(data:String):Void { + } =20 + function onClose():Void { + } =20 + function onConnect(success:Boolean):Void { + } + + private function _parseUrl():Void { + var urlParts:Array; + =20 + try { + urlParts =3D UrlParse.parseUrl(this._url); + } catch (e:Error) { + throw new Error("HttpRequest._parseUrl() - Invalid URL: " + = this._url); + }=20 + =20 + this._host =3D urlParts[0] !=3D undefined ? urlParts[0] : ""; =20 + this._port =3D urlParts[1] !=3D undefined ? urlParts[1] : 80; + this._path =3D urlParts[2] !=3D undefined ? urlParts[2] : ""; + + delete urlParts; + } +=20 + // x-www-form-urlencoded string + static function formUrlEncode(str:String):String { + var len:Number =3D str.length; + var encodedStr:String =3D ""; + var char:String; + var charCode:Number; + for (var i=3D0; i<len; i++) { + char =3D str.charAt(i); + if (isSafe(char)) { + encodedStr +=3D char; + } else { + encodedStr +=3D "%" + Hex.charToHex(char); + } + } + return encodedStr; + } + + // return true if character doesn't need to be hex encoded =20 + static function isSafe(char:String):Boolean { + var safeChars:String =3D "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL= MNOPQRSTUVWXYZ0123456789-_.!~*\\()"; + return safeChars.indexOf(char) >=3D 0; + } =20 + +} + + Added: flash_repubsub/classes/repubsub/IClient.as =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- (empty file) +++ flash_repubsub/classes/repubsub/IClient.as Mon Jan 17 07:43:43 2005 @@ -0,0 +1,50 @@ +=EF=BB=BF/* +Copyright (c) 2005, Planar Systems, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright=20 + notice, this list of conditions and the following disclaimer.=20 + + 2. Redistributions in binary form must reproduce the above=20 + copyright notice, this list of conditions and the following=20 + disclaimer in the documentation and/or other materials=20 + provided with the distribution.=20 + + 3. Neither the name of Planar Systems, Inc. nor the names of its=20 + contributors may be used to endorse or promote products derived=20 + from this software without specific prior written permission. =20 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLANAR SYSTEMS, +INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/* +* IClient interface +*=20 +* +*/ + +interface repubsub.IClient { +=20 + function publish(topic:String, message, statusHandler):String; =20 + function subscribe(topic:String, msgCallback, options, statusHandler= ):String;=20 + function unsubscribe(kn_route_location:String, statusHandler):Void; + function disconnect():Void; + function connect():Void; + function getTunnelUrl():String; + function isConnected():Boolean +} Added: flash_repubsub/classes/repubsub/IMessageListener.as =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- (empty file) +++ flash_repubsub/classes/repubsub/IMessageListener.as Mon Jan 17 07:43:= 43 2005 @@ -0,0 +1,46 @@ +=EF=BB=BF/* +Copyright (c) 2005, Planar Systems, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright=20 + notice, this list of conditions and the following disclaimer.=20 + + 2. Redistributions in binary form must reproduce the above=20 + copyright notice, this list of conditions and the following=20 + disclaimer in the documentation and/or other materials=20 + provided with the distribution.=20 + + 3. Neither the name of Planar Systems, Inc. nor the names of its=20 + contributors may be used to endorse or promote products derived=20 + from this software without specific prior written permission. =20 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLANAR SYSTEMS, +INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/* +* IMessageListener interface +*=20 +*=20 +*/ + +interface repubsub.IMessageListener { + =20 + function _onMessage(message:Object):Void; + function _onRequestComplete(kn_status_from:String):Void; + =20 +} Added: flash_repubsub/classes/repubsub/ITransport.as =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- (empty file) +++ flash_repubsub/classes/repubsub/ITransport.as Mon Jan 17 07:43:43 200= 5 @@ -0,0 +1,47 @@ +=EF=BB=BF/* +Copyright (c) 2005, Planar Systems, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright=20 + notice, this list of conditions and the following disclaimer.=20 + + 2. Redistributions in binary form must reproduce the above=20 + copyright notice, this list of conditions and the following=20 + disclaimer in the documentation and/or other materials=20 + provided with the distribution.=20 + + 3. Neither the name of Planar Systems, Inc. nor the names of its=20 + contributors may be used to endorse or promote products derived=20 + from this software without specific prior written permission. =20 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLANAR SYSTEMS, +INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/* +* ITransport interface +*=20 +* +*/ + +interface repubsub.ITransport { +=20 + function startTunnel(message:Object):Void; =20 + function stopTunnel():Void;=20 + function sendMessage(message:Object):Void; + =20 +} Added: flash_repubsub/classes/repubsub/ITunnelListener.as =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=... [truncated message content] |
|
From: <rep...@mo...> - 2004-12-29 00:42:14
|
Author: mod-pubsub-developer Date: Tue Dec 28 08:17:03 2004 New Revision: 21 Added: INSTALL.txt Log: Adding new install instructions Added: INSTALL.txt ============================================================================== --- (empty file) +++ INSTALL.txt Tue Dec 28 08:17:03 2004 @@ -0,0 +1,33 @@ +1) Install Twisted by any means necessary. + +2) Untar the Repubsub distribution. + + tar -zxvf repubsub_0.2.6.tar.gz + +3) Go into repubsub/kn_apps/kn_lib, and edit prologue.js to reflect your +servername and the port you want to run on. The default is: + + http://localhost:8080 + +but this is not likely to be useful except for short tests. + +If you are running an Apache server and a Mod-pubsub server on two different machines within the same domain (e.g. www.example.com and mps.example.com), you will also need to add a line like this for JavaScript security: + + document.domain = "http://example.com"; + +4) Go into repubsub/twisted.pubsub, and do something like this: + + sudo python2.3 pubsub.py 8080 .. & + +5) Hit the test URL in a browser: + + http://localhost:8080/tests/server_test.html + +You should see two embedded iframes, one that says 200 Watching Topic and one +that says 200 OK. + +6) If you run an Apache server and a Mod-pubsub server in tandem, you probably want to do this in Apache httpd.conf: + + Redirect permanent /kn http://localhost:8080/kn + +This will allow you to address the pubsub server at /kn in your apps, instead of worrying which hostname and port it might be on. \ No newline at end of file |
|
From: <rep...@mo...> - 2004-12-09 00:57:53
|
Author: mod-pubsub-developer Date: Wed Dec 8 08:37:03 2004 New Revision: 20 Modified: docs/repubsub.xml kn_client/repubsub.js Log: changes to allow the repubsub docs to build with the supplied Jars Modified: docs/repubsub.xml ============================================================================== --- docs/repubsub.xml (original) +++ docs/repubsub.xml Wed Dec 8 08:37:03 2004 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8" ?> <!-- -$Id$ +$Revision$ Copyright (c) 2004 Alex Russell Licensed under the Academic Free License version 2.0 --> @@ -9,8 +9,8 @@ <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "docbook/dtd/docbookx.dtd" [ <!-- "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [ --> - <!ENTITY repubsub_contents SYSTEM "../kn_client/repubsub.js"> - <!ENTITY sigslot_contents SYSTEM "../kn_client/sigslot_core2.js"> + <!ENTITY repubsub_contents SYSTEM "file:./kn_client/repubsub.js"> + <!ENTITY sigslot_contents SYSTEM "file:./kn_client/sigslot_core2.js"> <!-- js obj entities --> <!ENTITY rps "<classname role='singleton'>repubsub</classname>"> @@ -19,6 +19,7 @@ <!-- <!ENTITY class "<classname role='singleton'>class</classname>"> --> <!-- other text replacement entities --> + <!ENTITY nw "nWidgets"> <!ENTITY js "JavaScript"> <!ENTITY mps "<literal>mod_pubsub</literal>"> <!ENTITY sigslot "Signals and Slots"> Modified: kn_client/repubsub.js ============================================================================== --- kn_client/repubsub.js (original) +++ kn_client/repubsub.js Wed Dec 8 08:37:03 2004 @@ -363,7 +363,7 @@ </fieldsynopsis> <para role="fieldinfo"> When &rps;.<varname>isInitialized</varname> is &false;, this &arr; - holds &arrs; of arguments to the <methodname>subscribe</methodname> + holds &arr;s of arguments to the <methodname>subscribe</methodname> method which are unrolled (and subscriptions are sent) once initialization is complete. </para> |
|
From: <rep...@mo...> - 2004-12-09 00:48:23
|
Author: mod-pubsub-developer Date: Wed Dec 8 08:27:51 2004 New Revision: 19 Modified: build.xml Log: yet another cosmetic change to test out the checkin mail system Modified: build.xml ============================================================================== --- build.xml (original) +++ build.xml Wed Dec 8 08:27:51 2004 @@ -15,7 +15,10 @@ jimi jar file (provided) --> -<!-- Copyright (c) 2004 Friendster Inc., Licensed under the Academic Free License version 2.0 or later --> +<!-- + Copyright (c) 2004 Friendster Inc., Licensed under the Academic Free + License version 2.0 or later +--> <project name="repubsub" default="help" basedir="."> <description>build me!</description> |
|
From: <rep...@mo...> - 2004-12-09 00:34:07
|
this is a test of mail sending from mod-pubsub.org |
|
From: <rep...@mo...> - 2004-12-09 00:13:31
|
Author: mod-pubsub-developer Date: Wed Dec 8 07:53:08 2004 New Revision: 18 Modified: build.xml Log: yet another test of mailing notification Modified: build.xml ============================================================================== --- build.xml (original) +++ build.xml Wed Dec 8 07:53:08 2004 @@ -15,8 +15,6 @@ jimi jar file (provided) --> -<!-- test block --> - <!-- Copyright (c) 2004 Friendster Inc., Licensed under the Academic Free License version 2.0 or later --> <project name="repubsub" default="help" basedir="."> |
|
From: <rep...@mo...> - 2004-12-09 00:09:55
|
Author: mod-pubsub-developer Date: Wed Dec 8 06:30:45 2004 New Revision: 17 Modified: build.xml Log: test for email notification Modified: build.xml ============================================================================== --- build.xml (original) +++ build.xml Wed Dec 8 06:30:45 2004 @@ -15,6 +15,8 @@ jimi jar file (provided) --> +<!-- test block --> + <!-- Copyright (c) 2004 Friendster Inc., Licensed under the Academic Free License version 2.0 or later --> <project name="repubsub" default="help" basedir="."> |
|
From: Alex R. <al...@do...> - 2004-12-08 22:23:11
|
=2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 check. 1, 2, 3. =2D --=20 Alex Russell al...@do... al...@ne... F687 1964 1EF6 453E 9BD0 5148 A15D 1D43 AB92 9A46 =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (Darwin) iD8DBQFBt38SoV0dQ6uSmkYRAnstAKCSh5P/39VmKd5dXgVSGWsTaTTLewCeMV3j yiy3SzWbuZra83kfutqDhT8=3D =3D4Eu9 =2D----END PGP SIGNATURE----- |