triplea-game / triplea

TripleA is a turn based strategy game and board game engine, similar to Axis & Allies or Risk.
https://triplea-game.org/
GNU General Public License v3.0
1.35k stars 399 forks source link

Replace RMI #1505

Closed RoiEXLab closed 7 years ago

RoiEXLab commented 7 years ago

As you may or may not know, tripleA uses the Java RMI system, which stands for Remote Method Invocation for it's internet communication... I have a more or less concrete idea on how to implement a Network-Communication-System using Java Sockets, but I'm here to discuss the details with you since this is going to be a huge project... I have a Packet System in mind - see my current implementation for more details. This Packet systems uses IDs for every action. Currently I have:

Is there anything missing? How are we going to restart the lobby without killing the java process?

RoiEXLab commented 7 years ago

Just some concluding words, summing up my own opinion: After hearing your concerns, we should IMO opinion go for a WebSockets API and send JSON back and forth. Ideally this JSON should be gzip/deflate compressed, depending on browser support, in order to send less data overall. I'd like to have a consistent JSON scheme to make overall reading much simpler e.g. have all JSON look like this:

{
  "id": "packet_name",
  "version": 1,// In order to be able to maintain backwards compatibility when changing any data
  "data": {
    //The packet-specific data
  }
}

I'm not sure on wether it's a good idea to use gson or some similar object-to-json serialization framework to encode the data object, because this again limits us to our object class structure, while if we would encode the objects manually, we could easily refactor code without having ro worry about breaking anything + we can make sure no unnecessary data is being sent. Thoughts?

DanVanAtta commented 7 years ago

I think we're on the same page. The exact JSON structure used is an interesting thing to consider, a number of different ways to do that. Though, I do think we have at least made a few steps forward. We may want to track this initiative as a project so we can relate the different ideas/PRs as they come up

RoiEXLab commented 7 years ago

I just looked into the net code, and this is going to be a similar huge project as the JavaFX project...

  1. TripleA uses java NIO, which only has SSL/TLS support with manually using SSLEngine. I found a promising example, in order to test some things out, but this example did unfortunetely not work with our code, as our code would need some refactoring in order for it to work,
  2. If we wanted to use IO instead, for the "automatic TLS", we would need to refactor all the netcode (rewrite would be simpler).
RoiEXLab commented 7 years ago

TL;DR: I'm not going to have more than 1 giant project active at the same time: I'm not going to work on this until JavaFX is reaching it's final state, not going to happen soon (although I will continue working on it soon) But if anyone wants to work on the net-code, feel free to do so, I'd very much appreciate it.

DanVanAtta commented 7 years ago

No worries @RoiEXLab , this has been on the radar for some time, we all really would like something that we can update with compile time checks, and let the devs and game players worry far less about versioning.

RoiEXLab commented 7 years ago

@DanVanAtta @ssoloff @ron-murhammer Found this: http://docs.oracle.com/javase/9/rmi/toc.htm We might should consider using a security manager for the server side...

ssoloff commented 7 years ago

Note that some of those recommendations may not be implementable as described at the link. We don't actually use RMI™ but a custom network protocol written by Sean that was heavily influenced by RMI™. From IRemoteMessenger.java:

/**
 * Very similar to RMI
 *
RoiEXLab commented 7 years ago

@ssoloff We actually do: https://github.com/triplea-game/triplea/blob/master/src/main/java/games/strategy/net/GUID.java

ssoloff commented 7 years ago

@RoiEXLab Using a type from the java.rmi package doesn't equate to using the RMI™ protocol. :smile:

RoiEXLab commented 7 years ago

If you say so... ^^