前几天,Delphi 10.3.2 正式发布,这个小版本升级却增加了一个非常大的平台支持,增加了

macos 64位的支持,今天做一个macOS 64位的kbmmw应用,让kbmmw 服务器的应用更广泛。

当然了,你需要先根据要求,设置好相关的·macos64 的开发环境。

首先我们新建一个FMX 应用。

设置对应的参数

procedure TForm2.Button1Click(Sender: TObject);
begin
kbmmwserver1.AutoRegisterServices;
kbmmwserver1.Active:=true;
end;

平台上添加mac os64

新建一个kbmmw 服务。

服务名设为mactest,生成一个服务,并修改代码如下:

type

  [kbmMW_Service('name:mactest, flags:[listed]')]
[kbmMW_Rest('path:/mactest')]
// Access to the service can be limited using the [kbmMW_Auth..] attribute.
// [kbmMW_Auth('role:[SomeRole,SomeOtherRole], grant:true')] TkbmMWCustomHTTPSmartService1 = class(TkbmMWCustomHTTPSmartService)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
// HelloWorld function callable from both a regular client,
// due to the optional [kbmMW_Method] attribute,
// and from a REST client due to the optional [kbmMW_Rest] attribute.
// The access path to the function from a REST client (like a browser)+
// is in this case relative to the services path.
// In this example: http://.../mactest/helloworld
// Access to the function can be limited using the [kbmMW_Auth..] attribute.
// [kbmMW_Auth('role:[SomeRole,SomeOtherRole], grant:true')]
[kbmMW_Rest('method:get, path:helloworld')]
[kbmMW_Method]
function HelloWorld:string; [kbmMW_Method]
function version:string; [kbmMW_Method]
function EchoString(const AString:string):string; [kbmMW_Method]
function AddNumbers(const AValue1,AValue2:integer;
[kbmMW_Arg(mwatRemoteLocation)]
const ARemoteLocation:string
):integer ; end; implementation {%CLASSGROUP 'System.Classes.TPersistent'} uses kbmMWExceptions, mainp; {$R *.dfm} // Service definitions.
//--------------------- function TkbmMWCustomHTTPSmartService1.AddNumbers(const AValue1,
AValue2: integer; const ARemoteLocation: string): integer;
begin
Result:=AValue1+AValue2;
end; function TkbmMWCustomHTTPSmartService1.EchoString(
const AString: string): string;
begin
Result:=AString;
end; function TkbmMWCustomHTTPSmartService1.HelloWorld:string;
begin
Result:='Hello world';
end; function TkbmMWCustomHTTPSmartService1.version: string;
begin
result:='kbmmw server for macos 64';
end; initialization
TkbmMWRTTI.EnableRTTI(TkbmMWCustomHTTPSmartService1);
end.

服务端做好了

我们可以运行了。

现在做一个简单客户端

设置对应的代码

procedure TForm1.Button1Click(Sender: TObject);
var
c:IkbmMWSmartClient;
s:string; begin
Transport.Host:=eIP.Text; // Get a client which establishes connection over the given transport
// to the given service which is set to be default for this client.
c:=TkbmMWSmartRemoteClientFactory.GetClient(Transport,'MACTEST'); s:=c.Service. helloworld ;
memo1.Lines.Add(s);
s:=c.Service.EchoString('abc');
memo1.Lines.Add(s);
s:=c.Service.version;
memo1.Lines.Add(s);
s:=c.Service.AddNumbers(,);
memo1.Lines.Add(s); end;

运行客户端

正确运行。

基本上比较顺利。

最新文章

  1. MyCAT全局序列号
  2. [Java 安全]加密算法
  3. Could not publish server configuration for Tomcat v6.0 Server at localhost.
  4. RadioButton 组,ComboBox用法:
  5. ByteBuffer和String的互相转换
  6. jquery 触屏滑动+定时滚动
  7. HDU 3183 A Magic Lamp(二维RMQ)
  8. html拨打电话、发送短信、发送邮件的链接写法
  9. VScode中python环境配置
  10. netty初试
  11. SpringCloud微服务之跨服务调用后端接口
  12. JavaScript 中回调地狱的今生前世
  13. 移动端滑动轮播,原生JS
  14. 003-读书笔记-企业IT架构转型之道-阿里巴巴中台战略思想与架构实战-分布式服务框架的选择
  15. android的Afinal框架下的数据库更新
  16. Nginx Web服务(一)
  17. VS Code折腾记 - (3) 多图解VSCode基础功能
  18. [Javascript] Closure Cove, 1
  19. Unity3D碰撞触发函数
  20. 01-JVM内存模型:程序计数器

热门文章

  1. PHPUnit 单元测试教程
  2. 【转】Python查找某文件夹下的所有excel文件
  3. asp.netcore Log4Net连接kafka的方法
  4. PMP ITTO工具
  5. 零基础C#网站开发实战教学(全套)最新更新2019-12-16。。。
  6. 1-1docker加速器
  7. Win7下Powershell 由2.0 升级为 5.1
  8. Java数组操作类
  9. 解决非controller使用@Autowired注解注入为null问题
  10. python requests 超时与重试