Hi so I'm currently working on a way to make a dashboard for my bot. My idea is that I have my website send commands to the bot via sockets though I'm having some trouble.
This is the code that sends the message to my bot (Note this is PHP)
function sendMsg($msg) {
$host = "myIp";
$port = myPort;
$len = strlen($msg);
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");
socket_connect($socket,$host,$port) or die("Could not connect to the socket\n");
socket_sendto($socket, $msg, $len, 0, $host, $port);
}
Basically what it does is that it sends a string to my VPS which the bot is hosted on, then the bot reads it using this code:
on *:SOCKLISTEN:www: {
sockaccept web $+ $ticks
echo -s *** Connection Accepted.
}
on *:SOCKREAD:web*: {
echo -s *** READING MESSAGE
sockread %msg
echo -s MESSAGE: %msg
}
So when I run the PHP code my bot does actually run through the socket events, though it does not fetch the message, it only echoes: MESSAGE: (blank)
NOTE: I have indeed opened up the ports on both ends so it's not a firewall issue
Hope someone out there can help me