示例:
const headers = {
'Sec-WebSocket-Protocol': 'name=客户端名称'
};
const ws = new WebSocket('ws://example.com/socket', { headers });
对于要求的返回不同字段,对加密websocket,可以有不同的返回值字段。
参考,使用{e12a3dc0
-3a0b-47c4-a8c3-75190a42ae
}包装参数字段,避免重复:
{
"{e12a3dc0-3a0b-47c4-a8c3-75190a42ae68}": {
"account": "6214836668689199",
"confirm": 0,
"encrypt": 1,
"length": 6,
"reserved1": 0,
"reserved2": 0,
"reserved3": "",
"reserved4": "",
"smflag": 0,
"timeout": 0
},
"class": "PinPadService",
"className": "PinPadService",
"entity": "PinPad",
"entityName": "PinPad",
"messageType": 3,
"methodID": 6,
"MethodSignature": -1531281659,
"sessionID": 1818682325,
"signature": -1531281659,
"timeout": 60000,
"transID": 97
}