소켓 예제를 읽어 왔지만 JMP에서 할 수 있는 것은 요청 수신을 확인하는 것뿐입니다. 요청의 페이로드나 메시지를 가져올 수 없습니다.비 차단 통신을 달성하기 위해 소켓이나 스케줄러보다 더 좋은 방법이 있습니까?
모든 것이 창에 있습니다.
스크립팅 인덱스: 소켓
JSL을 사용하여 API에서 데이터 가져오기에 대한 자세한 지침
JMP, R 및 Python 스크립트에서 메시지를 가져오고 기록하기 위한 소켓 통신
나는 또한 이것을 이해하지 못합니다 : ((blobdata == Char To Blob( "" )) & (Left(r[2], 11) == "WOULDBLOCK:" ))
r[2]는 무엇입니까? 이러한 것들의 가치는 다른 것들에 대한 색인을 계속 생성합니까? 파이썬에서는 다음과 같은 말을 기대합니다.
아르 자형 = 요청
my_data_dict = r .업데이트({ 'last_jmp_data' :pd.DataFrame(요청.json)})
내 데이터를 검색하기 위해 Python에서 작동하지만 JMP로 다시 전달하려고 할 때 인쇄되는 유일한 것은 헤더이며 내가 보낸 JSON 데이터에 액세스할 수 없습니다. 내 데이터가 일부에 있다고 가정합니다. r[#] 항목?
저는 데이터를 수신할 수 있는 비 차단 기능을 만들려고 합니다. 지금은 스케줄러와 함께 해키 솔루션을 사용하여 워크플로를 만들고 작동하지만 투박합니다.
스케줄러를 사용하여 이 기능을 예약하고 내 플라스크 서버에 도달하고 데이터를 JSON으로 다시 수신하고 기본 테이블을 업데이트합니다. 업데이트로 인해 JMP가 모든 필터를 삭제하므로 문자열에 로그한 다음 사용자가 다시 적용하도록 합니다. 하던 일을 잃지 않습니다.
내가 원하는 것은 javascript에서 요청을 보내고 JMP로 선택할 수 있는 것입니다.
이것은 내 JavaScript 함수입니다. 응답이 필요하지 않습니다. JMP로 이동하기만 하면 됩니다. 이전에는 다른 JavaScript 해결 방법을 사용하여 다운로드에 JSON 파일을 작성하고 스케줄러 루프를 사용하여 테이블을 업데이트할 특정 JSON 파일에 대한 사용자 다운로드 폴더를 확인했습니다.
이 응용 프로그램은 사용자 PC에서 로컬로 실행되고 외부 리소스와 통신하지 않는 단일 사용자 응용 프로그램입니다. 브라우저에서 GUI/특정 데이터 상호 작용을 수행하기만 하면 되었지만 여전히 해당 데이터를 다시 JMP로 가져오고 싶습니다. 내 키메라 JMP/HTML/JS/CS S 애플리케이션.
브라우저에서 Python 서버로 데이터를 보내는 데 사용하는 Javascript 코드
var xhr = new XMLHttpRequest();
xhr.open("POST", 'http://localhost:8088/passdata', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send([my_json_data]);
JMP 스케줄러 루프
//scheduled loop to ping python local server and see if it's time to update:
get_remote_update = Function({},
s = Schedule(.25,
//show("remote update fn");
//check_downloads_folder(); // old routine that was watching download folder
check_downloads_over_ip();
get_remote_update(); //loops by scheduling the event again
);Python 서버에 대한 jmp 호출은 JSON 데이터를 수신하고 필요한 경우 업데이트합니다.
//****************************************************************
//check_downloads_OVER_IP();
//****************************************************************
// EXPLORE THIS dt = Open( Char To Blob( request << Send() ), "JSON" );
// see if we can just get the response back into a table without creating it with the weird JMP thing
check_downloads_over_ip = Function({},
request = New HTTP Request(
URL("localhost:8088/get_update"),
Method("Post"),
Timeout( .5 ),
);
data=request << Send;
if((data != "No Update" > 0) & ( isempty(data) != 1 ),
obj = JSON:Parse( data );
dt = JSON:Make Table(obj);
dt << show window(0);
temp_dtf = CHAR(dtf <<GET script=""></GET>
이해할 수 없는 소켓 스크립트
Names default to here( 1 );
//Table to hold received data
dtLog = New Table( "Log",
New Column( "Time", Numeric, "Continuous", Format( "m/d/y h:m:s", 23, 0 ),
Input Format( "m/d/y h:m:s", 0 ) ),
New Column( "Client", Character, "Nominal" ),
New Column( "Message", Character, "Nominal" )
);
//Wait for and get data from remote machine
receivedata = Function( {c, waittime = 1, waitcount = 10},
//Varaible to store data received from remote machine
blobdata = Char To Blob( "" );
//Make socket is connected
r = c << GetPeerName();
//While receiving data or waiting to receive data
i = 0;
While(
(
(r[2] == "ok") |
((blobdata == Char To Blob( "" )) & (Left(r[2], 11) == "WOULDBLOCK:" ))
) &
(i < waitcount),
i++;
//Get data
r = c << recv( 100000 );
//If no data is received yet, wait
If(Left(r[2], 11) == "WOULDBLOCK:", Wait( waittime ) );
//Write whatever is received to the log
show("writing to log now");
Write( Blob to Char( r[3] ) );
show("Done writing to log now");
//join data to whatever is already received
blobdata = blobdata || r[3];
);
return( blobdata );
);
//Get log info from remote machine, store it in a data table
processlogconnection = function( {c},
//New row in log table
dtLog << Add Rows( 1 );
rowout = N Rows( dtLog );
Column( dtLog, "Time" )[rowout] = Today();
//Get computer name of remote machine
r = c << GetPeerName();
Column( dtLog, "Client" )[rowout] = r[3];
//Get message from the remote machine
Column( dtLog, "Message" )[rowout] = Blob to Char( receivedata( c ) );
//Close the connection
c << Close;
);
//Function to accept conections from remote machine, calls another
//function to handle communication with that machine
callbackfn = function( {x},
//Call another function with the connection returned from the Accept message
If( x[2] == "ok", processlogconnection( x[4] ) );
);
//Create a socket
con = Socket();
//Use a specific port on this computer
con << Bind( "localhost", "8081" );
//Tell this socket to be ready for other sockets to connect to it
Write( "\!nlistening on ", (con << getSockName)[3]);
con << Listen();
//Verify that the connection is active
con << getsockname;
//When something connects to this socket, call a function to handle
//the connection. Accept connections for the next 5 minutes.
con << Accept(callbackfn, 30000);
//Now messages can be sent to this connection.
//When all done, close the connection
//con << close();