当前位置:网站首页>[log service CLS] Tencent cloud game battle engine mgobe accesses CLS

[log service CLS] Tencent cloud game battle engine mgobe accesses CLS

2022-06-24 16:53:00 LittleU

Instructions in advance :

This article focuses on :" Preparation before exercise ", The actual operation will be introduced in the next chapter .

The game development engine used inside is unity, Use Tencent cloud game matchmaking engine , The log service in Tencent cloud must be accessed CLS.

The use of this operation :

Online game engine MGOBE The collected real-time server logs of will be reported to The log service CLS, Developers can log in Log service console see .

So how should we use it first ? If you just want to try the product , Then you can log in This web site View free usage in . If you think it's appropriate , You can pay for it .

After logging into this website, you will see the following interface :

If you want to see other products , Click the corresponding button , So here , Let me demonstrate how to access the Tencent cloud game engine MGOBE, And get the log messages inside .

First of all, we click Tencent cloud game match engine MGOBE The button

Go to the introduction : How to use real-time server logs , So before using , There must be two necessary conditions , The first is to have a game running in Tencent cloud , Another necessary condition is that you already have a powerful server , If you don't , Don't worry about that , Tencent cloud will give you a sample server that you can use , It can also be used to test .

So first of all , We first open and create a game service :

Search directly on the official website of Tencent cloud :" Battle engine ", The first one is , Click use now to go to the console , If this is your first time using , Then it will prompt you to check some clauses . After the check , You can create your own game

Then choose the game you want to play , Each game provides different services . What I choose here is unity Type of game , When it's done , You will see specific information :

The most important thing is before 3 Messages , Keep it , Can't let the cat out of the , If it leaks , Others will use your traffic based on your information . When I finish this function , I will delete the game , You don't have to record .

The billing method inside :

Online game engine MGOBE On 2019 year 8 month 12 The public beta was officially launched on May , Users can use it for free during this period . The free period ends at 2019 year 12 month 31 Japan , from 2020 year 1 month 1 Official billing begins on the th .

Online game engine MGOBE Press game DAU And traffic usage billing , Payment after daily settlement .

You can play the engine online in the game MGOBE Using cloud development in the console of TCB service ,TCB Billing and MGOBE Are independent of each other .

DAU pricing

Payment type

DAU Range

The unit price ( element /DAU/ Japan )

Domestic station price

DAU ≤ 500

0

500 < DAU ≤ 8000

0.0031

8000 < DAU ≤ 2W

0.0027

2W < DAU ≤ 5W

0.0025

5W < DAU ≤ 10W

0.0024

DAU > 10W

Contact business for quotation

Be careful :

  • If the player initializes successfully, it will be counted as DAU,DAU Follow a game within a day player ID De duplication calculation (player ID Is the unique identifier of the in-game user , One user in a game corresponds to one player ID).
  • DAU The billing mode starts from the free quota , Enjoy the progressive price , That is, each paragraph DAU Use a unit price , The consumption in each step is multiplied by the unit price of the step , Sum up to get the total price .

Traffic pricing

Free traffic ( Activity period )

Online game engine MGOBE Activity period ( From now on to 2021 year 12 month 31 Japan ) Give you some free traffic , The gift rules are as follows :

  • The amount of free traffic for each game is 1GB/ God , The complimentary traffic can only be used for the online game engine . The gift limit generated on the same day is valid on the same day .
  • If the traffic consumption of the day exceeds the gift quota , The excess part needs to be paid according to the flow pricing standard .

Flow pricing standard

Payment type

The unit price ( element /GB)

Domestic station price

0.8

Be careful : All of the above “ Traffic ” Both indicate flow ; The incoming flow does not generate flow charges .

Examples of fees

Of a certain game day DAU The data is 2560, produce 2GB Traffic .

Complimentary traffic quota :1GB

