private void pingClient(String toToken,String senderToken){
  Client senderClient;
  if (toToken.equals(SENDER_ID + "@" + GcmServer.GCM_HOST)) {
    senderClient=clientMap.get(toToken);
    toToken=senderToken;
  }
 else {
    senderClient=clientMap.get(senderToken);
  }
  JsonObject jPing=new JsonObject();
  JsonObject jData=new JsonObject();
  jData.addProperty(ACTION_KEY,PING_CLIENT);
  jData.addProperty(SENDER_KEY,senderClient.registrationToken);
  JsonObject jNotification=new JsonObject();
  jNotification.addProperty("body",senderClient.name + " is pinging you.");
  jNotification.addProperty("title",PING_TITLE);
  jNotification.addProperty("icon",PING_ICON);
  jNotification.addProperty("sound","default");
  jNotification.addProperty("click_action",CLICK_ACTION);
  jPing.add(DATA_KEY,jData);
  jPing.add("notification",jNotification);
  friendlyGcmServer.send(toToken,jPing);
}

private void pingClient ( String toToken , String senderToken ) { Client senderClient ; if ( toToken . equals ( SENDER_ID + "@" + GcmServer . GCM_HOST ) ) { senderClient = clientMap . get ( toToken ) ; toToken = senderToken ; } else { senderClient = clientMap . get ( senderToken ) ; } JsonObject jPing = new JsonObject ( ) ; JsonObject jData = new JsonObject ( ) ; jData . addProperty ( ACTION_KEY , PING_CLIENT ) ; jData . addProperty ( SENDER_KEY , senderClient . registrationToken ) ; JsonObject jNotification = new JsonObject ( ) ; jNotification . addProperty ( "body" , senderClient . name + " is pinging you." ) ; jNotification . addProperty ( "title" , PING_TITLE ) ; jNotification . addProperty ( "icon" , PING_ICON ) ; jNotification . addProperty ( "sound" , "default" ) ; jNotification . addProperty ( "click_action" , CLICK_ACTION ) ; jPing . add ( DATA_KEY , jData ) ; jPing . add ( "notification" , jNotification ) ; friendlyGcmServer . send ( toToken , jPing ) ; }
send message to client with matching totoken . the validity of to and sender tokens should be check before this method is called .
