Auxiliary System

The Auxiliary System of SGUtil For Unity provides following methods.

Initialization

Method

void Init(string params, bool autoDeliverProduct)

Parameters
  • params - parameter string. It must be "name=value" series joined by '&', within which there must be "gameServerClass" and "location". "gameServerClass" is the class path of game server interface implementation, while "location" must be "beijing" at present. CP may add other parameters in accordance with its business necessity. These parameters are converted to Map and passed to method "init" of game server class. For details of game server interface, please refer to SGGameServerInterface .
  • autoDeliverProduct - specify whether SGUtil should automatically check order state and let game server mark it as delivered after user completes UI operation to buy a product. If set it to false, you need to manually do the job by calling GetOrderState later. Other function cannot be executed during the automatic checking period. If you think it a problem, please set it to false and call GetOrderState to check order state by yourself.
Remark
  • Initialize SGUtil For Unity.
  • The result of initialization is notified via OnInit.

Initialization Callback

Method

void OnInit(SGUResult resultCode)

Parameters
  • resultCode - result code
Remark
  • You must not do any subsequent calls neither should you call Init again if the initialization failed.

Start Game

Method

void StartGame()

Parameters
Remark
  • This API calls startGame() of game server interface asynchronously.
  • The result is notified to caller via OnStartGame.

Start Game Callback

Method

void OnStartGame(SGUResult resultCode)

Parameters
  • resultCode - result code
Remark

Stop Game

Method

void StopGame()

Parameters
Remark
  • This API calls stopGame() of game server interface asynchronously.
  • The result is notified to caller via OnStopGame.

Stop Game Callback

Method

void OnStopGame(SGUResult resultCode)

Parameters
  • resultCode - result code
Remark

Remote Logging

Method

void Log(int action, string key, int value, string message)

Parameters
  • action - action code. Refer to SGGameServerInterface.log
  • key - the key of log, null indicates no key
  • value - the value of key
  • message - log message
Remark
  • This API calls log() of game server interface asynchronously.
  • The actual effect depends on implementation of game server and game server interface.
  • The result is notified to caller via OnRemoteLog.

Remote Logging Callback

Method

void OnRemoteLog(SGUResult resultCode)

Parameters
  • resultCode - result code
Remark

Get Value of Remote Log

Method

void GetLogValue(string key, int default_value)

Parameters
  • key - key name
  • default_value - default value to be returned in case of failure or not found
Remark
  • This API call getLogValue() of game server interface asynchronously.
  • The actual effect depends on implementation of game server and game server interface.
  • The result is notified to caller via OnRemoteLogValue.

Get Value of Remote Log Callback

Method

void OnRemoteLogValue(SGUResult resultCode, string key, int value, string msg)

Parameters
  • resultCode - result code
  • name - key name
  • value - value
  • msg - content text of log
Remark

Get List of Extended Methods

Method

List<SGUExtMethod> GetExtMethodList()

Parameters
Remark
  • This API returns a list of extended methods supported by integrated channel. Channels may have different extended methods from each other, but method 'getChannelName' is always available. You may call it to get the channel name and do appropriate things.

Run Extended Method

Method

SGUExtMethodReturn RunExtMethod(string name, string cmd_line_args)

Parameters
  • name - name of method
  • cmd_line_args - command line to be passed to method. All arguments must be strings, and should be concatenated with spaces. A parameter should be embraced with quotation mark (") if it contains spaces within itself.
Remark
  • Refer to SGAgent.runExtMethod
  • The result of API call is returned in SGUExtMethodReturn. If it's an asynchronous method, consequent result is notified to caller via OnExtMethod.

Run Extended Method Callback

Method

void OnExtMethod(SGUResult resultCode, SGUExtMethodResult result)

Parameters
  • resultCode - result code
  • result - result
Remark
  • Result of aynchronous processing is notified to caller via this callback. 'resultCode' is set to RESULT_ITEM and detailed information is stored in 'result'.

Set System Property

Method

void SetSystemProperty(string name, string value)

Parameters
  • name - property name
  • value - peroperty value
Remark
  • The method does not response with callback.
  • Please refer to Java's System.setProperty for details.

Share Screen

Method

void ShareScreen(string filepath, string title, string content)

Parameters
  • filepath - absolute path of screenshot image file
  • title - title
  • content - content
Remark
  • This API invokes channel SDK interface to share screenshot.
  • The result is notified to caller via OnShareScreen.

Share Screen Callback

Method

void OnScreenShare(SGUResult resultCode, string path)

Parameters
  • resultCode - result code
  • path - path of image file to be shared
Remark
  • Application may use the parameter 'path' to delete temporarily-created image file.

Function Request From Low Level

Method

void OnFuncRequest(SGUResult resultCode, string func, string id, string arg)

Parameters
  • resultCode - always be RESULT_FUNC_REQUEST
  • func - function name (one of "screenshot" and "logout")
  • id - function id, used to distinguish multiple requests
  • arg - request parameters, for "screenshot", it is the path to which image file should be saved
Remark
  • Different from other callbacks that get invoked after application calls certain APIs, this callback is initiated by low level modules to application at first.

Notify Low Level Result Of Function Request

Method

void NotifyFuncRequestResult(string func, string id, string result)

Parameters
  • func - function name
  • id - function id
  • result - result of function request (one of "succeeded", "failed" and "cancelled")
Remark
  • This API is used to notify the result of function request to low level modules.