Advertisement
Guest User

Untitled

a guest
Apr 30th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 0.76 KB | None | 0 0
  1. package;
  2.  
  3. import flixel.FlxState;
  4. import io.colyseus.Client;
  5. import io.colyseus.Room;
  6.  
  7. class PlayState extends FlxState
  8. {
  9.     var client:Client;
  10.     var room:Room;
  11.  
  12.     override public function create():Void
  13.     {
  14.         super.create();
  15.  
  16.         trace("PlayState:create()");
  17.  
  18.         client = new Client("ws://0.0.0.0:2567");
  19.         client.onError = function (message){
  20.             trace("CLIENT ERROR: " + message);
  21.         }
  22.         room = client.join("my_room");
  23.  
  24.         client.onOpen = function() {
  25.             trace("CLIENT OPEN, id => " + client.id);
  26.         };
  27.  
  28.         client.onClose = function () {
  29.             trace("CLIENT CLOSE");
  30.         };
  31.  
  32.         room.onJoin = function() {
  33.             trace(client.id + " JOINED ROOM => " + room.name);
  34.         };
  35.     }
  36.  
  37.     override public function update(elapsed:Float):Void
  38.     {
  39.         super.update(elapsed);
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement