| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!--NewPage--> |
| <HTML> |
| <HEAD> |
| <!-- Generated by javadoc (build 1.6.0_26) on Wed Aug 29 14:55:34 PDT 2012 --> |
| <TITLE> |
| Sender |
| </TITLE> |
| |
| <META NAME="date" CONTENT="2012-08-29"> |
| |
| <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../default.css" TITLE="Style"> |
| |
| <SCRIPT type="text/javascript"> |
| function windowTitle() |
| { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="Sender"; |
| } |
| } |
| </SCRIPT> |
| <NOSCRIPT> |
| </NOSCRIPT> |
| |
| </HEAD> |
| |
| <BODY BGCOLOR="white" onload="windowTitle();"> |
| <HR> |
| |
| |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <A NAME="navbar_top"><!-- --></A> |
| <A HREF="#skip-navbar_top" title="Skip navigation links"></A> |
| <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> |
| <TR> |
| <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> |
| <A NAME="navbar_top_firstrow"><!-- --></A> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> |
| <TR ALIGN="center" VALIGN="top"> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../com/google/android/gcm/server/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> |
| <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> |
| </TR> |
| </TABLE> |
| </TD> |
| <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> |
| </EM> |
| </TD> |
| </TR> |
| |
| <TR> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| <A HREF="../../../../../com/google/android/gcm/server/Result.html" title="class in com.google.android.gcm.server"><B>PREV CLASS</B></A> |
| NEXT CLASS</FONT></TD> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| <A HREF="../../../../../index.html?com/google/android/gcm/server/Sender.html" target="_top"><B>FRAMES</B></A> |
| <A HREF="Sender.html" target="_top"><B>NO FRAMES</B></A> |
| <SCRIPT type="text/javascript"> |
| <!-- |
| if(window==top) { |
| document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); |
| } |
| //--> |
| </SCRIPT> |
| <NOSCRIPT> |
| <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A> |
| </NOSCRIPT> |
| |
| |
| </FONT></TD> |
| </TR> |
| <TR> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> |
| </TR> |
| </TABLE> |
| <A NAME="skip-navbar_top"></A> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| |
| <HR> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <H2> |
| <FONT SIZE="-1"> |
| com.google.android.gcm.server</FONT> |
| <BR> |
| Class Sender</H2> |
| <PRE> |
| java.lang.Object |
| <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>com.google.android.gcm.server.Sender</B> |
| </PRE> |
| <HR> |
| <DL> |
| <DT><PRE>public class <B>Sender</B><DT>extends java.lang.Object</DL> |
| </PRE> |
| |
| <P> |
| Helper class to send messages to the GCM service using an API Key. |
| <P> |
| |
| <P> |
| <HR> |
| |
| <P> |
| <!-- =========== FIELD SUMMARY =========== --> |
| |
| <A NAME="field_summary"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> |
| <B>Field Summary</B></FONT></TH> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>protected static int</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#BACKOFF_INITIAL_DELAY">BACKOFF_INITIAL_DELAY</A></B></CODE> |
| |
| <BR> |
| Initial delay before first retry, without jitter.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>protected java.util.logging.Logger</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#logger">logger</A></B></CODE> |
| |
| <BR> |
| </TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>protected static int</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#MAX_BACKOFF_DELAY">MAX_BACKOFF_DELAY</A></B></CODE> |
| |
| <BR> |
| Maximum delay before a retry.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>protected java.util.Random</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#random">random</A></B></CODE> |
| |
| <BR> |
| </TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>protected static java.lang.String</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#UTF8">UTF8</A></B></CODE> |
| |
| <BR> |
| </TD> |
| </TR> |
| </TABLE> |
| |
| <!-- ======== CONSTRUCTOR SUMMARY ======== --> |
| |
| <A NAME="constructor_summary"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> |
| <B>Constructor Summary</B></FONT></TH> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#Sender(java.lang.String)">Sender</A></B>(java.lang.String key)</CODE> |
| |
| <BR> |
| Default constructor.</TD> |
| </TR> |
| </TABLE> |
| |
| <!-- ========== METHOD SUMMARY =========== --> |
| |
| <A NAME="method_summary"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> |
| <B>Method Summary</B></FONT></TH> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>protected static void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#addParameter(java.lang.StringBuilder, java.lang.String, java.lang.String)">addParameter</A></B>(java.lang.StringBuilder body, |
| java.lang.String name, |
| java.lang.String value)</CODE> |
| |
| <BR> |
| Adds a new parameter to the HTTP POST body.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>protected java.net.HttpURLConnection</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#getConnection(java.lang.String)">getConnection</A></B>(java.lang.String url)</CODE> |
| |
| <BR> |
| Gets an <CODE>HttpURLConnection</CODE> given an URL.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>protected static java.lang.String</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#getString(java.io.InputStream)">getString</A></B>(java.io.InputStream stream)</CODE> |
| |
| <BR> |
| Convenience method to convert an InputStream to a String.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>protected static java.lang.StringBuilder</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#newBody(java.lang.String, java.lang.String)">newBody</A></B>(java.lang.String name, |
| java.lang.String value)</CODE> |
| |
| <BR> |
| Creates a <CODE>StringBuilder</CODE> to be used as the body of an HTTP POST.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>protected static java.util.Map<java.lang.String,java.lang.String></CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#newKeyValues(java.lang.String, java.lang.String)">newKeyValues</A></B>(java.lang.String key, |
| java.lang.String value)</CODE> |
| |
| <BR> |
| Creates a map with just one key-value pair.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>protected java.net.HttpURLConnection</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#post(java.lang.String, java.lang.String)">post</A></B>(java.lang.String url, |
| java.lang.String body)</CODE> |
| |
| <BR> |
| Make an HTTP post to a given URL.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE>protected java.net.HttpURLConnection</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#post(java.lang.String, java.lang.String, java.lang.String)">post</A></B>(java.lang.String url, |
| java.lang.String contentType, |
| java.lang.String body)</CODE> |
| |
| <BR> |
| </TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> <A HREF="../../../../../com/google/android/gcm/server/MulticastResult.html" title="class in com.google.android.gcm.server">MulticastResult</A></CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#send(com.google.android.gcm.server.Message, java.util.List, int)">send</A></B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A> message, |
| java.util.List<java.lang.String> regIds, |
| int retries)</CODE> |
| |
| <BR> |
| Sends a message to many devices, retrying in case of unavailability.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> <A HREF="../../../../../com/google/android/gcm/server/Result.html" title="class in com.google.android.gcm.server">Result</A></CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#send(com.google.android.gcm.server.Message, java.lang.String, int)">send</A></B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A> message, |
| java.lang.String registrationId, |
| int retries)</CODE> |
| |
| <BR> |
| Sends a message to one device, retrying in case of unavailability.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> <A HREF="../../../../../com/google/android/gcm/server/MulticastResult.html" title="class in com.google.android.gcm.server">MulticastResult</A></CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#sendNoRetry(com.google.android.gcm.server.Message, java.util.List)">sendNoRetry</A></B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A> message, |
| java.util.List<java.lang.String> registrationIds)</CODE> |
| |
| <BR> |
| Sends a message without retrying in case of service unavailability.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> <A HREF="../../../../../com/google/android/gcm/server/Result.html" title="class in com.google.android.gcm.server">Result</A></CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../com/google/android/gcm/server/Sender.html#sendNoRetry(com.google.android.gcm.server.Message, java.lang.String)">sendNoRetry</A></B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A> message, |
| java.lang.String registrationId)</CODE> |
| |
| <BR> |
| Sends a message without retrying in case of service unavailability.</TD> |
| </TR> |
| </TABLE> |
| <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
| <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> |
| <TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD> |
| </TR> |
| </TABLE> |
| |
| <P> |
| |
| <!-- ============ FIELD DETAIL =========== --> |
| |
| <A NAME="field_detail"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> |
| <B>Field Detail</B></FONT></TH> |
| </TR> |
| </TABLE> |
| |
| <A NAME="UTF8"><!-- --></A><H3> |
| UTF8</H3> |
| <PRE> |
| protected static final java.lang.String <B>UTF8</B></PRE> |
| <DL> |
| <DL> |
| <DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#com.google.android.gcm.server.Sender.UTF8">Constant Field Values</A></DL> |
| </DL> |
| <HR> |
| |
| <A NAME="BACKOFF_INITIAL_DELAY"><!-- --></A><H3> |
| BACKOFF_INITIAL_DELAY</H3> |
| <PRE> |
| protected static final int <B>BACKOFF_INITIAL_DELAY</B></PRE> |
| <DL> |
| <DD>Initial delay before first retry, without jitter. |
| <P> |
| <DL> |
| <DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#com.google.android.gcm.server.Sender.BACKOFF_INITIAL_DELAY">Constant Field Values</A></DL> |
| </DL> |
| <HR> |
| |
| <A NAME="MAX_BACKOFF_DELAY"><!-- --></A><H3> |
| MAX_BACKOFF_DELAY</H3> |
| <PRE> |
| protected static final int <B>MAX_BACKOFF_DELAY</B></PRE> |
| <DL> |
| <DD>Maximum delay before a retry. |
| <P> |
| <DL> |
| <DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#com.google.android.gcm.server.Sender.MAX_BACKOFF_DELAY">Constant Field Values</A></DL> |
| </DL> |
| <HR> |
| |
| <A NAME="random"><!-- --></A><H3> |
| random</H3> |
| <PRE> |
| protected final java.util.Random <B>random</B></PRE> |
| <DL> |
| <DL> |
| </DL> |
| </DL> |
| <HR> |
| |
| <A NAME="logger"><!-- --></A><H3> |
| logger</H3> |
| <PRE> |
| protected final java.util.logging.Logger <B>logger</B></PRE> |
| <DL> |
| <DL> |
| </DL> |
| </DL> |
| |
| <!-- ========= CONSTRUCTOR DETAIL ======== --> |
| |
| <A NAME="constructor_detail"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> |
| <B>Constructor Detail</B></FONT></TH> |
| </TR> |
| </TABLE> |
| |
| <A NAME="Sender(java.lang.String)"><!-- --></A><H3> |
| Sender</H3> |
| <PRE> |
| public <B>Sender</B>(java.lang.String key)</PRE> |
| <DL> |
| <DD>Default constructor. |
| <P> |
| <DL> |
| <DT><B>Parameters:</B><DD><CODE>key</CODE> - API key obtained through the Google API Console.</DL> |
| </DL> |
| |
| <!-- ============ METHOD DETAIL ========== --> |
| |
| <A NAME="method_detail"><!-- --></A> |
| <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
| <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
| <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> |
| <B>Method Detail</B></FONT></TH> |
| </TR> |
| </TABLE> |
| |
| <A NAME="send(com.google.android.gcm.server.Message, java.lang.String, int)"><!-- --></A><H3> |
| send</H3> |
| <PRE> |
| public <A HREF="../../../../../com/google/android/gcm/server/Result.html" title="class in com.google.android.gcm.server">Result</A> <B>send</B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A> message, |
| java.lang.String registrationId, |
| int retries) |
| throws java.io.IOException</PRE> |
| <DL> |
| <DD>Sends a message to one device, retrying in case of unavailability. |
| |
| <p> |
| <strong>Note: </strong> this method uses exponential back-off to retry in |
| case of service unavailability and hence could block the calling thread |
| for many seconds. |
| <P> |
| <DD><DL> |
| <DT><B>Parameters:</B><DD><CODE>message</CODE> - message to be sent, including the device's registration id.<DD><CODE>registrationId</CODE> - device where the message will be sent.<DD><CODE>retries</CODE> - number of retries in case of service unavailability errors. |
| <DT><B>Returns:</B><DD>result of the request (see its javadoc for more details) |
| <DT><B>Throws:</B> |
| <DD><CODE>java.lang.IllegalArgumentException</CODE> - if registrationId is null. |
| <DD><CODE><A HREF="../../../../../com/google/android/gcm/server/InvalidRequestException.html" title="class in com.google.android.gcm.server">InvalidRequestException</A></CODE> - if GCM didn't returned a 200 or 503 status. |
| <DD><CODE>java.io.IOException</CODE> - if message could not be sent.</DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="sendNoRetry(com.google.android.gcm.server.Message, java.lang.String)"><!-- --></A><H3> |
| sendNoRetry</H3> |
| <PRE> |
| public <A HREF="../../../../../com/google/android/gcm/server/Result.html" title="class in com.google.android.gcm.server">Result</A> <B>sendNoRetry</B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A> message, |
| java.lang.String registrationId) |
| throws java.io.IOException</PRE> |
| <DL> |
| <DD>Sends a message without retrying in case of service unavailability. See |
| <A HREF="../../../../../com/google/android/gcm/server/Sender.html#send(com.google.android.gcm.server.Message, java.lang.String, int)"><CODE>send(Message, String, int)</CODE></A> for more info. |
| <P> |
| <DD><DL> |
| |
| <DT><B>Returns:</B><DD>result of the post, or null if the GCM service was |
| unavailable. |
| <DT><B>Throws:</B> |
| <DD><CODE><A HREF="../../../../../com/google/android/gcm/server/InvalidRequestException.html" title="class in com.google.android.gcm.server">InvalidRequestException</A></CODE> - if GCM didn't returned a 200 or 503 status. |
| <DD><CODE>java.lang.IllegalArgumentException</CODE> - if registrationId is null. |
| <DD><CODE>java.io.IOException</CODE></DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="send(com.google.android.gcm.server.Message, java.util.List, int)"><!-- --></A><H3> |
| send</H3> |
| <PRE> |
| public <A HREF="../../../../../com/google/android/gcm/server/MulticastResult.html" title="class in com.google.android.gcm.server">MulticastResult</A> <B>send</B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A> message, |
| java.util.List<java.lang.String> regIds, |
| int retries) |
| throws java.io.IOException</PRE> |
| <DL> |
| <DD>Sends a message to many devices, retrying in case of unavailability. |
| |
| <p> |
| <strong>Note: </strong> this method uses exponential back-off to retry in |
| case of service unavailability and hence could block the calling thread |
| for many seconds. |
| <P> |
| <DD><DL> |
| <DT><B>Parameters:</B><DD><CODE>message</CODE> - message to be sent.<DD><CODE>regIds</CODE> - registration id of the devices that will receive |
| the message.<DD><CODE>retries</CODE> - number of retries in case of service unavailability errors. |
| <DT><B>Returns:</B><DD>combined result of all requests made. |
| <DT><B>Throws:</B> |
| <DD><CODE>java.lang.IllegalArgumentException</CODE> - if registrationIds is null or |
| empty. |
| <DD><CODE><A HREF="../../../../../com/google/android/gcm/server/InvalidRequestException.html" title="class in com.google.android.gcm.server">InvalidRequestException</A></CODE> - if GCM didn't returned a 200 or 503 status. |
| <DD><CODE>java.io.IOException</CODE> - if message could not be sent.</DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="sendNoRetry(com.google.android.gcm.server.Message, java.util.List)"><!-- --></A><H3> |
| sendNoRetry</H3> |
| <PRE> |
| public <A HREF="../../../../../com/google/android/gcm/server/MulticastResult.html" title="class in com.google.android.gcm.server">MulticastResult</A> <B>sendNoRetry</B>(<A HREF="../../../../../com/google/android/gcm/server/Message.html" title="class in com.google.android.gcm.server">Message</A> message, |
| java.util.List<java.lang.String> registrationIds) |
| throws java.io.IOException</PRE> |
| <DL> |
| <DD>Sends a message without retrying in case of service unavailability. See |
| <A HREF="../../../../../com/google/android/gcm/server/Sender.html#send(com.google.android.gcm.server.Message, java.util.List, int)"><CODE>send(Message, List, int)</CODE></A> for more info. |
| <P> |
| <DD><DL> |
| |
| <DT><B>Returns:</B><DD>true if the message was sent successfully, |
| false if it failed but could be retried. |
| <DT><B>Throws:</B> |
| <DD><CODE>java.lang.IllegalArgumentException</CODE> - if registrationIds is null or |
| empty. |
| <DD><CODE><A HREF="../../../../../com/google/android/gcm/server/InvalidRequestException.html" title="class in com.google.android.gcm.server">InvalidRequestException</A></CODE> - if GCM didn't returned a 200 status. |
| <DD><CODE>java.io.IOException</CODE> - if message could not be sent or received.</DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="post(java.lang.String, java.lang.String)"><!-- --></A><H3> |
| post</H3> |
| <PRE> |
| protected java.net.HttpURLConnection <B>post</B>(java.lang.String url, |
| java.lang.String body) |
| throws java.io.IOException</PRE> |
| <DL> |
| <DD>Make an HTTP post to a given URL. |
| <P> |
| <DD><DL> |
| |
| <DT><B>Returns:</B><DD>HTTP response. |
| <DT><B>Throws:</B> |
| <DD><CODE>java.io.IOException</CODE></DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="post(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3> |
| post</H3> |
| <PRE> |
| protected java.net.HttpURLConnection <B>post</B>(java.lang.String url, |
| java.lang.String contentType, |
| java.lang.String body) |
| throws java.io.IOException</PRE> |
| <DL> |
| <DD><DL> |
| |
| <DT><B>Throws:</B> |
| <DD><CODE>java.io.IOException</CODE></DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="newKeyValues(java.lang.String, java.lang.String)"><!-- --></A><H3> |
| newKeyValues</H3> |
| <PRE> |
| protected static final java.util.Map<java.lang.String,java.lang.String> <B>newKeyValues</B>(java.lang.String key, |
| java.lang.String value)</PRE> |
| <DL> |
| <DD>Creates a map with just one key-value pair. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="newBody(java.lang.String, java.lang.String)"><!-- --></A><H3> |
| newBody</H3> |
| <PRE> |
| protected static java.lang.StringBuilder <B>newBody</B>(java.lang.String name, |
| java.lang.String value)</PRE> |
| <DL> |
| <DD>Creates a <CODE>StringBuilder</CODE> to be used as the body of an HTTP POST. |
| <P> |
| <DD><DL> |
| <DT><B>Parameters:</B><DD><CODE>name</CODE> - initial parameter for the POST.<DD><CODE>value</CODE> - initial value for that parameter. |
| <DT><B>Returns:</B><DD>StringBuilder to be used an HTTP POST body.</DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="addParameter(java.lang.StringBuilder, java.lang.String, java.lang.String)"><!-- --></A><H3> |
| addParameter</H3> |
| <PRE> |
| protected static void <B>addParameter</B>(java.lang.StringBuilder body, |
| java.lang.String name, |
| java.lang.String value)</PRE> |
| <DL> |
| <DD>Adds a new parameter to the HTTP POST body. |
| <P> |
| <DD><DL> |
| <DT><B>Parameters:</B><DD><CODE>body</CODE> - HTTP POST body<DD><CODE>name</CODE> - parameter's name<DD><CODE>value</CODE> - parameter's value</DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="getConnection(java.lang.String)"><!-- --></A><H3> |
| getConnection</H3> |
| <PRE> |
| protected java.net.HttpURLConnection <B>getConnection</B>(java.lang.String url) |
| throws java.io.IOException</PRE> |
| <DL> |
| <DD>Gets an <CODE>HttpURLConnection</CODE> given an URL. |
| <P> |
| <DD><DL> |
| |
| <DT><B>Throws:</B> |
| <DD><CODE>java.io.IOException</CODE></DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="getString(java.io.InputStream)"><!-- --></A><H3> |
| getString</H3> |
| <PRE> |
| protected static java.lang.String <B>getString</B>(java.io.InputStream stream) |
| throws java.io.IOException</PRE> |
| <DL> |
| <DD>Convenience method to convert an InputStream to a String. |
| |
| <p> |
| If the stream ends in a newline character, it will be stripped. |
| <p> |
| If the stream is null, returns an empty string. |
| <P> |
| <DD><DL> |
| |
| <DT><B>Throws:</B> |
| <DD><CODE>java.io.IOException</CODE></DL> |
| </DD> |
| </DL> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <HR> |
| |
| |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <A NAME="navbar_bottom"><!-- --></A> |
| <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> |
| <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> |
| <TR> |
| <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> |
| <A NAME="navbar_bottom_firstrow"><!-- --></A> |
| <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> |
| <TR ALIGN="center" VALIGN="top"> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../com/google/android/gcm/server/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> |
| <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> |
| </TR> |
| </TABLE> |
| </TD> |
| <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> |
| </EM> |
| </TD> |
| </TR> |
| |
| <TR> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| <A HREF="../../../../../com/google/android/gcm/server/Result.html" title="class in com.google.android.gcm.server"><B>PREV CLASS</B></A> |
| NEXT CLASS</FONT></TD> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| <A HREF="../../../../../index.html?com/google/android/gcm/server/Sender.html" target="_top"><B>FRAMES</B></A> |
| <A HREF="Sender.html" target="_top"><B>NO FRAMES</B></A> |
| <SCRIPT type="text/javascript"> |
| <!-- |
| if(window==top) { |
| document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); |
| } |
| //--> |
| </SCRIPT> |
| <NOSCRIPT> |
| <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A> |
| </NOSCRIPT> |
| |
| |
| </FONT></TD> |
| </TR> |
| <TR> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> |
| </TR> |
| </TABLE> |
| <A NAME="skip-navbar_bottom"></A> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| |
| <HR> |
| |
| </BODY> |
| </HTML> |