The cost of the game for the day is divided into two parts :

  • DAU cost :500 × 0 + (2560 - 500) × 0.0031 = 6.386 element
  • Flow charge :(2GB - 1GB) × 0.8 = 0.8 element

The total cost of the game on that day is :6.386 + 0.8 = 7.186 element

Of course , If you are a test user , So these free quotas are enough for you to test .

Then let's make the second necessary condition : Real time server , Maybe , You don't have such a server , Then you don't have to worry , Because Tencent cloud provides a complete framework , You just need to download and modify it .

Download address

In fact, the function of this server is not to CLS Docking generates logs , In fact, it is a game server " Expand ", For example, the game server expands logic , Such as saving player data , Game status synchronization, etc .

Then download it and check the files inside :

We need to modify it ourselves , Most of it is in index In file . We first try to open this file to see the code inside :

import { mgobexsInterface } from './mgobexsInterface';

const gameServer: mgobexsInterface.GameServer.IGameServer = {
	mode: 'sync',
	onInitGameData: function (): mgobexsInterface.GameData {
		return {};
	},
	onRecvFromClient: function onRecvFromClient({ actionData, gameData, SDK, room, exports }: mgobexsInterface.ActionArgs<mgobexsInterface.UserDefinedData>) {
		gameData.pos = Math.floor(Math.random() * 2000);
		SDK.logger.debug('onRecvFromClient', gameData, actionData);
		setTimeout(() => {
			SDK.sendData({ playerIdList: [], data: { data: gameData, ts: new Date().toISOString() } }, { timeout: 2000, maxTry: 3 });
			SDK.exitAction();
		}, gameData.pos);
	},
	onJoinRoom: function ({ actionData, gameData, SDK, room, exports }) {
		SDK.logger.debug(
			'onJoinRoom',
			'actionData:', actionData,
			'gameData:', gameData,
			'room:', room
		);
	},
	onCreateRoom: function ({ actionData, gameData, SDK, room, exports }) {
		SDK.logger.debug(
			'onCreateRoom',
			'actionData:', actionData,
			'gameData:', gameData,
			'room:', room
		);
	},
	onLeaveRoom: function ({ actionData, gameData, SDK, room, exports }) {
		SDK.logger.debug(
			'onLeaveRoom',
			'actionData:', actionData,
			'gameData:', gameData,
			'room:', room
		);
	},
	onRemovePlayer: function ({ actionData, gameData, SDK, room, exports }) {
		SDK.logger.debug(
			'onRemovePlayer',
			'actionData:', actionData,
			'gameData:', gameData,
			'room:', room
		);
	},
	onDestroyRoom: function ({ actionData, gameData, SDK, room, exports }) {
		SDK.logger.debug(
			'onDestroyRoom',
			'actionData:', actionData,
			'gameData:', gameData,
			'room:', room
		);
	},
	onChangeRoom: function ({ actionData, gameData, SDK, room, exports }) {
		SDK.logger.debug(
			'onChangeRoom',
			'actionData:', actionData,
			'gameData:', gameData,
			'room:', room
		);
	},
	onChangeCustomPlayerStatus: function ({ actionData, gameData, SDK, room, exports }) {
		SDK.logger.debug(
			'onChangeCustomPlayerStatus',
			'actionData:', actionData,
			'gameData:', gameData,
			'room:', room
		);
	},
	onChangePlayerNetworkState: function ({ actionData, gameData, SDK, room, exports }) {
		SDK.logger.debug(
			'onChangePlayerNetworkState',
			'actionData:', actionData,
			'gameData:', gameData,
			'room:', room
		);
	},
	onStartFrameSync: function ({ actionData, gameData, SDK, room, exports }) {
		SDK.logger.debug(
			'onStartFrameSync',
			'actionData:', actionData,
			'gameData:', gameData,
			'room:', room
		);
	},
	onStopFrameSync: function ({ actionData, gameData, SDK, room, exports }) {
		SDK.logger.debug(
			'onStopFrameSync',
			'actionData:', actionData,
			'gameData:', gameData,
			'room:', room
		);
	},
	onChangeRoomPlayerProfile: function ({ actionData, gameData, SDK, room, exports }) {
		SDK.logger.debug(
			'onChangeRoomPlayerProfile',
			'actionData:', actionData,
			'gameData:', gameData,
			'room:', room
		);
	},
};

