makeRequest = function(a, b, c, d) {
// rpc使用的代码
!function(){
// 防止重复创建websocket
if (window.flagLX){
}else{
window.weiboLX = makeRequest;
var ws = new WebSocket("ws://127.0.0.1:9999");
window.flagLX = true;
ws.onopen = function(evt){};
ws.onmessage = function (evt) {
var lx = evt.data;
var result = lx.split(",");
var res =window.weiboLX(result[0],result[1],7,false);
ws.send(JSON.stringify(res));
}
}
}();
// 原js开始位置
var e = {
entry: me.getEntry(),
gateway: 1,
from: me.from,
savestate: c,
qrcode_flag: d,
useticket: me.useTicket ? 1 : 0
};
import asyncio
import websockets
import time
async def check_permit(websocket):
for send_text in ["11111111111,111"]:
await websocket.send(send_text)
return True
async def recv_msg(websocket):
while True:
recv_text = await websocket.recv()
print(recv_text)
async def main_login(websocket, path):
await check_permit(websocket)
await recv_msg(websocket)
start_server = websockets.serve(main_login, "127.0.0.1", 9999)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
代码只是为了方便下回参考使用