Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Deep in the code of BigBrother : I have a few questions...

Comments in 'Plugin Development' started by blocksandgold, Oct 1, 2014.

  1. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    Hi,
    I'm trying to establish a connexion between a HTML5 client and Pocketmine.
    To do that i've imaginated that the best way to do it is to code a new plugin inspired from BigBrother.

    HTML 5 <------ WebSockets -----> Plugin <---------> Pocketmine

    *The HTML5 client is setup.
    *The plugin is setup
    * I've successfully established a websocket connexion between my html5 client and my plugin

    Connect ---------> plugin
    Connected <------- plugin
    OpenSession ------> plugin --------> xxx PocketMine Core

    I'm stuck here :
    I lost the trace here in my plugin (this part is the same as Bigbrother)
    ProtocolInterface.php
    Code:
    }elseif($pid === ServerManager::PACKET_OPEN_SESSION){
    $id = Binary::readInt(substr($buffer, $offset, 4));
    $offset += 4;
    if(isset($this->sessionsPlayers[$id])){
    continue;
    }
    $len = ord($buffer{$offset++});
    $address = substr($buffer, $offset, $len);
    $offset += $len;
    $port = Binary::readShort(substr($buffer, $offset, 2), false);
    $identifier = "$id:$address:$port";
    $player = new DesktopPlayer($this, $identifier, $address, $port);
    $this->sessions->attach($player, $id);
    $this->sessionsPlayers[$id] = $player;
    $this->plugin->getServer()->addPlayer($identifier, $player);
    
    $identifier contains "id:<ipofmyclientwebsocket>:<portofmyclientwebsocket>"
    all is ok.
    But, nothing happens after addPlayer.
    The server doesn't seem to send any packet to the client or to trigger any event.
    Is the client is supposed to do anything ? What should the server do ?

    Thx in advance,
    iJoshuaHD, Lambo, Falk and 1 other person like this.
  2. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    at least i succeded to establish the connexion and send a packet to the html5 client... :)

    https://twitter.com/BlocksAndGold/status/518772926422986753

    Next step,

    - Spawn the player to a flat world, exchange positions and move around.

    - After that i'll try to load a chuck, but i'm not sure if it's really what I want. I don't know if my little html5 application will be able to render thousands of cubes...
    Jon likes this.
  3. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Interesting, so your HTML app uses TCP to connect to the plugin?
  4. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    WebSockets.
    Browser only allow this type of sockets. It's a layer over TCP.
    At the PocketMine side, I use a small lib to frame and deframe the TCP packets : TCP => Websockets
    jython234 likes this.
  5. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    Chat is working :)
    It was harder than i though ;-) I've lost a lot of time because i haven't got any response to my chat packets because my player was dead at server side oO
    So i added a repawn packet and all has began to work:)

    https://twitter.com/BlocksAndGold/status/520611834895036417

    [​IMG]

    Tomorrow (or before the end of the week, I'll add moving. (On a fake flat 16x16 world)
    Last edited: Oct 11, 2014
    JoshV, Falk and iJoshuaHD like this.
  6. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    371
    Plugins:
    3
    Minecraft User:
    Dutok
    Wow. This is really cool. Great job!
    iJoshuaHD likes this.
  7. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    JoshV, Falk and Jon like this.
  8. Dinokiller
    Offline

    Dinokiller Notable Member

    Joined:
    Sep 22, 2013
    Posts:
    376
    Minecraft User:
    Dinokiller_
  9. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,167
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
  10. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    This looks absolutely amazing. Do you plan on sharing the product?
    MegaSamNinja, Dutok and iJoshuaHD like this.
  11. DovahDoVolom
    Offline

    DovahDoVolom Active Member

    Joined:
    Nov 29, 2013
    Posts:
    76
    Minecraft User:
    DovahDoVolom
    So are you trying to make a client for pocketmine that runs in the browser?
  12. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    371
    Plugins:
    3
    Minecraft User:
    Dutok
    Yep.
    PEMapModder likes this.
  13. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    This is amazing!
  14. CrossfireServer
    Offline

    CrossfireServer New Member

    Joined:
    Oct 3, 2014
    Posts:
    15
    Minecraft User:
    crossfire123
    Great lordblock I miss Blocks And Gold I wish I can get unban please :'(

Share This Page

Advertisement