Navigation

    Colyseus
    • Login
    • Search
    • Recent
    • Tags
    • Users
    1. Home
    2. mdotedot
    3. Posts
    • Profile
    • More
      • Continue chat with mdotedot
      • Flag Profile
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups

    Posts made by mdotedot

    Colyseus and wss proxy (to a docker)

    Installing Local Certificate Authority for testing purposes.

    I wanted to create a proxy from wss to ws connection. But I didn't want to touch my production environment.

    So I created a local certificate authority on my local = private computer.

    This is how I did this (Oracle Enterprise Linux = CentOS = RedHat - based)

    (First start with a root login)

    • vi /etc/yum/repos.d/epel-yum-ol7.repo
    [ol7_epel]
    name=Oracle Linux $releasever EPEL ($basearch)
    baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/developer_EPEL/$basearch/
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
    gpgcheck=1
    enabled=1
    
    • yum repolist

    • yum -y install easy-rsa

    Connect non-root-user

    • useradd myrsa

    • passwd myrsa

    • su - myrsa

    (add user to sudoers)

    • mkdir ~/easy-rsa

    • ln -s /usr/share/easy-rsa/3/* ~/easy-rsa/

    • chmod 700 ~/easy-rsa

    • cd ~/easy-rsa
      *./easyrsa init-pki

    • vi vars

    set_var EASYRSA_REQ_COUNTRY    "NL"
    set_var EASYRSA_REQ_PROVINCE   "MyProv"
    set_var EASYRSA_REQ_CITY       "MyCity"
    set_var EASYRSA_REQ_ORG        "MyOrg"
    set_var EASYRSA_REQ_EMAIL      "admin@localhost"
    set_var EASYRSA_REQ_OU         "Community"
    set_var EASYRSA_ALGO           "ec"
    set_var EASYRSA_DIGEST         "sha512"
    
    • ./easyrsa build-ca nopass
    . . .
    Enter New CA Key Passphrase:
    Re-Enter New CA Key Passphrase:
    . . .
    Common Name (eg: your user, host, or server name) [Easy-RSA CA]:
    
    CA creation complete and you may now import and sign cert requests.
    Your new CA certificate file for publishing is at:
    ~/easy-rsa/pki/ca.crt
    
    • cat ~/easy-rsa/pki/ca.crt

    Other Server : WebServer (or the same system : in my case the same system )

    • vi /tmp/ca.crt
      pate data from the ca.crt you created earlier

    • sudo cp /tmp/ca.crt /etc/pki/ca-trust/source/anchors/

    • sudo update-ca-trust

    Make private key

    • openssl genrsa -out webserver.key

    Certificate SIGNING request : CSR

    • openssl req -new -key webserver.key -out webserver.req

    Verify:

    • openssl req -in webserver.req -noout -subject

    • cat webserver.req
      -----BEGIN CERTIFICATE REQUEST-----
      ....

    Transport this certificate to the ca-server

    • vi /tmp/webserver.req
      paste - webserver.req from other server
    • cd ~/easy-rsa
    • ./easyrsa import-req /tmp/webserver.req webserver
    • ./easyrsa sign-req server webserver
      Enter: Yes

    Certificate created at: .../webserver.crt

    • cat ~/easy-rsa/pki/issued/webserver.crt

    -----BEGIN CERTIFICATE-----

    Take this certifcate to the webserver

    • vi /tmp/webserver_ca.crt
      Paste certificate

    WebServer (root)

    • cp /tmp/webserver_ca.crt /etc/pki/tls/certs/webserver_ca.crt
    • cp webserver.key /etc/pki/tls/private/webserver.key
    • chmod 600 /etc/pki/tls/private/webserver.key
    • yum -y install httpd mod_ssl mod_dav_svn ssl proxy proxy_http proxy_html proxy_wstunne
    • vi /etc/httpd/conf.d/ssl.conf

    SSLCertificateFile /etc/pki/tls/certs/webserver_ca.crt
    SSLCertificateKeyFile /etc/pki/tls/private/webserver.key
    SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt

    service httpd restart

    Importing CA in Browser

    In order for the client to trust the server it should also trust the CA that made the key.

    Generate a key you can import in a browser:

    • cd /home/myrsa/easy-rsa
    • openssl pkcs12 -export -in pki/ca.crt -inkey pki/private/ca.key -out browser.pfx

    Browser / Client

    Client computer:
    c> pscp root@ca_server:/home/myrsa/easy-rsa/browser.pfx Downloads

    Add the name 'webserver' to your host-resolver:

    C> notepad c:\windows\system32\drivers\etc\hosts
    192.168.0.12 webserver

    Open browser

    • chrome://settings/security?search=certificat
      Go to certificate management and import the PFX into the Trusted ROOT CERTIFICATES

    You can now make a secure connection to the webserver:

    https://webserver

    Proxy Forward

    • vi /etc/httpd/conf.d/ssl.conf
      Add below in the file :

    To make sure that all non-browser traffic goes to specific port I open up the 8567 port instead of 443

      <VirtualHost *:8567>
        
        SSLEngine On
        SSLCertificateFile /etc/pki/tls/certs/webserver_ca.crt
        SSLCertificateKeyFile /etc/pki/tls/private/webserver.key
        SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt
    
         RewriteEngine On
    
        RewriteCond %{HTTP:Upgrade} =websocket [NC]
            # Port 3567 is where the docker is listening for
        RewriteRule ^/(.*)    ws://0.0.0.0:3567/$1 [P,L]
    
      </VirtualHost>
    

    My docker is started like this:

    • docker run --name=col -h col --dns=8.8.8.8 -p 3567:3567 -v /home/root:/home/extern/ -t -d oel /bin/bash

    Port forward trafic comming from 3567 is going inside the docker where colyseus is listening on 3567 as well.

    Firewall is completely open on my private server.
    This should never be done for global servers. But for global servers you really need a non-self-signed certificate.

    You now have a secure connection to the server and it will proxy the stream to the docker. Inside the docker (colyseus-code) nothing has to be altered!

    posted in Links & Resources •
    RE: Stencyl (HaXe) Extension

    While preparing for the LD47 I revisted an old (LD38) project and converted it into a Client-As-A-Server game.

    LD38_Recreate

    The left shows player control using the arrow keys and the right session you control the rock with the mouse.

    The Extension Demo Page where you can play yourself is:
    StencylColsyeusDemoPage

    posted in Showcase •
    RE: Stencyl (HaXe) Extension

    Since I want to join the Ludum Dare Jam 47 (2nd October) and make an on-line game we need to make resources public available.
    Therefore I have made the Stencyl Extension available as a public beta : Stencyl Colyseus Extension Page

    Last days I've worked on the documentation

    And I worked on implementing a turn based card game.

    alt physics

    Sending and receiving data is a breeze with Colyseus.

    It all depends on the game-logic and how to show the state of the game.

    I hope that the docker container that I provide to the Stencyl users will make running of the server easier for them.

    As mentioned before I have made the extension based on the work of serjek (haxe externs) on top of the Colyseus engine.

    The server has only three logic parts : Turn based and Locking mechanism and a check on active seat.
    All other logic has to run on the client.

    Of course most good server implementations need more logic on the server,
    but I still am not certain how to provide the stencyl users with a relative easy way to make server-side code.

    The best 'feel' you get is when you implement the Lock Room Type for your game. The room-data is kind of like a database server
    that allows only one player to modify the data.

    But, to be honest, most Stencyl users want to create physics based games. I provide examples how to run a client-as-a-server approach.
    That seems to work since all clients see the same 'server'-state. But it is never as fast as it could be with server-side-physics.

    I've attempted to create physics logic on the server based on the Box2D library.
    The problems arise when doing client side prediction and server lag compensation. I wasn't able to get that to work. The data on the
    clients 'jumped' all over the place. It works when you have minimal player interaction on the physics objects, but then the 'client-as-a-server' approach
    is way easier to implement.

    posted in Showcase •
    RE: Stencyl (HaXe) Extension

    Working towards a beta release of the Colyseus Stencyl Extension.

    I had already Lock, TurnBased and Raw room-types.

    Most of the progress has been made with the Client-As-A-Server concept.
    I know that the best way to handle multiplayer is on the server-side.
    But many of the Stencyl users are not comfortable writing the server-side logic.

    Therefore I attempted for a Client-Server-Relay kind of thing.
    The collision and logic is handled on the client side with one of the clients acting as the server.
    On that client the real physics objects are hidden and only the data that is send to all players is displayed.

    These are the things that are currently made with the Client-As-A-Server approach:

    alt pong

    Left Window is a Windows executable
    Right Window is a web-page

    alt physics

    I hope to do some more beta-testing with other Stencyl users to gain more information about this approach.

    posted in Showcase •
    RE: Raspberry PI and Colyseus ( and Haxe)

    From my setup:

    root@raspberrypi:~/colyseus-hxjs-examples# haxe -version

    4.0.0-rc.2
    

    root@raspberrypi:~/colyseus-hxjs-examples# haxelib list

    colyseus-hxjs: [git]
    hxnodejs: [10.0.0]
    tink_core: [1.23.0]
    tink_lang: [0.6.2]
    tink_macro: [0.17.7]
    tink_priority: [0.1.4]
    tink_syntaxhub: [0.4.3]
    

    root@raspberrypi:~/colyseus-hxjs-examples# cat src/colyseus/server/schema/Schema.hx | grep MapSchemaUtil

    class MapSchemaUtil {
    

    Your tink_core is different than mine. Don't know if that is the only thing that is different?

    posted in Showcase •
    RE: Raspberry PI and Colyseus ( and Haxe)

    Not sure if you are mixing libraries. The stuff that I rely on is from serjek and was based on 0.10 release. There is now a 0.11 release so I hope you didn't load any of that?!

    posted in Showcase •
    RE: Raspberry PI and Colyseus ( and Haxe)

    Unfortunately I can't confirm now on my system, but you might try to move the contents of that hxjs directory to the [git] (or copy)
    So that /usr/lib/haxe/lib/colyseus/-hxjs/git has the src, haxelib.json, README.md and extraParams.hxml

    And then try again haxe server.hxml

    posted in Showcase •
    RE: Raspberry PI and Colyseus ( and Haxe)

    @closetmonkey
    Hmm that is a strange output of haxelib list on colyseus-hxjs

    From memory (I don't have access to it now since I'm at work) the colyseus-hxjs should only have one version behind it :
    colyseus-hxjs: [git]

    this was used to tell haxelib what version it should use:
    echo "git" > /usr/lib/haxe/lib/colyseus-hxjs/.current

    what is the contents of your .current file?!

    Maybe you just edit the /usr/lib/haxe/lib/ (or your own haxelib path) /colyseus-hxjs/.current and make sure it only has the git in it?!

    posted in Showcase •
    RE: Raspberry PI and Colyseus ( and Haxe)

    what does ' haxelib list ' show?

    I had to use a mix of steps ( haxelib install and copying files) before haxe server.hxml could find all types.

    posted in Showcase •
    Raspberry PI and Colyseus ( and Haxe)

    Raspberry PI & Colyseus ( & Haxe )

    Currently there are two basic ways to deploy my Colyseus server:

    • (Virtual) Host on premise or in the cloud
    • Docker container running on premise or in the cloud

    For my Console system I wanted to run Colyseus and Haxe on a Raspberry PI.
    You could use this as a low budget computer for testing purposes or use port forwarding on your router to host it to the rest of the world.

    The steps below could be used to create a nodejs server and you can avoid all the extra steps to get haxe working.

    For small multiplayer games or for turnbased/idle games this would be a cheap way to run a server from your home.

    The procedure for a Virtual Raspberry PI (VirtualBox/XenServer) is much simpler because the x86 can work with lix.
    Unfortunately I haven't managed to get lix working on the real (ARM) hardware. It defaults to an incompatible distribution.

    If anyone knows how to tell lix to get the ARM based executables that would make this procedure a lot easier

    Installation Steps:

    Components:

    • Raspberry PI B v1.2 : 1GB Ram, 4x 1.2 Ghz Cores
    • Stretch image 2018-11-13-raspbian-stretch from https://distrowatch.com/?newsid=10376
    • Use Win32DiskImage/RUFUS to write the image to a 16GB SD card. The haxe software that we will install brings it to 14 GB!

    Boot raspbian (default it will use DHCP to get an IP address)
    Open terminal : sudo su - (Become root)

    vi /etc/ssh/sshd_config 
    

    change permitRootLogin to : permitRootLogin yes

    change password for root : passwd root

    Allow putty / ssh into the PI

    systemctl enable ssh
    systemctl start ssh
    

    Update/upgrade

    apt update
    apt upgrade
    
    rpi-update
    

    restart the PI

    Get the IP address:

    ip addr show      
    

    login as root to do the (remote) installation

    cd /root
    #nodejs
    #curl -sL https://deb.nodesource.com/setup_8.x | bash - # used for x86 version of pi
    curl -sL https://deb.nodesource.com/setup_10.x | bash -
    apt-get -y install nodejs
    node -v
    npm -v
    

    You can install the node stuff for Colyseus and run the NodeJS version.

    But I wanted HaXe so these are the steps we need to make before we can compile the neko and haxe versions

    If you are on x86 versions you can use the serjek example github files and use ' lix download' to download the binaries.

    But for now I had to compile the ARM versions:

    # ---------------
    # Neko / HaXe / Colyseus-hxjs 
    # ---------------
    # base software packages  
    # execute line after line (do not copy-paste-run!)
    mkdir -p ~/Development/haxe/{dev,lib,source}
    cd ~/Development/haxe/source
    apt-get install -y build-essential git cmake
    apt-get install -y libgc-dev libgc1c2 libpcre3 libpcre3-dev
    apt-get install -y apache2-dev libmariadb-client-lgpl-dev-compat    
    apt-get install -y libsqlite3-0 sqlite3 libsqlite3-dev    
    apt-get install -y libgtk2.0-dev
    apt-get install -y libudev-dev
    apt-get install -y libasound2-dev
    apt-get install -y zlib1g libmariadb2 libmbedtls-dev libmbedcrypto0 libmbedtls10 libmbedx509-0
    apt-get install -y m4 ocaml ocaml-native-compilers libpcre-ocaml-dev libextlib-ocaml libextlib-ocaml-dev opam
    apt-get install -y openssl libssl-dev 
    

    Interactive setup/install:

    opam init
    ocamlc -config|grep arch # should be arm 
    #interactive:
    opam install conf-m4 ocamlfind sedlex depext xml-light extlib rope ptmap sha
    

    We are ready to install neko and haxe:

    export HAXE_VERSION='4.0.0-rc.2'
    export NEKO_VERSION='v2-2-0'
    
    cd /root
    eval `opam config env`
    #
    #Neko install
    #
    git clone --recursive  https://github.com/HaxeFoundation/neko -b $NEKO_VERSION
    cd neko 
    mkdir build
    cd build
    cmake -DRELOCATABLE=OFF ..
    make
    make install
    

    Test the neko by typing in neko and check that the version is 2.2.0

      
    #
    # haxe install
    #  
    eval `opam config env`
    cd ~/Development/haxe/source
    git clone --recursive https://github.com/HaxeFoundation/haxe -b $HAXE_VERSION
    cd haxe
    make
    make tools
    make install  
      
    

    haxe --version # should give you 4.0.0-rc.2

    Setting up the libraries to run the examples

    haxelib setup
    # default /usr/lib/haxe/lib
     
    # yarn
    npm i yarn -g
    yarn
    
    # Get Haxe Libraries
    cd /usr/lib/haxe/lib
    # haxelib git colyseus-hxjs https://github.com/serjek/colyseus-hxjs
    git clone https://github.com/serjek/colyseus-hxjs
    
    

    Unfortunately I'm not good enough with haxe and lix libraries and I needed a hack to get
    the colyseus-hxjs library to work with the compiled ARM versions.

    Apparently the required versions are different from the default haxelib installations.
    Since I know that the lix steps worked for x86 installations I used a mix of installation steps to get it to work.

    npm i lix -g
    
    cd /root
    git clone https://github.com/serjek/colyseus-hxjs-examples.git
    cd /root/colyseus-hxjs-examples
    # We are still going to download the latest haxe_libraries but we are using the haxelib versions later
    lix download
    haxelib install tink_core
    haxelib install tink_lang
    haxelib install hxnodejs
    
    # Now we need to copy some of the /root/haxe/haxe_libraries to the haxelib libraries:
    mkdir -p /usr/lib/haxe/lib/colyseus-hxjs/git/src
    cp -r /root/haxe/haxe_libraries/colyseus-hxjs/0.0.0/github/*6  /usr/lib/haxe/lib/colyseus-hxjs/git
    mv /usr/lib/haxe/lib/colyseus-hxjs/git/*6/src  /usr/lib/haxe/lib/colyseus-hxjs/git/src
    cp -r /root/haxe/haxe_libraries/hxnodejs/6.9.1/haxelib/src/ /usr/lib/haxe/lib/hxnodejs/10,0,0
    
    echo "git" > /usr/lib/haxe/lib/colyseus-hxjs/.current
    
    haxelib list
    

    With these hacked haxe libraries we can then run the steps to create node versions from the haxe code:

    haxe server.hxml
    
    cd bin/server
    yarn
    node index.js
    
    

    You can now tell your client to connect to the examples.

    My pre-alpha Stencyl Extension Server was used by myself to run the TicTacToe game.

    For that I installed a webserver on the PI and uploaded both the server code and the client code to the Raspberry PI:

    #
    # Apache WebServer
    #
    apt-get install apache2
    systemctl enable apache2
    

    Copy your project to /var/www/html
    and
    Visit your game with a browser to the following URL: http://raspberry_pi_ip_address

    You can use win32diskimage to create an image from the SD card as a back-up.

    posted in Showcase •
    RE: Stencyl (HaXe) Extension

    The Lock System is still a good challenge. After two code-refactors I have put it on hold for now.

    Last week I've worked on an actual TurnBased system game (TicTacToe)

    [running html5 and windows publication next to eachother]
    http://photoquesting.com/Colyseus/ColyseusTicTacToe.gif

    (published for HTML5, Windows and Android; should work on the others)

    During development I started to rethink my approach of a single extension versus multiple extensions.
    I believe that a Stencyl user wants to create a specific type of game and install / enable the extension that is used for that type of game.
    This make the palette a lot cleaner. (Unfortunately Stencyl Extension Developers don't have the means to create sub-palettes or tabs)

    TODO for TurnBased System :

    • set timeout value; when a player needs to react before certain time (auto-logout)

    TODO for general :

    • make roomtype specific extensions (raw, turn, physics, lock/logic) that have still the general purpose blocks (init, join, create, leave room, etc..)

    TODO for games:

    • Make another turnbased game (Poker?)

    Also, I need to figure out the Lock/Logic room type eventually...

    posted in Showcase •
    RE: Room details

    This is how I do it (in HaXe)

    Client Side : Joining/Create a room with options where I add the variable RoomName

    	var theOptions:Map<String, Dynamic>=new Map<String,Dynamic>();
    	theOptions.set("RoomName", ""+RoomName);
    

    Client Side (getAvailableRooms) this will give you a list off all roomnames created

    	client.getAvailableRooms(room_type, function(rooms, ?err) {
    		if (err != null) trace("ERROR! " + err);
    		for (room in rooms) {
    trace(" room ID: "+room.roomId+" room Name: "+room.metadata.RoomName);
    		}
    		
    	}
    
    

    Server Side :

    override function onInit (options:Dynamic) {
    trace("Lobby created!", options);
            setMetadata(options); // is from Room documentation: https://docs.colyseus.io/server/room/#setmetadata-metadata
    }
    
    
    posted in Questions & Help •
    RE: Stencyl (HaXe) Extension

    With the core functionality done, the next room was much faster to create.

    RoomType: Turn Based System

    Proof Of Concept (sorry for the wall of text which is used to debug stuff)
    http://photoquesting.com/Colyseus/ColyseusTurnBasedRoom.gif

    This leads to these new blocks in Stencyl:
    http://photoquesting.com/Colyseus/ColyseusTurnBlocks.png

    When a player leaves the system will pick the next seat as the active seat. If there is no seat after the leaving player the first available seat is selected.

    Also, the seat that becomes availabe is added to a stack for next players to join to. (Of course when the Stencyl Developer decides to allow join/rejoining of active game!)

    posted in Showcase •
    RE: Stencyl (HaXe) Extension

    The past days I've worked on the Colyseus v0.10 framework and the Haxe externs from Serjek. As well as creating a docker that will run the server and will be supplied to the Stencyl Users so they can run the server on their own.

    Since Endel has provided a haxe-ws fork ( https://github.com/colyseus/haxe-ws ) the system is really stable.

    I've started with the core room-types:

    • Lobby
    • Raw
    • Turn
    • Lock

    Lobby is where all players are signed in automatically. The playernames are stored and can be used in other rooms.

    Raw Room is for games that don't need server logic. Think of games that are split screen and don't interact with eachother.

    Turn Room is for turnbased games.

    Lock system is where the server has a lock on coordinates/areas/objects and you request a lock to alter the data. Think of RPGs, puzzle games

    In the future I want to have a Box2D Server collision interaction, but that will propably take a long time to figure out.

    Currently a proof-of-concept has been made for the raw-room type. For the others I need to create more Stencyl blocks like request/release lock and turn (seat/next turn)

    Here is the current Stencyl palette layout:

    http://photoquesting.com/Colyseus/ColyseusStencylExtension_v0.42.png

    http://photoquesting.com/Colyseus/ColyseusStencylExtension_RoomInfo.png

    I've used client.getAvailableRooms

    for (room in rooms) {
    	if(room.metadata.ApplicationID == ""+colyseus.ApplicationID){
    		roomIDs.push(""+room.roomId);
    		roomNames.set(""+room.roomId,""+room.metadata.RoomName);
    	}
    }
    

    I wonder if there can be a filter for things like this so that I don't get all the rooms and filter the applicationID out 'manually'
    At least it works, but I don't know if it slows down when there are a lot of games running on the server?
    Then again, I don't think that many stencyl-developers will run a server with different type of games.

    posted in Showcase •
    RE: Stencyl (HaXe) Extension

    The wikipedia linked in the sourcecode of Crypto.hx mentioned :
    "but reading the special file \Device\KsecDD does not work as in UNIX"

    So I tried another crypto number generator:

    haxelib install trandom
    

    Edit the project.xml to include this haxelib

    notepad \HaxeToolkit\haxe\lib\haxe-ws\git\src\haxe\net\Crypto.hx
    Change this:

    	 #if windows
    
    			var randomValue = trandom.TargetRandom.random();
    			var bytes = haxe.io.Bytes.alloc(length);
    		        bytes.setInt32(0, randomValue);
    			return bytes;
    
                        var input = sys.io.File.read("\\Device\\KsecDD");
    
                    #else
    
    

    This worked when I did a lime build & test for windows.

    When I tried to incorporate the trandom library into Stencyl it gave me problems. There is a define done that is going to add a build.xml file to the publication method and Stencyl does not handle that.

    I opted for another approach for the windows build from in Stencyl:

    		#if windows
    					return  haxe.io.Bytes.ofString(getRandomString(16));
    					// This will not work
                        var input = sys.io.File.read("\\Device\\KsecDD");
    
                    #else
    

    getRandomString:

    public static function getRandomString(length:Int, ?charactersToUse = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"):String
    	{
    		var str = "";
    		for (i in 0...length){
    			str += charactersToUse.charAt( Math.floor((Math.random() *  (Date.now().getTime() % (charactersToUse.length) ) )));
    		}
    		return str;
    	} //getRandomString
    

    It is not as strong as the crypto generator but at least it works.

    Confirmed v0.10 & Serjek Externs with Simple Stencyl Extension (Kind of like the NyanCat demo)

    • HTML5
    • Windows
    • Android
    • iOS Simulator
    • iOS on device
    • Macintosh OSX
    • (Oracle) Linux
    posted in Showcase •
    RE: Stencyl (HaXe) Extension

    @endel said in Stencyl (HaXe) Extension:

    https://github.com/colyseus/haxe-ws

    Endel you are a true Master!

    C:\HaxeToolkit\haxe\lib>haxelib git haxe-ws https://github.com/colyseus/haxe-ws.git
    Installing haxe-ws from https://github.com/colyseus/haxe-ws.git
    Library haxe-ws current version is now git
    
    C:\HaxeToolkit\haxe\lib>haxelib list
    actuate: [1.8.9]
    box2d: [1.2.3]
    haxe-ws: [git]
    haxelib: [3.3.0]
    hxcpp: 3.2.94 [4.0.8]
    layout: [1.2.1]
    lime-samples: [7.0.0]
    lime: 7.2.1 [7.5.0]
    openfl-samples: [8.7.0]
    openfl: 8.8.0 [8.9.1]
    

    Now to build / test it again:

    cd \HaxeToolkit\colyseus-hx\example\openfl
    lime build windows
    lime test windows
    

    Error:

    Can't find a secure source of random bytes. Reason: [file_open,\Device\KsecDD]
    

    Debugging leads me to this part

    trace("WebSocketGeneric.hx . initialize ... Before this.key 		");
            //this.key = Base64.encode(Crypto.getSecureRandomBytes(16)); // This generates the secure source of random bytes
    		this.key = Base64.encode(haxe.io.Bytes.ofString("ABCDEFGHIJKLMNOP"));
    trace("initialize key : "+this.key);
    

    After this ofString-"16-bytes" the error was gone and hand-shake was made!!!

    Windows and Android publication worked out of the box.

    I will test iOS/Mac later this week!

    posted in Showcase •
    RE: Stencyl (HaXe) Extension

    Haxe Client and Server on v0.10

    Using the externs by Serjek I was able to create a very Simple Colyseus Server with a StateHandler Room that handles string data. The data is send to the clients and everything works as it supposed to.

    But only for HTML5 !!!

    I again have lots of problems to get it to work on anything else than HTML5.

    Here are the (non-stencyl) HaxeToolkit steps that I made:

    set HAXE_PATH=c:\HaxeToolkit\haxe
    set NEKOPATH=c:\HaxeToolkit\neko
    set PATH=%HAXE_PATH%;%NEKOPATH%;%PATH%
    haxelib setup c:\HaxeToolkit\haxe\lib
    haxelib --global update haxelib
    

    haxelib is up to date
    haxelib install openfl
    8.9.1
    haxelib run openfl setup
    7.5.0
    haxelib run lime setup
    Up to Date

    Get GIT from :
    https://git-scm.com/download/win

    git clone https://github.com/colyseus/colyseus-hx.git
    cd \HaxeToolkit\colyseus-hx\example\openfl\Source
    notepad Main.hx
    

    Edit: the ws connection so that it points to the docker server
    Also Edit the this.client.join line on number 55:

            //this.room = this.client.join("state_handler", [], State);
    		this.room = this.client.join("state_handler", new Map<String,Dynamic>(), State);
    

    Build the project:

    cd \HaxeToolkit\colyseus-hx\example\openfl
    haxelib install haxe-ws
    haxelib set hxcpp 3.2.94
    

    (installing)

    lime build project.xml html5
    lime test html5
    

    It works like a charm with the Serjek externs in the Colyseus Docker .

    But Android and Windows give again connection problems:

    cd \HaxeToolkit\colyseus-hx\example\openfl
    haxelib set hxcpp 4.0.8
    lime build windows
    
    lime test windows
    

    The connection is attempted but not made:

     - src/lime/utils/AssetCache.cpp  [haxe,release]
    Link: ApplicationMain.exe
       Creating library ApplicationMain.lib and object ApplicationMain.exp
    Main.hx:48: CLIENT CLOSE
    Connection.hx:66: WebSocket connection has been closed, stopping the thread!
    Main.hx:29: ERROR! timeout
    

    (I've tried the alterations on the haxe-ws library that I made for the 0.9 but they didn't solved it now)

    I am very curious if anyone got a different target to run with haxe other than HTML5 ??!??

    posted in Showcase •
    RE: Stencyl (HaXe) Extension

    Subject: Colyseus HaXe Externs & Colyseus version 0.10

    Took a break from the Colyseus Extension, but I'm back.
    I was asked to create a MicroPhone HaXe extension for iOS and Android so that did take some time.

    Also, I wanted to wait a bit till the version 0.10 was done on both of the client and server side.

    Thanks to Serjek and Endel for their contributions, I was able to get a HaXe combination running with the Nyan Cat example.

    Server Side: Oracle Linux

    • Download : https://github.com/serjek/colyseus-hxjs
    • Download : https://github.com/serjek/colyseus-hxjs-examples
    • extract in /root/serjek directory
    • Install npm : curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -
    • yum install -y nodejs`
    • npm -version
      6.5.0-next.0
      HaXe
    • Download install-haxe.hs : https://gist.github.com/jgranick/8cc40e2e0f277146725f
    • sh install-haxe.sh
    • export LD_LIBRARY_PATH=/root/haxe/neko
    • haxelib setup
      /usr/lib/haxe/lib
    • cd /root/serjek/colyseus-hxjs-examples-master/
    • npm i lix -g
    • lix download
    • Upgraded haxe to 4.0.0 preview 4 from : https://haxe.org/download/file/4.0.0-preview.4/haxe-4.0.0-preview.4-linux64.tar.gz/
    • Updated the install-haxe.sh to reflect that .tar.gz
    • ran install-haxe.sh again
    • haxe -version
      4.0.0-preview.4+1e3e5e0
    • lix use haxe 4.0.0-rc.2
    • Make sure that you are in the serjek/colyseus-hxjs-examples-master directory
    • haxe server.hxml
    • cd bin/server
    • npm i yarn -g
    • yarn
    • node index.js
      src/MainServer.hx:39: -- listening on 0.0.0.0:2567... --

    New Session

    • export LD_LIBRARY_PATH=/root/haxe/neko
    • /usr/local/bin/haxe
    • lix use haxe 4.0.0-rc.2
    • haxe -version
      4.0.0-preview.4+1e3e5e0
    • cd /root/serjek/colyseus-hxjs-examples-master
    • haxe client.hxml
    • cd bin/client
    • yarn
    • node index.js

    Test will run.

    Now for the HaXe Client on Windows: https://github.com/colyseus/colyseus-hx

    • https://github.com/HaxeFoundation/haxe/releases/download/3.4.4/haxe-3.4.4-win64.exe
    • set HAXE_PATH=c:\HaxeToolkit\haxe
    • set NEKOPATH=c:\HaxeToolkit\neko
    • set PATH=%HAXE_PATH%;%NEKOPATH%;%PATH%
    • haxelib setup c:\HaxeToolkit\haxe\lib
    • haxelib --global update haxelib
      Current version is 3.3.0
    • haxelib install openfl
      8.9.0
    • haxelib run openfl setup
      7.3.0
    • haxelib run lime setup
      Up to Date
    • lime create HelloWorld
    • cd HelloWorld
    • lime test html5
    • extract the colyseus hx master to \haxetoolkit\colyseus-hx-master
    • cd \HaxeToolkit\colyseus-hx-master\example\openfl\Source
    • notepad Main.hx
      Edit: the ws connection so that it points to the Linux Server mentioned above.
    • cd \HaxeToolkit\colyseus-hx-master\example\openfl
    • haxelib install haxe-ws
    • haxelib set hxcpp 3.2.94
      (installing)
    • lime build project.xml html5
      Error:
    Source/Main.hx:55: characters 48-50 : Array<Unknown<0>> should be Null<Map<Strin
    g, Dynamic>>
    Source/Main.hx:55: characters 48-50 : Array<Unknown<0>> should be Map<String, Dy
    namic>
    Source/Main.hx:55: characters 48-50 : For optional function argument 'options'
    

    Edit : c:\HaxeToolkit\colyseus-hx-master\src\io\colyseus\Client.hx

    			// M.E. @:generic    public function join<T>(roomName: String, ?options: Map<String, Dynamic>, ?cls: Class<T>): Room<T> {
            //this.room = this.client.join("state_handler", [], State);
    		this.room = this.client.join("state_handler", new Map<String,Dynamic>(), State);
    

    Now the lime build project.xml html5 followed by lime test html5 work with the externs by Serjek.

    That leaves me the task of creating a new Stencyl Extension that utilizes the
    this.room.state.players.onAdd = function(player, key)
    methodology rather than the
    this.room.listen("players/:id", function(change) {
    methodology.

    posted in Showcase •
    RE: Haxe externs for server?

    Hey Serjek,

    Thank you for your detailed steps.
    These steps work perfectly together when both client and server are made with haXe.

    I'm a bit confused why the externs would not work with, for instance the html demo from colyseus-examples static/02-state-handler.html ...

    I need to experiment with pure haXe client to see if that can communicate with the haxe externs.

    Thanks for your work. It is appreciated!

    posted in General Discussion •
    RE: Haxe externs for server?

    When using the 0.10 client it complaints about :

       var room = client.join("state_handler");
    

    Not using new operator.

    The same client runs with the npm started 0.10 server just fine.

    When I don't start the haxe-extern-server and fire up the client it tells that it can't connect.

    So apparently in both 0.9 and 0.10 the client connect works, but the room fails.

    posted in General Discussion •