Skip to content

Latest commit

 

History

History
92 lines (81 loc) · 3.67 KB

client.md

File metadata and controls

92 lines (81 loc) · 3.67 KB

Language: English | Українська

SA:MP Mobile CEF

Important Information

  • All client-side logs, including WebView logs, are saved in the SAMP/cef.log folder.
  • There are no additional functions for working with the client part; all necessary functions are specified in the installation instructions below.

Installation and Configuration of the Client (C++)

Warning

The examples provided below are suitable for most projects, but exceptions are possible.

  • Export the client/cpp/libSAMPMobileCef.a and client/cpp/SAMPMobileCef.h files to your client's vendor/cef folder (this folder needs to be created manually).
  • In the Android.mk file, include the libSAMPMobileCef.a library:
    include $(PREBUILT_STATIC_LIBRARY)
    include $(CLEAR_VARS)
    LOCAL_MODULE    := libSAMPMobileCef 
    LOCAL_SRC_FILES := vendor/cef/libSAMPMobileCef.a
    
    LOCAL_STATIC_LIBRARIES := libSAMPMobileCef
  • In the main.cpp file, include the SAMPMobileCef.h header file:
    #include "vendor/cef/SAMPMobileCef.h"
  • In the main.cpp file, in the InitSAMP function, set the game cache path:
    cef::setGamePath(g_pszStorage);
  • In the net/netgame.cpp file, include the SAMPMobileCef.h header file in the same way as in the main.cpp file.
  • In the net/netgame.cpp file, in the CNetGame constructor, initialize the network part of the library:
    cef::initNetwork(m_pRakClient, ID_CUSTOM_CEF); // a pointer to RakClient and a custom packet ID for network communication should be passed (e.g., 252 or any other free in PacketEnumeration)
  • In the net/netgame.cpp file, in CNetGame::UpdateNetwork, add processing for the previously specified packet:
    switch (packetIdentifier)
    {
    ...
    case ID_CUSTOM_CEF: // the previously specified ID in initNetwork
        cef::handlePacket(pkt);
        break;
    }
  • In the net/netgame.cpp file, in CNetGame::Packet_ConnectionSucceeded, add server connection handling:
    cef::handleServerConnection(); // at the end of the function

Installation and Configuration of the Client (Java)

Warning

The examples provided below are suitable for most projects, but exceptions are possible.

  • Export the client/java/sampmobilecef-...-release.aar file to app/libs (the libs folder should be created if it does not exist).
  • In the app/build.gradle file, import the previously exported library:
    dependencies {
        implementation files("libs/sampmobilecef-...-release.aar")
    }
  • In the NvEventQueueActivity file, initialize the following variables:
    private CefJavaManager mJavaManager = null;
    private CefClientManager mClientManager = null;
  • In the NvEventQueueActivity file, in the systemInit function, add the initialization of the necessary classes:
    mJavaManager = new CefJavaManager(mRootFrame, getInstance());
    mClientManager = new CefClientManager(getInstance());
    
    mJavaManager.setClientManager(mClientManager);
    mClientManager.setJavaManager(mJavaManager);
  • In the NvEventQueueueActivity file, in the setPauseState function, add functionality to hide/show the WebView while the pause state is changing:
    public void setPauseState(boolean z2) {
        runOnUiThread(() -> {
            if (mJavaManager.isShow()) {
                if (z2)
                    mJavaManager.hideBrowserView();
                else
                    mJavaManager.showBrowserView();
            }
        });
    }

Copyright © 2024 Denis Akazuki.