Interface MetaserverClient


  • public interface MetaserverClient
    Meta Server Client
    This is an API client to connect to the metaserver. Note that the client is async and all callbacks will be executed in a separate IO thread. Implement onSuccess and onError callbacks respectively. In the context of these IO threads engine and server facades must be accessed with context check disabled and there are limitations to access classes from scripts. Therefore it is advised to just fire an event or dispatch a message and execute any major operation in the event- or message handler.
    • Method Detail

      • announce

        void announce​(DirectoryRecord record,
                      String officialKey,
                      Runnable onSuccess,
                      Consumer<Exception> onError)
        Announces a game session. Must be renewed in certain intervals. DirectoryRecord#secret is required to renew an entry, just set the same secret as for the initial announcement. A valid officialKey is optional but required to announce game sessions that are flagged as official.
      • discontinue

        void discontinue​(DirectoryRecord record,
                         Runnable onSuccess,
                         Consumer<Exception> onError)
        Removes a game session from the game browser. DirectoryRecord#secret is required, just set the same secret as for the initial announcement.
      • testConnection

        void testConnection​(Runnable onSuccess,
                            Consumer<Exception> onError)
        Metaserver will try to open a server connection to the sender's IP address to check whether the game server is reachable (e.g. in the router) and accepts connections
      • announceDedicated

        void announceDedicated​(DedicatedRecord record,
                               String officialKey,
                               Runnable onSuccess,
                               Consumer<Exception> onError)
        Announces a dedicated server for match making. Must be renewed in certain intervals, secret must match for renewing. A valid officialKey is optional but required to announce game sessions that are flagged as official.
      • queryShare

        void queryShare​(String hash,
                        String code,
                        Consumer<String> onSuccess,
                        Consumer<Exception> onError)
        Queries shared objects (e.g. ships, scenes)
        Parameters:
        hash - Optional, hash of object to download (You have to provide either hash or code)
        code - Optional, download code to download (You have to provide either hash or code)
        monitor - Optional, callback to receive download progress. First argument is the current size in bytes, second is the toal size (can be 0 because of chunked transfers)
      • uploadShare

        void uploadShare​(Object payload,
                         BiConsumer<Long,​Long> monitor,
                         Consumer<String> onSuccess,
                         Consumer<Exception> onError)
        Shares an object (e.g. ships, scenes) Only these classes can be uploaded: de.extio.spacecraft.shared.model.bo.Scene, de.extio.spacecraft.shared.model.message.toboth.CompositeEntityDefinitionMessage
        Parameters:
        monitor - Optional, callback to receive upload progress. First argument is the current size in bytes, second is the toal size (can be 0)
        onSuccess - Callback payload is the download code
      • downloadShare

        void downloadShare​(String hash,
                           String code,
                           BiConsumer<Long,​Long> monitor,
                           Consumer<byte[]> onSuccess,
                           Consumer<Exception> onError)
        Downloads an object from share (e.g. ships, scenes) Deserialize with ObjectSerialization#deserialize(bytes, false, true, true, null, null, null) from engine or server facade.
        Be aware that the onSuccess callback (as all callbacks) will be executed in an IO thread and the serializer will only use the default class loader in that context. If you need to deserialize classes from scripts you need to dispatch the data first to your client engine or server game session instance thread.
        Parameters:
        hash - Optional, hash of object to download (You have to provide either hash or code)
        code - Optional, download code to download (You have to provide either hash or code)
        monitor - Optional, callback to receive download progress. First argument is the current size in bytes, second is the toal size (can be 0 because of chunked transfers)