Receiver.onAttach( callback )

Use this method to pass a function to a receiver which should be called when a someone starts controlling your application. This happens when a user has entered the connection code of the receiver in the PlugPIN mobile app, on his smartphone.


Callback arguments

The callback you provide will be called with the following arguments

  • string screenName
    The screen name of the user who is now controlling your app


Code example

In the following example a developer is creating a multiplayer game. He has created two receivers, for two controllers to attach to. When the second controller attaches, he wants the screen name of the controller to be displayed. He has prepared the function 'setPlayerName' to do this for him.

var player2Receiver = PLUGPIN.createReceiver( 'Shoot m up - player 2' );

player2Receiver.onAttach( function( name )
    setPlayerName( 2, name );
} );


Contact us

Talk to us!
Tell us anything you want to and please add your contact information.

Our contact info
tel. +31 (0) 20 2170013

Groenhoedenveem 28
1019 BL Amsterdam
The Netherlands

News letter

Enter your e-mail address to stay informed on everything PlugPIN!