Package jNab.core.protocol

Examples of jNab.core.protocol.Packet


  {
      return;
  }

  // Playing recorded sound
  Packet p = new Packet();
  MessageBlock mb = new MessageBlock(600);
  mb.addPlayLocalSoundCommand("echo" + this.bunny.getSerialNumber() + ".wav");
  mb.addWaitPreviousEndCommand();
  p.addBlock(mb);
  p.addBlock(new PingIntervalBlock(1));
  this.bunny.addPacket(p);
    }
View Full Code Here


  try
  {
      MessageBlock mb = new MessageBlock(600);
      mb.addPlayLocalSoundCommand("message" + receiver + ".wav");
      mb.addWaitPreviousEndCommand();
      Packet p = new Packet();
      p.addBlock(mb);
      p.addBlock(new PingIntervalBlock(1));

      this.bunny.getBurrow().getBunny(receiver).addPacket(p);
  }
  catch (NoSuchBunnyException e)
  {
View Full Code Here

     * @see jNab.core.events.PingEventListener#onPing()
     */
    public void onPing()
    {
  // Preparing a new packet
  Packet p = new Packet();
 
  // Asking the bunny to ping 20s later (i.e. when the choreography has finished playing)
  p.addBlock(new PingIntervalBlock(20));
  MessageBlock mb = new MessageBlock(12345);
 
  // Playing the choreography associated to current level.
  mb.addPlayChoreographyFromLibraryCommand(this.getChoreography());
  mb.addWaitPreviousEndCommand();
  p.addBlock(mb);
  this.bunny.addPacket(p);
 
  // Switching level if needed
  if (System.currentTimeMillis() - this.lastSwitchingTime > 60000)
  {
View Full Code Here

     */
    public void onEndOfMessage()
    {
  // When choreography has finished playing, bunny notifies a end-of-message
  // Then it is asked to ping immediately
  Packet p = new Packet();
  p.addBlock(new PingIntervalBlock(1));
  this.bunny.addPacket(p);
    }
View Full Code Here

    {
  // If some click occurs while the choreography is playing, it is handled as a single-click event
  // A choreography is sent to raise both ears and bunny is asked to ping immediately after (to be able to send
  // packets generated by single-click event handling)
  this.bunny.handleEvent(Bunny.SINGLE_CLICK_EVENT, null);
  Packet p = new Packet();
  p.addBlock(new PingIntervalBlock(1));
  MessageBlock mb = new MessageBlock(12345);
  mb.addPlayChoreographyFromLibraryCommand("raisedEars");
  p.addBlock(mb);
  this.bunny.forcePacket(p);
    }
View Full Code Here

     *
     * @see jNab.core.events.ClickEventListener#onSingleClick()
     */
    public void onSingleClick()
    {
  Packet p = new Packet();

  // Generating a random number between 1 and 6
  Random rd = new Random();
  int n = rd.nextInt(6) + 1;

  // Playing the associated sound files
  MessageBlock mb = new MessageBlock(333);
  mb.addPlayLocalSoundCommand("files/sounds/dice/get.mp3");
  mb.addWaitPreviousEndCommand();
  mb.addPlayLocalSoundCommand("files/sounds/dice/" + n + ".mp3");
  mb.addWaitPreviousEndCommand();
  p.addBlock(mb);
  p.addBlock(new PingIntervalBlock(1));
  this.bunny.addPacket(p);
    }
View Full Code Here

  // Generating two random numbers between 1 and 6
  Random rd = new Random();
  int n1 = rd.nextInt(6) + 1;
  int n2 = rd.nextInt(6) + 1;

  Packet p = new Packet();

  // Playing the associated sound on the bunny
  MessageBlock mb = new MessageBlock(333);
  mb.addPlaySoundCommand("broadcast/files/sounds/dice/get.mp3");
  mb.addWaitPreviousEndCommand();
  mb.addPlaySoundCommand("broadcast/files/sounds/dice/" + n1 + ".mp3");
  mb.addWaitPreviousEndCommand();
  mb.addPlaySoundCommand("broadcast/files/sounds/dice/" + n2 + ".mp3");
  mb.addWaitPreviousEndCommand();
  p.addBlock(mb);
  p.addBlock(new PingIntervalBlock(1));
  this.bunny.addPacket(p);
    }
View Full Code Here

TOP

Related Classes of jNab.core.protocol.Packet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.