Okay, i think i've wrote it tooooooooo complicated.
My problem is the following:
If Core1 connects to the realmport and sending some commands to Core2, the realmd should change the active socket-session-number to the right one from Core2.
Like Core1 -send to> Core2.
Both Cores loged in as Client and they are sending, the clients(cores) stayed loged in and the connections weren't closed until the server is shutting down.
Thats the Handler for setting the connection_ ID's...
void CSYHandler::SetServerID(uint32 socketID, const char * ServerName)
{
ServerMap& servermap = m_scmap[serverName];
servermap.server_ID = socketID;
servermap.servername = ServerName;
sLog.outString ("CSY: STORED %d : %s in the CoreMap\\n", socketID, servermap.servername.c_str ());
}
...
Thats in the mainroutine for firing up the listenPort:
I've added it in the main.cpp under the AuthSocket (thats the best place i thought)
///- Launch the Service network socket
port_t csport = sConfig.GetIntDefault( "CSYPort", DEFAULT_CASSY_PORT );
std::string csbind_ip = sConfig.GetStringDefault("CSYBindIP", "0.0.0.0");
SocketHandler p;
ListenSocket<Cassy> CassyListenSocket(p);
if ( CassyListenSocket.Bind (csbind_ip.c_str(),csport))
{
sLog.outError( "Cassy can not bind to %s:%d",csbind_ip.c_str(), csport );
return 1;
}
sLog.outString ("CSY: Startet on %s : %d\\n",csbind_ip.c_str(),csport);
p.Add(&CassyListenSocket);
...
/// The Main Routine It's an modded RaConsole
void Cassy::OnRead()
{
TcpSocket::OnRead();
unsigned int sz=ibuf.GetLength();
if(iInputLength+sz>=RA_BUFF_SIZE)
{
sLog.outRALog("Input buffer overflow, possible DOS attack.\\n");
SetCloseAndDelete();
return;
}
char *inp = new char [sz+1];
ibuf.Read(inp,sz);
/// \\todo Can somebody explain this 'Linux bugfix'?
/* if(stage==MAIN)
if(sz>4) //linux remote telnet
if(memcmp(inp ,"USER ",5))
{
delete [] inp;return;
printf("lin bugfix");
} //linux bugfix
*/
///- Discard data after line break or line feed
bool gotenter=false;
unsigned int y=0;
for(;y<sz;y++)
if(inp[y]=='\\r'||inp[y]=='\\n')
{
gotenter=true;
break;
}
//No buffer overflow (checked above)
memcpy(&buff[iInputLength],inp,y);
iInputLength+=y;
delete [] inp;
if(gotenter)
{
buff[iInputLength]=0;
iInputLength=0;
sLog.outString ("CSY: %s\\n",buff);
uint32 sessionID=GetSocket();
switch(stage)
{
// Please note, this is the main login routine, every core have to check (denk drann du brauchst ne zweite Datenbank zum gegencheck, danke )
case LOGIN:
if(!memcmp(buff,"I am ",5))
{
std::string ss=GetRemoteAddress();
corename=&buff[5];
Sendf ("Welcome %s:%s\\r\\n",ss.c_str(), corename.c_str());
csyhandler.SetServerID (sessionID, corename.c_str());
stage=MAIN;
}
break;
case MAIN:
if(!memcmp(buff,"I've got a command for ",23))
{
corename=&buff[23];
if (!memcmp(corename.c_str(),"you",3))
{
stage=CMD;
break;
}
csyhandler.SetListenClient(sessionID, corename.c_str ());
stage=ROUTE;
}
break;
/***************************************************/
/*** Handle the SubCommands for the Realmmanager ***/
/***************************************************/
case CMD:
sLog.outString("CSY:Command in process...\\n");
if(!memcmp(buff,"Get Ping.",9))
{
PingBack();
stage=MAIN;
}
...
I hope now someone can help me now :huh:
Otherwise I have to write the PoolManager in VB6 (it would take one hour), than the whole system would work without any service port at the realmd. And without any Linux support (sry).
But this port is essentially for my CoreSystem, cause it'll the mastersystem for syncing my cores... :cool:
Greetz GiR-Booksized