Permalink
Browse files

Merge pull request #11 from clemos/master

Mainly MongoDB + Socket.io adds / fixes...
  • Loading branch information...
2 parents 394f465 + 952d621 commit 086bf77db06ac7024af3ae8d1c3b2e764e211cf0 @clemos clemos committed May 20, 2013
Showing with 64 additions and 3 deletions.
  1. +19 −0 js/node/Cookie.hx
  2. +12 −3 js/node/MongoDb.hx
  3. +33 −0 js/node/SocketIo.hx
View
@@ -0,0 +1,19 @@
+package js.node;
+
+extern class Cookie {
+
+ public function serialize( obj : Dynamic , ?options : {
+ ?path : String,
+ ?expires : Date,
+ ?maxAge : Int,
+ ?domain : String,
+ ?secure : Bool,
+ ?httpOnly : Bool
+ } ) : String;
+
+ public function parse( raw : String ) : Dynamic;
+
+ public static inline function require() : Cookie return untyped __js__("require('cookie')")
+
+
+}
View
@@ -104,13 +104,13 @@ class Db {
/**
Create an index on a collection
**/
- @:overload(function (collectionName : String, fieldOrSpec : Dynamic, callBack : Error -> String -> Void) {})
+ @:overload(function (collectionName : String, fieldOrSpec : Dynamic, callBack : Error -> String -> Void) : Void {})
public function createIndex (collectionName : String, fieldOrSpec : Dynamic, unique : Bool, callBack : Error -> String -> Void) : Void;
/**
Ensure index, create an index if it does not exist
**/
- @:overload(function (collectionName : String, fieldOrSpec : Dynamic, callBack : Error -> String -> Void) {})
+ @:overload(function (collectionName : String, fieldOrSpec : Dynamic, callBack : Error -> String -> Void) : Void {})
public function ensureIndex (collectionName : String, fieldOrSpec : Dynamic, unique : Bool, callBack : Error -> String -> Void) : Void;
/**
@@ -126,7 +126,7 @@ class Db {
/**
Index Information
**/
- @:overload(function (callBack : Error -> Dynamic -> Void) {})
+ @:overload(function (callBack : Error -> Dynamic -> Void) : Void {})
public function indexInformation(collectionName : String, callBack : Error -> Dynamic -> Void) : Void;
/**
@@ -168,3 +168,12 @@ class Db {
public function setMaxListeners(m:Int):Void;
public function emit(event:String,?arg1:Dynamic,?arg2:Dynamic,?arg3:Dynamic):Void;
}
+
+@:native("ObjectID")
+extern
+class ObjectID {
+ public function new( s : String ) : Void;
+ private static function __init__() : Void untyped {
+ ObjectID = Node.require('mongodb').ObjectID;
+ }
+}
View
@@ -9,11 +9,27 @@ typedef SocketIo = {
function listen(?server : Dynamic, ?options : Dynamic, ?fn : Dynamic) : SocketIoManager;
}
+typedef SocketAuth = {
+ headers : Dynamic,
+ time : String,
+ address : {
+ address : String ,
+ port : Int
+ },
+ xdomain : Bool,
+ secure : Bool,
+ issued : Int,
+ url : String,
+ query : Dynamic
+}
+
typedef NodeListener = Dynamic -> Void;
extern
class SocketNamespace {
+ public var id : String;
+
// public static function SocketNamespace (socket : Dynamic, name : String) : Void;
public function send(data : Dynamic, fn : Dynamic) : SocketNamespace;
public function disconnect () : SocketNamespace;
@@ -29,10 +45,27 @@ class SocketNamespace {
@:overload(function(name : String) : SocketNamespace{ } )
public function emit(event:String,?arg1:Dynamic,?arg2:Dynamic,?arg3:Dynamic):Void;
+
+ public function join(room:String):Void;
+ public function leave(room:String):Void;
+
+ /*@:native("in")*/
+ public inline function in_(room:String):SocketNamespace return untyped this["in"](room)
+
+
+ public function clients(room:String):Array<SocketNamespace>;
+
+ public function set<T>( key : String , value : T , ?cb : Void -> Void ) : Void;
+ public function get<T>( key : String , cb : Null<String> -> T -> Void ) : Void;
+
+ public function socket( id : String ) : SocketNamespace;
+
}
typedef SocketIoManager = {
+ var sockets(default,null) : SocketNamespace;
+
var store(default, null) : Dynamic;
var log(default, null) : Dynamic;
@:native("static") var static_(default, null) : Dynamic;

0 comments on commit 086bf77

Please sign in to comment.