我在socket.io中遇到查询参数问题。
服务器端:
<?php
$runners = [];
// Grab all the .txt files
foreach (glob('src-data/*.txt') as $filename ) {
$handle = fopen($filename, 'r');
if ( $handle ) {
// run line by line through the files
while (( $line = fgets($handle) ) !== false) {
// grab the fields
$clean = preg_split("/ +/", $line);
// All the fields
$position = $clean[1];
$name = $clean[3] . " " . $clean[4];
$time = $clean[5];
$class = $clean[6];
$class_place = $clean[7];
$runners['position'] = $position;
$runners['name'] = $name;
$runners['time'] = $time;
$runners['class'] = $class;
$runners['class place'] = $class_place;
$runners[] = $clean;
}
print_r($runners);
// write to json file
$jsonwrite = fopen('runners.json', 'w');
fwrite($jsonwrite, json_encode($runners));
fclose($jsonwrite);
fclose($handle);
} else {
echo "Error opening file";
}
}
?>
客户方:
var io = require('socket.io')(server);
io.of('/1').on('connection', function(socket){
console.log(socket.request._query['test']);
});
io.of('/2').on('connection', function(socket){
console.log(socket.request._query['test']);
});
io.of('/3').on('connection', function(socket){
console.log(socket.request._query['test']);
});
打印:
io('/1', {
query: 'test=1'
});
io('/2', {
query: 'test=2'
});
io('/3', {
query: 'test=3'
});
而不是:
1
1
1
其余的只是一个默认的快速脚手架。
为什么查询参数总是1?
感谢。
答案 0 :(得分:0)
library("mailR")
sender <- "sender@gmail.com"
bcc<- c("BCC Recipient <bcc1@gmail.com.tr>","BCC Recipient<bcc2@gmail.com.tr>")
send.mail(from = sender,
bcc = c("BCC Recipient <bcc1@gmail.com.tr>","BCC Recipient<bcc2@gmail.com.tr>"),
subject = "subject",
body = "BODY",
authenticate=TRUE,
smtp = list(host.name = "smtp.gmail.com", port = 465,
user.name = "YOURUSERNAME@gmail.com",
passwd = "YOURPASSWORD", ssl = TRUE),
send = TRUE,
attach.files = c("C:/Users/admin/Desktop/Forecast.csv"),
file.names = c("Demand_Forecast.csv"))