Skip to content

Commit

Permalink
change addAuth to authorizer for Channel
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie turner committed Aug 14, 2012
1 parent 14c3b1a commit 453b825
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion flux/Channel.hx
Expand Up @@ -58,7 +58,7 @@ interface ChannelServer
implements Startable<SessionMgr,String,ChannelServer>,
implements ObservableDelegate<ChannelEvent> {

function addChannelAuth(cb:String->Chan<Dynamic>->(Either<String,String>->Void)->Void):ChannelServer;
function authorizer(cb:String->Chan<Dynamic>->(Either<String,String>->Void)->Void):ChannelServer;
function channel<T>(chanID:String):Outcome<String,Chan<T>>;
function direct<T>(sessID:String):Outcome<String,Chan<T>>;
}
Expand Down
30 changes: 22 additions & 8 deletions flux/channel/Flow.hx
@@ -1,4 +1,10 @@


/*
Flow is the internal implementation of Channels, the Channels top level module
provides a higher level interface to these facilities
*/

package flux.channel;

using flux.Core;
Expand Down Expand Up @@ -37,7 +43,9 @@ enum ConduitEvent {
ConduitNoConnection(sessID:String);
}


/*
A Conduit is the network transport for packets, and manages all current connections.
*/
interface Conduit
#if nodejs
implements Startable<Dynamic,String,Conduit>,
Expand All @@ -49,15 +57,16 @@ implements ObservableDelegate<ConduitEvent> {
// a sink to whom incoming packets are sent
function addSink(s:Sink):Void;

// send a packet out over the conduit
// send a packet out over the conduit to a given session
function outgoing(sessID:String,pkt:Dynamic,chanID:String,meta:Dynamic):Void;

function authorize(pipeID:String):Future<Either<String,String>>;
function leave(pipeID:String):Future<Either<String,String>>;
#if nodejs

#if nodejs
function subscriptions(sessID:String):Hash<Void->Void>;
function session():SessionMgr;
#end
#end

}

Expand All @@ -66,24 +75,29 @@ enum SinkEvent {
ConnectionClose(sessID:String);
}

/*
Channels are created from sinks, and Sinks hold collections of channels.
*/
interface Sink
implements Startable<Conduit,String,Sink>,
implements Stoppable<Dynamic,Dynamic,Dynamic>,
implements ObservableDelegate<SinkEvent> {

/* create a public channel */
function chan<T>(chanID:String):Chan<T>;
/* create a private channel */
function direct<T>(sessID:String):Chan<T>;
function chanFromId(chanID:String):Option<Chan<Dynamic>>;
/* subscription and authorisation */
function authorize<T>(chan:Chan<T>):Outcome<String,Chan<T>>;
function removeChan<T>(p:Chan<T>):Void;

function chanFromId(chanID:String):Option<Chan<Dynamic>>;
/* incoming message from conduit */
function incoming(chan:Chan<Dynamic>,pkt:Pkt<Dynamic>):Void;

#if nodejs
function subscribe(sessID:String,chan:Chan<Dynamic>,cb:Either<String,String>->Void):Void;
function unsubscribe(sessID:String,chan:Chan<Dynamic>,cb:Either<String,String>->Void):Void;
#end
#end
}

class Flow {
Expand Down
2 changes: 1 addition & 1 deletion flux/channel/TChannelServer.hx
Expand Up @@ -67,7 +67,7 @@ implements ChannelServer {
}

public function
addChannelAuth(cb:String->Chan<Dynamic>->(Either<String,String>->Void)->Void):ChannelServer {
authorizer(cb:String->Chan<Dynamic>->(Either<String,String>->Void)->Void):ChannelServer {
_channelAuth = cb;
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion usage/bitcoin/eproject.cfg
Expand Up @@ -21,7 +21,7 @@
("../../cloudshift/Bitcoin.hx" 171 205)
("/home/blackdog/Projects/hx-node/js/Node.hx" 93 98)
("../../cloudshift/Http.hx" 62 73)
("../../cloudshift/Core.hx" 132 133)
("../../cloudshift/Core.hx" 1 1)
("/home/blackdog/.bitcoin/bitcoin.conf" 48 60)
("Makefile" 1 6)))

Expand Down
2 changes: 1 addition & 1 deletion usage/chat/ChatServer.hx
Expand Up @@ -21,7 +21,7 @@ class ChatServer {
.outcome(function(sess:SessionMgr) {
sess.authorizer(sessAuth);
Channel.server()
.addChannelAuth(channelAuth)
.authorizer(channelAuth)
.start(sess).outcome(startRooms);
});
});
Expand Down
3 changes: 2 additions & 1 deletion usage/chat/build.hxml
Expand Up @@ -23,7 +23,8 @@
-js www/client.js
-debug
# just add some test
--macro flux.core.JSGenerator.use()
#--macro flux.core.JSGenerator.use()
-main ChatClient
-cmd tweakasync www/client.js
-cmd echo "chat client built"

0 comments on commit 453b825

Please sign in to comment.