Giter Club home page Giter Club logo

colyseus-hxjs's Introduction

colyseus-hxjs

Haxe externs for colyseus server and client to compile into js/nodejs/react/react-native projects.

Note that since ES6 code is required you should use haxe no earlier than 4.0.0-rc.3

Examples

Enabling Express and Monitor

Have @colyseus/monitor installed along with colyseus and declare externs, like so (you can omit auth part of course):

@:jsRequire('express')
extern class Express {
  @:selfCall static function create():Express;
  function use(?path:String, ?optional:Dynamic, what:Dynamic):Void;
}

@:jsRequire('express-basic-auth')
extern class ExpressAuth {
  @:selfCall static function create(config:ExpressAuthConfig):ExpressAuth;
}

typedef ExpressAuthConfig = {
  final users:Dynamic;
  final challenge:Bool;
}

@:jsRequire('@colyseus/monitor','monitor')
extern class Monitor {
  @:selfCall static function create():Monitor;
}

Use externs with server init:

public function new() {
  var app:Express = Express.create();
  var server:Server = new Server({
    server: Http.createServer(cast app),
    express: app
  });

  app.use(
    '/colyseus', 
    ExpressAuth.create({
      users: {
        "admin": "admin"
      },
      challenge: true
    }),
    Monitor.create()
  );
  server.listen(2567);
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.