Simply put, whenever I attempt to make a server with a TCP object it fails.
Client ones, which connect to servers are fine.
One can plainly see the stuffload of echoes I have everywhere, but they rarely give me any useful information.
new TCPObject(lugsTCPServ);
function lugsTCPServ::onConnectRequest(%this, %ip, %socket)
{
if(isObject(%this.connection[%ip]))
{
echo(%this.getName() @ ": Got duplicate connection from" SPC %ip);
%this.connection[%ip].disconnect();
%this.connection[%ip].delete();
}
echo(%this.getName() @ ": Creating connection to" SPC %ip);
%this.connection[%ip] = new TCPobject("Client", %socket) { class = lugsTCPServ; parent = %this;};
}
function lugsTCPServ::onConnected(%this)
{
echo("SRVR:Connected");
}
function lugsTCPServ::onConnectFailed(%this)
{
echo("SRVR:Connection Failed");
}
function lugsTCPServ::onDisconnect(%this)
{
echo("SRVR:Disconnected");
}
function lugsTCPServ::onLine(%this, %line)
{
echo(%this);
echo(%line);
%mode = getword(%line, 0);
echo(%mode);
%msg = strReplace(%line, getword(%line, 0), "");
echo(%msg);
switch$(%mode)
{
case "CHAT:":
echo("SRVR:CHAT:" SPC %msg);
case "WARNMSG":
warn("SRVR:WARN:" SPC %msg);
default:
echo("SRVR:Message received, unknown mode:" SPC %line);
}
return;
}
lugsTCPServ.listen(8675);
solved: i needed to get onLine from "client" in the code.
see the part where there's "lugTCPServ::onLine"?
That needs to be Client::onLine, using the ambiguous (therefore poorly chosen) names above.