完成除数据查询前端功能的EDataCapture开发
This commit is contained in:
@@ -11,7 +11,7 @@ $options = getopt('h::', ['server_name:', 'user:', 'password:', 'help::']);
|
||||
|
||||
init_db($options['server_name'], $options['user'], $options['password']);
|
||||
|
||||
$worker = new Worker('http://0.0.0.0:1818');
|
||||
$worker = new Worker('http://0.0.0.0:8888');
|
||||
$worker -> name = 'CaptureWorker';
|
||||
|
||||
$worker -> onWorkerStart = function(Worker $worker) {
|
||||
@@ -30,9 +30,40 @@ $worker -> onMessage = function(TcpConnection $connection, Request $request) {
|
||||
unset($post['action']);
|
||||
$enode_configure = new ENodeConfigure($dbconn, $post = $post);
|
||||
$res = $enode_configure -> $action();
|
||||
if ($res)
|
||||
$connection -> send(json_encode(array ('code' => 0,
|
||||
'msg' => 'Set threshold success')));
|
||||
if ($res === true)
|
||||
$connection -> send(json_encode(array(
|
||||
'code' => 0,
|
||||
'msg' => 'Success'
|
||||
)));
|
||||
else if ($res === "REPLICATED")
|
||||
$connection -> send(json_encode(array(
|
||||
'code' => 1,
|
||||
'msg' => '节点编码不可重复!'
|
||||
)));
|
||||
else if ($res === false) {
|
||||
$connection -> send(json_encode(array(
|
||||
'code' => 1,
|
||||
'msg' => '服务器内部逻辑错误,请联系开发者!'
|
||||
)));
|
||||
}
|
||||
} else if (isset($post['action']) and str_contains($post['action'], 'data')) {
|
||||
$action = $post['action'];
|
||||
unset($post['action']);
|
||||
$data_capture = new EDataCapture($dbconn, $post = $post);
|
||||
$res = $data_capture -> $action();
|
||||
if ($res === true) {
|
||||
$connection -> send(json_encode(array(
|
||||
'action' => 'result_set_data',
|
||||
'errcode' => 0,
|
||||
'errmsg' => ''
|
||||
)));
|
||||
} else {
|
||||
$connection -> send(json_encode(array(
|
||||
'action' => 'result_set_data',
|
||||
'errcode' => 4002,
|
||||
'errmsg' => 'ROLLBACKed: Bad data received (structure and/or values)'
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
$get = $request -> get();
|
||||
@@ -40,9 +71,15 @@ $worker -> onMessage = function(TcpConnection $connection, Request $request) {
|
||||
$enode_configure = new ENodeConfigure($dbconn, $get = $get);
|
||||
$nodes = $enode_configure -> get_nodes();
|
||||
if (is_null($nodes))
|
||||
$connection -> send(json_encode(array('code' => 1, 'msg' => 'no node data')));
|
||||
$connection -> send(json_encode(array(
|
||||
'code' => 1,
|
||||
'msg' => 'no node data'
|
||||
)));
|
||||
else
|
||||
$connection -> send(json_encode(array('code' => 0, 'data' => $nodes)));
|
||||
$connection -> send(json_encode(array(
|
||||
'code' => 0,
|
||||
'data' => $nodes
|
||||
)));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user