---
title: C端开发
description: "如下所示，对于C端开发，需要使用注解@HafCall标记所调用的远端函数。```"
url: https://www.hikunpeng.com/document/detail/zh/kunpengaccel/system-lib/ug-haf/kunpengaccel_haf_06_0054.html
sourcePath: /source/zh/kunpengaccel/system-lib/ug-haf/kunpengaccel_haf_06_0054.html
indexId: cd0b43d6087c600b8cdeda5efcac606fb5188b7600c4b31c45bed212630e104971
---
# C端开发

如下所示，对于C端开发，需要使用注解@HafCall标记所调用的远端函数。```
public class Client {

    private String ip;
    public Client(String ip) {
        this.ip = ip;
    }

    @HafCall(ip = "ip", method = "TestMain.testService", exception = ClientException.class, timeout = "300")
    public void testCSAdd(int a, int b) throws ClientException {
        int res = TestMain.testService(a, b);
        System.out.println(res);
    }
}
```


@HafCall注解支持如下字段：

- ip表示卸载节点IP地址，函数将被下推到指定IP的节点上运行，必填。该注解字段支持一个IP地址或一个类型为String的成员变量名，用户需保证该成员变量的值是一个合法IP地址。
- method表示访问的S端函数，由类名和函数名组成，必填。
- exception表示下推失败抛出的异常，必填。
- timeout表示函数下推运行的超时时间，默认1800s。


CS下推模式，C端和S端都使用FST序列化工具序列化对象，如果存在不可直接序列化的对象，参考3，为C端和S端指定序列化器。

```
public class Client {
    @HafSerializer(clazz = Page.class, serializer = PageSerializer.class)
    @HafCall(ip = "ip", method = "NoMainService.getPageTest", exception = Exception.class)
    public Page getPage() throws Exception {
        Page page = NoMainService.getPageTest();
        return page;
    }
}

public class NoMainService {
    @HafSerializer(clazz = Page.class, serializer = PageSerializer.class)
    @HafService
    public static Page getPageTest() {
        Page page = new Page("testPage", 10);
        System.out.println(page);
        return page;
    }
}
```
