无法使用GCM建立设备到设备的消息传递

I am trying to establish device to device messaging using Google Cloud Messaging. I tried using socket programmng, but the connection used to get lost everytime I moved to the next page. Thus I am using GCM. The plan is to send a message from client's phone and it should be displayed on server's phone, using 3g/wifi and not bluetooth.

I am referring the following link for the same:

http://androidexample.com/Device_To_Device_Messaging_Using_Google_Cloud_Messaging_GCM_-_Android_Example/index.php?view=article_discription&aid=122&aaid=142

It has no errors and is running, but nothing is displaying on the screen. Also a few doubts:

  1. In the code in CommonUtilities.java what should be the Server_Url? I am using XAMPP, so should it be XAMPP's URL?
  2. Also, what should be the Sender_ID?
  3. Also in MainActivity.java, what should be the device IMEI? Do we have to enter that manually, or will the device fetch on ots own.
  4. Also in the php files, its written enter "GCM Registeration ID got from device".Is it client's ID? I am running using Google API and registering my ID in the settings of the emulator before proceeding further.

Can anyone please tell me where am I going wrong? Or even if you have a better idea, please do share here. I am looking for mobile to mobile communication only, not using push notifications.

GCM is working as follow:

1/First of all you have to register your application in google and get your Sender_ID

2/the client connect to GCM cloud in order to register it self (using the SENDR_ID)

3/GCM cloud send a registrationID to the client

4/You should make a server so that you save the registrationID of any device that runs your apps

If you want to send a GCM notification from one client to server

1/the client should connect to your server

2/tell the server to make a demande to the GCM cloud containing the registrationID of the server so that the GCM send the notification to the server

you will find a detailed explanation here