/**
* 沟通业务员坐席 执行摘机操作(拨打以及接听操作用)
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function ConnectedToSoft(Request $request){
$user_info = Session::get('user_info');
$ip = $request->getClientIp();
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
//设置接受超时2秒
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec" => 2, "usec" => 0));
socket_connect($socket, $ip, 8888);
//里面的换行代表 \r\n 注意拷贝的代码后面可能有空格
$http = json_encode(array('username' => $user_info['systemPhone'], 'password' => "1111111", 'action' => "answer"));
socket_write($socket, $http, strlen($http));
$strs = "";
while ($str = socket_read($socket, 1024)) {
$strs .= $str;
}
$return_infos = json_decode($strs, true);
if ($return_infos['status'] === "success") {
return \response()->json(array('status'=>"200"));
} else {
return \response()->json(array('status'=>"401"));
}
}