Unified in-app VPN SDK's for Microsoft Windows Vista+, Android 4.4+ and Mac OS 10.7+. Earlier OS versions can be supported as well by request. Please contact [email protected] to receive your own API key.

Copyright © 2019 VPNWholesaler.com. All rights reserved.

Back

3.14 setIOCount setIOCount Android Example

I. Providing JSON as a parameter:

VPNSDK.CmdProc("{\"cmd\": 15, \"data\": {\"status\": true}}");

Result of this command will be returned using onNotify method provided on initialization

II. Convenient form:

VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
        @Override
        public void onNotify(int notification, int error, Object data) {
            if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
                // Do something when command is successful
            } else {
                // Process error
            }
        }
    };
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_SET_IOCOUNT, callback, true);

This form of method accepts following parameters:

  1. Command code
  2. Callback to be invoked after command execution
  3. IO Counter status (boolean)

data parameter of callback will be null. Result could be determined based on error parameter of callback.

When IO Counter is enabled SDK will be constantly invoking handler provided upon initialization with notification code equal to VPNSDK.OVS_NOTIFY_CODES.OVS_NOTIFY_IOCOUNT. And data parameter will contain following structure:

{
    "data_in": 0,
    "speed_in": 0,
    "data_out": 0,
    "speed_out": 0
}

It's possible to use the following code to handle it:

@Override
public void onNotify(int notification, int error, Object data) {
    switch (notification) {
        case VPNSDK.OVS_NOTIFY_CODES.OVS_NOTIFY_IOCOUNT: {
            Map<String, Long> map = (Map)data;
            long BytesIn = data.get("data_in");
            long BytesOut = data.get("data_out");
            //Do something with IO counters
        }
    }
}