Overview
1. Why Extension
Although PGOS has offered many game services to help you building your awesome games, we are not able to do all the features and backend logic for you. In our perspective, a good designed extension will empower the game online service and make it more flexible. We hope that you can handle any event in your way, and make your own service which can interact with PGOS services and your own client and dedicated server. Also, you can notify your own server that is outside PGOS by configuring Event Handler and WebHook on PGOS Web Portal. All these things will be done quickly just with a lightweight framework. What you need to do is just writing server codes with the language that you prefer. The left stuff will be covered automatically by PGOS backend.
2. Virtual Server
2.1 What is Virtual Server
Virtual Server is an Extension service offered by PGOS, allowing developers to expand the functionality and implement customized features through code writing. The essence of a Virtual Server is that developers create web servers, which are then deployed and run on the container runtime platform provided by PGOS. To orchestrate and manage the virtual servers written by developers, PGOS uses the Knative framework and ensures isolation between Virtual Servers under different TitleRegions.
2.2 Hierarchy
Virtual Server includes the following layers:
- Tool Layer
- Dev Tool: Supports editing, uploading and submitting code online.
- CI/CD Pipeline: Support continuous integration and automated deployment.
- Application Layer
- Backend API: Provides access to back-end PGOS services.
- Storage: Back-end data storage, including player data and title region conifg data. In the future, PGOS will also support the storage of custom game data.
- Env Vars: Configuration of environment variables at runtime.
- Basic Layer
- Monitoring: Monitors the running status of the Virtual Server.
- Stat: Displays the Virtual Server's running status and statistics, including call count, concurrency, and error count.
- Logs: Allows the Virtual Server run logs to be queried.
- Core Layer
- Runtime: Currently, PGOS uses Google KNative.
2.3 Triggers
Virtual Server can be accessed in the following ways:
- Task: Configure a scheduled Task on the Web Portal to trigger a specific Virtual Server Function.
- Event: Configure an Event Handler with filter Conditions to trigger a specific Virtual Server Function.
- Game (Client/DS): Trigger a specific Virtual Server Function using the PGOS SDK.
- Web Portal: Trigger a specific Virtual Server Function manually via the Web Portal.
3. Events
3.1 What is an Event
An Event is generated when something happens. For example, event_player_login_pgos
will be generated when a player login. One or more Actions can be executed when an Event triggered. These Actions can be bound with specific Virtual Server
or Webhook
, which will be executed once the corresponding event triggered. You can configure them in the Web Portal.
3.2 Event Actions
The "Event-Handler-Action" conceptual model is shown in the figure below.
- One or more handlers can be configured in an Event.
- A handler can have one filter and one or more Actions.
- A filter is a set of logical judgments with conditional expressions.
- The action must be a Virtual Server Function. WebHooks and other types of Actions will be supported in the future. The Actions can be triggered only when the filter is TRUE.
3.3 Filter
A Filter consists of "AND" and "OR" logical judgments with conditional expressions, as shown below:
3.4 Documentation
For more details, please refer to Events.
4. WebHook
4.1 What is a WebHook
Webhook is a "user-defined HTTP/HTTPS callback" that can be set to Events' Actions, which is triggered by Events.
5.2 Documentation
For more details, please refer to WebHook.
5. Tasks
5.1 What is a Task
A Task automatically executes specific Actions at a given time.
Tasks execute predefined Virtual Server Functions to achieve specific Actions.
PGOS provides crontab expressions that are accurate to the second. Developers can use crontab expressions to precisely define the task trigger time. The crontab expression is as follows; click here to learn more.
5.2 Documentation
For more details, please refer to Task.