Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
arjuna
Posts: 48
Registered: ‎04-07-2011
My Device: 9550

Problem in Join a Public Game using bbm sdk

[ Edited ]

 

When Someone Hosted the public connection to a game,

 

How do i get the PIN and PPID of that host for Joining a Public Game .

 

Can any one tell me and send me a Sample Code.

 

Send me the replies as early as possible.

 

Thanks in advance.

arjuna
Developer
VivekAgar
Posts: 79
Registered: ‎09-22-2010
My Device: 9700

Re: Problem in Join a Public Game using bbm sdk

Download the BBMSDK and see the sample App TicTacToe App, in this u fill Found these Two Methods

    public void hostPublicGame() {
        // prompt user to make the channel public
        _bbm.hostPublicGame();
        // retrieve PIN and PPID and convert it to hexadecimal
        String pin = toHex32(DeviceInfo.getDeviceId());
        String ppid = _bbm.getPPID();
        if (!pin.equals(toHex32(fromHex32(pin)))) throw new RuntimeException("Bad conversion");
        // display public channel information
        addMessage("[Others can join this public game using the following]\n" +
                   "      PIN = " + pin + "\n      PPID = " + ppid +
                   "\n  [This has been copied to clipboard]");
        // copy to clipboard
        Clipboard.getClipboard().put(pin + " " + ppid);
    }
   
    public void joinPublicGame() {
//        String answer = TextDialog.ask("Joining a Public Game", "Enter PIN and PPID, separated by a space: ", "");
        String answer = TextDialog.ask("Enter PIN and PPID, separated by a space: ", "", null);
        if (answer == null) return;  // user canceled
        int p = answer.indexOf(' ');
        if (p == 8) {
            int pin = fromHex32(answer.substring(0, p));
            String ppid = answer.substring(p+1);
            if (pin > 0) {
                _bbm.joinPublicGame(pin, ppid);
                return;
            }
        }
        Dialog.inform("Invalid PIN/PPID");
    }

 These is sample code.

u can call these methods for Hosting or Joining A public Game Session.

 

 

 

--------------------------------------------------------------------------------------------------------------------------------


Use Search. "Accept Solution" If the problem is resolved.