Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7407367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:42:25+00:00 2026-05-29T05:42:25+00:00

I’d like to use PlayN to create a client/server card game, e.g. Hearts. While

  • 0

I’d like to use PlayN to create a client/server card game, e.g. Hearts. While I’m mostly focusing on the HTML5 output, I’d ideally like to be output-platform-agnostic in case I decide to make an Android client in the future. How should I approach the RPC mechanism?

These are the options I’ve thought of:

  1. Use JSON for RPCs with get()/post() methods – write a servlet that accepts/returns JSON, and make all versions of client code use that. This seems doable, but I’m concerned about JSON’s verbosity. Once I get Hearts working I’d like to move on to more complex games, and I’m worried that JSON will result in a lot of much-larger-than-necessary messages being passed back and forth between client and server. I don’t actually know how to work with JSON in Java, but I assume this is doable. Are my assumptions in-line? How well does Java work with JSON?
  2. Continue using GWT-RPC. I can do this by taking an asynchronous service interface in my core (platform-agnostic) constructor, and in my HTML main() I pass in the GWT Async interface generated by GWT.create(MyService.class) (or at least a wrapper around it). I have no idea how well this would work for non-HTML versions though. Is it possible for me to use GWT-RPC from client-side Java code directly?
  3. Use some other form of RPC. Any suggestions?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:42:26+00:00Added an answer on May 29, 2026 at 5:42 am

    For the GWT RPC on the Java and Android platforms, I’m currently experimenting with using gwt-syncproxy to provide Java client access to the GWT RPC methods, and I’m using Guice, Gin, and RoboGuice on their respective target platforms to inject the appropriate asynchronous service instances for the instantiated Game object.

    In the core/pom.xml for a PlayN project, I include the following dependency coordinates to support DI from Gin/Guice/RoboGuice as needed:

    <dependency>
      <groupId>javax.inject</groupId>
      <artifactId>javax.inject</artifactId>
      <version>1</version>
    </dependency>
    

    Then I add @Inject annotations to any fields inside of the concrete Game implementation:

    public class TestGame implements Game {
    
        @Inject
        TestServiceAsync _testService;
    
        ...
    
    }
    

    In the html/pom.xml, I include the dependency coordinates for Gin:

    <dependency>
      <groupId>com.google.gwt.inject</groupId>
      <artifactId>gin</artifactId>
      <version>1.5.0</version>
    </dependency>
    

    And I create TestGameGinjector and TestGameModule classes:

    TestGameGinjector.java

    @GinModules(TestGameModule.class)
    public interface TestGameGinjector extends Ginjector {
        TestGame getGame();
    }
    

    TestGameModule.java

    public class TestGameModule extends AbstractGinModule {
        @Override
        protected void configure() {
        }
    }
    

    Since at the moment, I’m only injecting the TestServiceAsync interface, I don’t need to put any implementation in the TestGameModule.configure() method; Gin manages instantiation of AsyncServices for me via GWT.create().

    I then added the following to TestGame.gwt.xml

    <inherits name='com.google.gwt.inject.Inject'/>
    

    And finally, I made the following changes to TestGameHtml.java

    public class TestGameHtml extends HtmlGame {
    
        private final TestGameGinjector _injector = GWT.create(TestGameGinjector.class);
    
        @Override
        public void start() {
            HtmlPlatform platform = HtmlPlatform.register();
            platform.assetManager().setPathPrefix("test/");
            PlayN.run(_injector.getGame());
        }
    }
    

    And this pretty much covers the HTML5 platform for PlayN.

    For the Java platform, I add the following dependency coordinates to java/pom.xml:

    <dependency>
      <groupId>com.gdevelop.gwt.syncrpc</groupId>
      <artifactId>gwt-syncproxy</artifactId>
      <version>0.4-SNAPSHOT</version>
    </dependency>
    
    <dependency>
      <groupId>com.google.inject</groupId>
      <artifactId>guice</artifactId>
      <version>3.0-rc2</version>
    </dependency>
    

    Do note that the gwt-syncproxy project on Google Code does not contain a pom.xml. I have a mavenized version of gwt-syncproxy forked and available via git at https://bitbucket.org/hatboyzero/gwt-syncproxy.git. You should be able to clone it, run mvn clean package install to get it into your local Maven repository.

    Anyways, I created a TestGameModule.java for the Java platform as follows:

    public class TestGameModule extends AbstractModule {
    
        @Override
        protected void configure() {
            bind(TestServiceAsync.class).toProvider(TestServiceProvider.class);
        }
    
        public static class TestServiceProvider implements Provider<TestServiceAsync> {
            public TestServiceAsync get() {
                return (TestServiceAsync) SyncProxy.newProxyInstance(
                    TestServiceAsync.class,
                    Deployment.gwtWebPath(),  // URL to webapp -- http://127.0.0.1:8888/testgame
                    "test"
                );
            }
        }
    }
    

    And I modified TestGameJava.java as follows:

    public class TestGameJava {
    
        public static void main(String[] args) {
            Injector _injector = Guice.createInjector(new TestGameModule());
    
            JavaPlatform platform = JavaPlatform.register();
            platform.assetManager().setPathPrefix("test/images");
            PlayN.run(_injector.getInstance(TestGame.class));
        }
    }
    

    I went through a similar exercise with the Android platform and RoboGuice — without going into tremendous detail, the relevant changes/snippets are as follows:

    pom.xml dependencies

    <dependency>
      <groupId>com.gdevelop.gwt.syncrpc</groupId>
      <artifactId>gwt-syncproxy</artifactId>
      <version>0.4-SNAPSHOT</version>
    </dependency>
    
    <dependency>
      <groupId>org.roboguice</groupId>
      <artifactId>roboguice</artifactId>
      <version>1.1.2</version>
    </dependency>
    
    <dependency>
      <groupId>com.google.inject</groupId>
      <artifactId>guice</artifactId>
      <version>3.0-rc2</version>
      <classifier>no_aop</classifier>
    </dependency>
    

    TestGameApplication.java

    public class TestGameApplication extends RoboApplication {
        @Override
        protected void addApplicationModules(List<Module> modules) {
            modules.add(new TestGameModule());
        }
    }
    

    TestGameModule.java

    public class TestGameModule extends AbstractModule {
    
        @Override
        protected void configure() {
            bind(TestServiceAsync.class).toProvider(TestServiceProvider.class);
        }
    
        public static class TestServiceProvider implements Provider<TestServiceAsync> {
            public TestServiceAsync get() {
                return (TestServiceAsync) SyncProxy.newProxyInstance(
                    TestServiceAsync.class,
                    Deployment.gwtWebPath(),  // URL to webapp -- http://127.0.0.1:8888/testgame
                    "test"
                );
            }
        }
    }
    

    TestGameActivity.java

    public class TestGameActivity extends GameActivity {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
        final Injector injector = ((RoboApplication) getApplication()).getInjector();
            injector.injectMembers(this);
            super.onCreate(savedInstanceState);
        }
    
        @Override
        public void main(){
            platform().assetManager().setPathPrefix("test/images");
            final Injector injector = ((RoboApplication) getApplication()).getInjector();
            PlayN.run(injector.getInstance(TestGame.class));
        }
    }
    

    That’s a quick and dirty rundown of how I got Gin/Guice/RoboGuice + GWT working in my project, and I have verified that it works on both Java and HTML platforms beautifully.

    Anyways, there’s the GWT approach to providing RPC calls to multiple PlayN platforms :).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.