@@ -0,0 +1,1940 @@
+package typo.gtp;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.net.HttpURLConnection;%0Aimport java.net.URL;%0A%0Apublic class Rest %7B%0A%0A%09public static String mServerUrl = %22http://goratingserver.appspot.com/rankingserver/restful%22;%0A%0A%09private static String sendRequest( String pUrl ) throws IOException %7B%0A%09%09for( int i=0 ; true ; ++i ) %7B%0A%09%09%09URL url = new URL( pUrl );%0A%09%09%09HttpURLConnection conn = (HttpURLConnection) url.openConnection();%0A%09%09%09conn.setRequestMethod( %22GET%22 );%0A%09%09%09if( conn.getResponseCode() != 200 ) %7B%0A%09%09%09%09try %7B%0A%09%09%09%09%09Thread.sleep( (int)Math.pow( 2 , i ) * 100l );%0A%09%09%09%09%7D catch( InterruptedException pE ) %7B%0A%09%09%09%09%09throw new Error( pE );%0A%09%09%09%09%7D%0A%09%09%09%09System.err.println( pUrl + %22 : %22 + conn.getResponseCode() );%0A%09%09%09%09continue;%0A%09%09%09%7D%0A%09%09%09InputStream input = conn.getInputStream();%0A%09%09%09StringBuffer result=new StringBuffer();%0A%09%09%09for( int c=input.read() ; c != -1 ; c=input.read() ) %7B%0A%09%09%09%09result.append( (char)c );%0A%09%09%09%7D%0A%09%09%09return result.toString();%0A%09%09%7D%0A%09%7D%0A%0A%09public static void sendMove( long pUserId , Move pMove , int pMoveNumber ) throws IOException %7B%0A%09%09sendRequest( mServerUrl + %22?c=sm&u=%22 + pUserId + %22&n=%22 + pMoveNumber + %22&m=%22 + pMove.toJson() );%0A%09%7D%0A%0A%09public static void registerForPairing( long pUserId , boolean pBlitz , boolean pFast ) throws IOException %7B%0A%09%09sendRequest( mServerUrl + %22?c=rfp&u=%22 + pUserId + %22&b=%22 + pBlitz + %22&f=%22 + pFast );%0A%09%7D%0A%0A%09public static void ack( long pUserId , long pMessageId ) throws IOException %7B%0A%09%09sendRequest( mServerUrl + %22?c=a&u=%22 + pUserId + %22&m=%22 + pMessageId );%0A%09%7D%0A%0A%09public static void resync( long pUserId ) throws IOException %7B%0A%09%09sendRequest( mServerUrl + %22?c=r&u=%22 + pUserId );%0A%09%7D%0A%0A%09public static String getChannelSecret( long pUserId , long pUnique ) throws IOException %7B%0A%09%09return sendRequest( mServerUrl + %22?c=gcs&u=%22 + pUserId + %22&a=%22 + pUnique );%0A%09%7D%0A%0A%09public static long createUserId() throws IOException %7B%0A%09%09return Long.parseLong( sendRequest( mServerUrl + %22?c=cui%22 ) );%0A%09%7D%0A%0A%7D%0A

support for websockets