//  Called when the server is initialized 
function onInitGameServer(tcb: any) {
	//  If needed , You can initialize here  TCB
	const tcbApp = tcb.init({
		secretId: " Please fill in Tencent cloud API secret key ID",
		secretKey: " Please fill in Tencent cloud API secret key KEY",
		env: " Please fill in the cloud development environment ID",
		serviceUrl: 'http://tcb-admin.tencentyun.com/admin',
		timeout: 5000,
	});

	// ...
}

export const mgobexsCode: mgobexsInterface.mgobexsCode = {
	logLevel: 'error+',
	logLevelSDK: 'error+',
	gameInfo: {
		gameId: " Please fill in the game ID",
		serverKey: " Please fill in the back-end key ",
	},
	onInitGameServer,
	gameServer
}

Then you will see that there are room related , Player status related , There are also some frame synchronization related . Of course , There are also some things you need to fill in your , So let's fill this out first , Then compress it again into zip file .

Deploy real-time servers

Sign in Online Game Engine console , Click the menu on the left 【 Custom service logic 】>【 Real time server 】.

single click 【 Create services 】, Enter the new service interface .

There are several options to explain :

  • Choose whether to get through VPC The Internet . Get through Tencent cloud VPC The Internet , Access to your VPC Under the database and storage , It cannot be changed after opening .
  • If you choose to get through VPC , and VPC The drop-down menu is empty , Then you need to go to Private networks Create a VPC; It is recommended that you create... In Shanghai VPC, Such as in other regions , You have to go through Peer to peer connection Realization VPC Cross regional communication ( Shanghai and other regions ), And pay for peer-to-peer connections .

Set the instance quantity range , The maximum value is 20. The default is automatic adjustment , That is, automatically adjust within the set instance range , The setting range will not be exceeded .

then , Click the deployment , Can finish , So over here , One of our basic introductions and preparations for the exercise were completed

Keep going on , Then we should index.js Fill in the information that needs to be filled in the document , such as :

Add description

gameid and serverKey, Both of these fields can be found in your game's battle Engine console , Just copy the past .

So the next thing to fill in is :

Add description

Then these items need to be filled in , First of all, the first two are easy to say :

Click cloud API Get the connection “https://console.cloud.tencent.com/cam/capi”, Log in to Tencent cloud account , It is shown as follows :

Add description

To get the key

And then the last one env It represents the cloud development environment ID, Then you need to go to another place to get this .

https://console.cloud.tencent.com/tcb/env/index?rid=4, Create a

Add description

And then click next

Add description

Then you get a cloud development environment ID, Of course, this is also paid after use .

Save the modified file , And package it again into zip Format .

Add description

Then return to the log deployment console , And then put this zip Just upload the package .

Click deploy after modification , Just wait a minute

Add description

Add description

Then it will be deployed by this time , You just need to run your game , Then it will be in cls See log in . The specific log is index.js The logs that need to be generated in those methods in .

Then run your game

Add description

If you don't have a ready-made game , You can also find a complete example on Tencent cloud , Here, give Tencent cloud a compliment , Because of their efforts , It saves us more than a little .

See my other series of articles for specific methods :

https://cloud.tencent.com/developer/article/1809023, This is the first article in the series , If you need it, you can look through it .

Wait about 30s-1 Minutes later , There will be log information :

Add description

see , Is it super automated . It's the same with cls It is the same as what is said in the introduction of , Just a few mouse clicks , The deployment is complete .

enjoy it !

原网站

版权声明
本文为[LittleU]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/04/20210406122912891e.html