03 Sonic - 代码初认识

一、agent

 
 

 二、server+web

 2.1、远控和服务端通信(安卓)

  1. ws://localhost:3000/ : 和服务建立的心跳
  2. ws://172.31.13.22:7777/websockets/android/0a6344ee-4b34-418d-b7cb-0ab0b156a9a5/822QEDU5227H3/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsibHJzIiwiYjM5NTFkYmUtOTFhNC00YTg4LWFiMDktNGJlYjUxMzFlMmM4Il0sImV4cCI6MTY1NzI1MTI0M30.cOfb0-YLThxPp8YNirSt2bQ9ExGw6VQCmS4FcRZnKrI/0 :主要发送远控运行脚本请求
    websockets/android :接口地址

    1. 0a6344ee-4b34-418d-b7cb-0ab0b156a9a5 :agent的key,创建agent的时候产生的key
    2. 822QEDU5227H3 : deviceId,设备id
    3. eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsibHJzIiwiYjM5NTFkYmUtOTFhNC00YTg4LWFiMDktNGJlYjUxMzFlMmM4Il0sImV4cCI6MTY1NzI1MTI0M30.cOfb0-YLThxPp8YNirSt2bQ9ExGw6VQCmS4FcRZnKrI :用户token
    4. 0 :第1个ws连接??
  3. ws://172.31.13.22:7777/websockets/android/screen/0a6344ee-4b34-418d-b7cb-0ab0b156a9a5/822QEDU5227H3/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsibHJzIiwiYjM5NTFkYmUtOTFhNC00YTg4LWFiMDktNGJlYjUxMzFlMmM4Il0sImV4cCI6MTY1NzI1MTI0M30.cOfb0-YLThxPp8YNirSt2bQ9ExGw6VQCmS4FcRZnKrI : 远控控制抓屏的返回
    1. websockets/android/screen :抓屏的接口地址
    2. 0a6344ee-4b34-418d-b7cb-0ab0b156a9a5 :agent的key,创建agent的时候产生的key
    3. 822QEDU5227H3 : deviceId,设备id
  4. ws://172.31.13.22:7777/websockets/android/terminal/0a6344ee-4b34-418d-b7cb-0ab0b156a9a5/822QEDU5227H3/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsibHJzIiwiYjM5NTFkYmUtOTFhNC00YTg4LWFiMDktNGJlYjUxMzFlMmM4Il0sImV4cCI6MTY1NzI1MTI0M30.cOfb0-YLThxPp8YNirSt2bQ9ExGw6VQCmS4FcRZnKrI : terminal(终端)控制数据通道
    1. /websockets/android/terminal/ :接口地址
    2. 其余见上

2.2、初始化appium信令 (安卓)

远控走的都是一个ws,用的上边的2讲的那个ws

 

 点击这个按钮会发如下信令

 

==>{
  "type": "debug",
  "detail": "openDriver"
}
<=={
  "msg": "step",
  "des": "连接设备驱动成功",
  "log": "",
  "time": "13:06:51",
  "rid": 0,
  "udId": "822QEDU5227H3",
  "status": 2,
  "cid": 0
}
<=={
  "msg": "step",
  "des": "",
  "log": "设备操作系统:Android<br>操作系统版本:8.1.0<br>设备序列号:822QEDU5227H3<br>设备制造商:Meizu<br>设备型号:M1822<br>安卓API等级:27<br>设备分辨率:1080x2160",
  "time": "13:06:51",
  "rid": 0,
  "udId": "822QEDU5227H3",
  "status": 1,
  "cid": 0
}
<=={
  "msg": "appiumPort",
  "port": 44394
}
<=={
  "msg": "openDriver",
  "detail": "初始化Driver完成!",
  "status": "success"
}

2.3、运行case(安卓)  

==>{
  "type": "debug",
  "detail": "runStep",
  "caseId": 1,
  "pwd": ""
}
<=={
  "msg": "step",
  "des": "打开应用",
  "log": "App包名: com.example.tablayouttest",
  "time": "13:17:00",
  "rid": 0,
  "udId": "822QEDU5227H3",
  "status": 2,
  "cid": 0
}
<=={
  "msg": "step",
  "des": "点击点击 quickstart",
  "log": "点击xpath: //android.widget.Button[@text='QUICKSTART']",
  "time": "13:17:02",
  "rid": 0,
  "udId": "822QEDU5227H3",
  "status": 2,
  "cid": 0
}
<=={
  "msg": "status",
  "des": "",
  "log": "",
  "time": "13:17:02",
  "rid": 0,
  "udId": "822QEDU5227H3",
  "status": 1,
  "cid": 0
}

case执行有错误也是同一个ws返回,可以构造个错误场景测一下。另外,还有其他命令包括 terminal(终端)我就不一一赘述了,大家可以自己测下。

2.4、运控调用了谁?

其实就是要看下这个 ws://172.31.13.22:7777/websockets/android/0a6344ee-4b34-418d-b7cb-0ab0b156a9a5/822QEDU5227H3/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsibHJzIiwiYjM5NTFkYmUtOTFhNC00YTg4LWFiMDktNGJlYjUxMzFlMmM4Il0sImV4cCI6MTY1NzI1MTI0M30.cOfb0-YLThxPp8YNirSt2bQ9ExGw6VQCmS4FcRZnKrI/0 链接了哪里?调用关系如下

调用时序图如下 

其中 runAndroidStep 比较复杂又是异步执行所以单独画了时序

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2022-06-22 19:01  rslai  阅读(200)  评论(0编辑  收藏  举报