[mw-devel] MW3 r1376 - in trunk: src/webclient webclient
arthur at sucs.org
arthur at sucs.org
Tue Feb 10 13:27:23 GMT 2015
Author: arthur
Date: 2015-02-10 13:27:23 +0000 (Tue, 10 Feb 2015)
New Revision: 1376
Modified:
trunk/src/webclient/comms.c
trunk/webclient/say.js
trunk/webclient/send.php
Log:
Fix both the cause and effect of the .room command sending an extra bad command
Modified: trunk/src/webclient/comms.c
===================================================================
--- trunk/src/webclient/comms.c 2015-01-17 15:09:57 UTC (rev 1375)
+++ trunk/src/webclient/comms.c 2015-02-10 13:27:23 UTC (rev 1376)
@@ -347,7 +347,18 @@
char buff[8192];
int ret;
- if ((ret = recv(co->fd, buff, sizeof buff, MSG_DONTWAIT))<0) {
+ if ((ret = recv(co->fd, buff, sizeof buff, MSG_DONTWAIT))<=0) {
+
+ if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ // not ready, try again later
+ return 0;
+ }
+
+ if (ret == 0) {
+ // end of the line
+ return 1;
+ }
+
fprintf(stderr, "Error on cmd sock read: %s\n", strerror(errno));
return 1;
}
Modified: trunk/webclient/say.js
===================================================================
--- trunk/webclient/say.js 2015-01-17 15:09:57 UTC (rev 1375)
+++ trunk/webclient/say.js 2015-02-10 13:27:23 UTC (rev 1376)
@@ -248,10 +248,8 @@
if (args == undefined){
$('#textlist').append("<div class='error'>Usage: "+cmd+" <number></div>");
}else{
- $.getJSON("send.php", {send: what});
+ sendCmd('channel '+args);
}
-
- sendCmd('channel '+args);
break;
case "e":
case "em":
@@ -269,8 +267,7 @@
case "whisper":
case "whi":
var what = "sayto "+args;
- $.getJSON("send.php", {send: what});
- if (args == undefined||!args.match(" .* ")){
+ if (args == undefined){
$('#textlist').append("<div class='error'>Usage: "+cmd+" <user> <text></div>");
}else{
$.getJSON("send.php", {send: what});
Modified: trunk/webclient/send.php
===================================================================
--- trunk/webclient/send.php 2015-01-17 15:09:57 UTC (rev 1375)
+++ trunk/webclient/send.php 2015-02-10 13:27:23 UTC (rev 1376)
@@ -15,6 +15,11 @@
header("Content-type: application/json");
+if (!isset($_REQUEST['send'])) {
+ echo "{\"status\":\"Bad command\"}\n";
+ exit;
+}
+
$sock = socket_create(AF_UNIX, SOCK_SEQPACKET, 0);
if (@socket_connect($sock, $path) === FALSE) {
echo "{";
@@ -44,11 +49,6 @@
exit;
}
-if (!isset($_REQUEST['send'])) {
- echo "{\"status\":\"Bad command\"}\n";
- exit;
-}
-
$msg = trim($_REQUEST['send']);
if (@socket_send($sock, $msg, strlen($msg), MSG_EOF)===FALSE) {
More information about the mw-devel
mailing list