ChatServer.cpp 94 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441
  1. #include "ChatServer.h"
  2. #include <iostream>
  3. #include <Globals.h>
  4. #ifndef WIN32
  5. #include <unistd.h>
  6. #define Sleep( x ) usleep( (x) * 1000 )
  7. #endif
  8. // Inhalt der ChatServer Klasse aus ChatServer.h
  9. // Konstruktor
  10. ChatServer::ChatServer( InitDatei *zIni )
  11. : Thread()
  12. {
  13. Network::Start( 100 );
  14. std::cout << "CS: Verbindung mit Datenbank wird hergestellt...\n";
  15. db = new CSDatenbank( zIni );
  16. klientAnzahl = 0;
  17. klients = new RCArray< CSKlient >();
  18. empfangen = 0;
  19. gesendet = 0;
  20. fehler = new Text();
  21. ini = zIni->getThis();
  22. if( !db->serverAnmelden( zIni ) )
  23. {
  24. std::cout << "CS: Der Server konnte nicht in die Datenbank eingetragen werden:\n";
  25. Text *txt = db->getLetzterFehler();
  26. std::cout << txt->getText() << "\nDas Programm wird beendet.";
  27. txt->release();
  28. exit( 1 );
  29. }
  30. id = *zIni->zWert( "ServerId" );
  31. server = new Server();
  32. aServer = new Server();
  33. std::cout << "CS: Starten des Admin Servers...\n";
  34. if( !aServer->verbinde( (unsigned short)db->getAdminPort( id ), 10 ) )
  35. {
  36. std::cout << "CS: Der Admin Server konnte nicht gestartet werden. Das Programm wird beendet.\n";
  37. exit( 1 );
  38. }
  39. db->setServerStatus( id, 2 );
  40. end = 0;
  41. nichtPausiert = 0;
  42. InitializeCriticalSection( &cs );
  43. ref = 1;
  44. if( zIni->zWert( "Aktiv" )->istGleich( "TRUE" ) )
  45. {
  46. serverStarten();
  47. serverFortsetzen();
  48. }
  49. ref = 1;
  50. }
  51. // Destruktor
  52. ChatServer::~ChatServer()
  53. {
  54. fehler->release();
  55. server->trenne();
  56. server->release();
  57. aServer->trenne();
  58. aServer->release();
  59. ini->release();
  60. db->release();
  61. DeleteCriticalSection( &cs );
  62. if( klients )
  63. klients->release();
  64. }
  65. // nicht constant
  66. void ChatServer::runn()
  67. {
  68. while( !end )
  69. {
  70. SKlient *klient;
  71. klient = aServer->getKlient();
  72. if( end && klient )
  73. {
  74. klient->trenne();
  75. klient = klient->release();
  76. Sleep( 1000 );
  77. return;
  78. }
  79. if( !klient )
  80. return;
  81. CSAKlient *clHandle = new CSAKlient( klient, getThis() );
  82. clHandle->start();
  83. }
  84. }
  85. void ChatServer::thread()
  86. {
  87. while( 1 )
  88. {
  89. SKlient *klient;
  90. klient = server->getKlient();
  91. if( !klient )
  92. break;
  93. Framework::getThreadRegister()->cleanUpClosedThreads();
  94. CSKlient *clHandle = new CSKlient( klient, getThis() );
  95. EnterCriticalSection( &cs );
  96. klients->set( clHandle, klientAnzahl );
  97. klientAnzahl++;
  98. LeaveCriticalSection( &cs );
  99. clHandle->start();
  100. }
  101. }
  102. void ChatServer::close()
  103. {
  104. db->setServerStatus( id, 1 );
  105. server->trenne();
  106. #ifdef WIN32
  107. warteAufThread( 1000 );
  108. #endif
  109. EnterCriticalSection( &cs );
  110. for( int i = 0; i < klientAnzahl; i++ )
  111. klients->z( i )->absturz();
  112. klients = klients->release();
  113. klientAnzahl = 0;
  114. LeaveCriticalSection( &cs );
  115. ende();
  116. run = 0;
  117. end = 1;
  118. Klient *klient = new Klient();
  119. klient->verbinde( aServer->getPort(), "127.0.0.1" );
  120. Sleep( 500 );
  121. aServer->trenne();
  122. klient->release();
  123. }
  124. bool ChatServer::serverStarten()
  125. {
  126. if( nichtPausiert )
  127. {
  128. fehler->setText( "Der Server konnte nicht gestartet werden: Der Server läuft bereits." );
  129. return 0;
  130. }
  131. if( server )
  132. server->release();
  133. server = new Server();
  134. if( server->verbinde( (unsigned short)TextZuInt( ini->zWert( "ServerPort" )->getText(), 10 ), 10 ) )
  135. {
  136. nichtPausiert = 1;
  137. start();
  138. return 1;
  139. }
  140. else
  141. {
  142. serverBeenden();
  143. fehler->setText( "Der Server konnte nicht gestartet werden: Eventuell ist der Port in benutzung." );
  144. return 0;
  145. }
  146. }
  147. bool ChatServer::serverPause()
  148. {
  149. if( !nichtPausiert )
  150. {
  151. fehler->setText( "Der Server konnte nicht pausiert werden: Der Server läuft nicht." );
  152. return 0;
  153. }
  154. if( !db->setServerStatus( id, 2 ) )
  155. {
  156. fehler->setText( "Der Server konnte nicht pausiert werden: " );
  157. fehler->append( db->getLetzterFehler() );
  158. return 0;
  159. }
  160. return 1;
  161. }
  162. bool ChatServer::serverFortsetzen()
  163. {
  164. if( !nichtPausiert )
  165. {
  166. fehler->setText( "Der Server konnte nicht fortgesetzt werden: Der Server läuft nicht." );
  167. return 0;
  168. }
  169. if( !db->setServerStatus( id, 3 ) )
  170. {
  171. fehler->setText( "Der Server konnte nicht fortgesetzt werden: " );
  172. fehler->append( db->getLetzterFehler() );
  173. return 0;
  174. }
  175. return 1;
  176. }
  177. bool ChatServer::serverBeenden()
  178. {
  179. if( !nichtPausiert )
  180. {
  181. fehler->setText( "Der Server konnte nicht beendet werden: Der Server läuft nicht." );
  182. return 0;
  183. }
  184. if( db->serverIstNichtPausiert( id ) )
  185. {
  186. fehler->setText( "Der Server konnte nicht beendet werden: Der Server muss erst pausiert werden." );
  187. return 0;
  188. }
  189. nichtPausiert = 0;
  190. ende();
  191. if( server )
  192. server->trenne();
  193. return 1;
  194. }
  195. bool ChatServer::setMaxKlients( int mc )
  196. {
  197. if( !db->setMaxClients( id, mc ) )
  198. {
  199. fehler->setText( "Die maximale Anzahl der Clients konnte nicht gesetzt werden:\n" );
  200. fehler->append( db->getLetzterFehler() );
  201. return 0;
  202. }
  203. ini->setWert( "MaxClients", Text() += mc );
  204. return 1;
  205. }
  206. bool ChatServer::absturzKlient( int klientId )
  207. {
  208. bool gefunden = 0;
  209. EnterCriticalSection( &cs );
  210. for( int i = 0; i < klientAnzahl; i++ )
  211. {
  212. if( klients->z( i )->getKlientNummer() == klientId )
  213. {
  214. klients->z( i )->absturz();
  215. klients->remove( i );
  216. klientAnzahl--;
  217. gefunden = 1;
  218. i--;
  219. }
  220. }
  221. LeaveCriticalSection( &cs );
  222. return gefunden;
  223. }
  224. bool ChatServer::removeAccount( int accId )
  225. {
  226. bool gefunden = 0;
  227. EnterCriticalSection( &cs );
  228. for( int i = 0; i < klientAnzahl; i++ )
  229. {
  230. if( klients->z( i )->getAccountId() == accId )
  231. {
  232. klients->remove( i );
  233. klientAnzahl--;
  234. gefunden = 1;
  235. i--;
  236. }
  237. }
  238. LeaveCriticalSection( &cs );
  239. return gefunden;
  240. }
  241. bool ChatServer::removeKlient( int klientId )
  242. {
  243. bool gefunden = 0;
  244. EnterCriticalSection( &cs );
  245. for( int i = 0; i < klientAnzahl; i++ )
  246. {
  247. if( klients->z( i )->getKlientNummer() == klientId )
  248. {
  249. klients->z( i )->trenne();
  250. klients->remove( i );
  251. klientAnzahl--;
  252. gefunden = 1;
  253. i--;
  254. }
  255. }
  256. LeaveCriticalSection( &cs );
  257. return gefunden;
  258. }
  259. bool ChatServer::removeKlient( CSKlient *zKlient )
  260. {
  261. bool gefunden = 0;
  262. EnterCriticalSection( &cs );
  263. for( int i = 0; i < klientAnzahl; i++ )
  264. {
  265. if( klients->z( i ) == zKlient )
  266. {
  267. klients->z( i )->trenne();
  268. klients->remove( i );
  269. klientAnzahl--;
  270. gefunden = 1;
  271. break;
  272. }
  273. }
  274. LeaveCriticalSection( &cs );
  275. return gefunden;
  276. }
  277. void ChatServer::addGesendet( int bytes )
  278. {
  279. gesendet += bytes;
  280. }
  281. void ChatServer::addEmpfangen( int bytes )
  282. {
  283. empfangen += bytes;
  284. }
  285. int ChatServer::getKlientStatus( int klientNummer, CSKlient *zKlient )
  286. {
  287. bool empf = 0;
  288. bool send = 0;
  289. EnterCriticalSection( &cs );
  290. for( int i = 0; i < klientAnzahl; i++ )
  291. {
  292. if( klients->z( i )->getKlientNummer() == klientNummer && klients->z( i ) != zKlient )
  293. {
  294. if( klients->z( i )->istEmpfang() )
  295. empf = 1;
  296. else
  297. send = 1;
  298. }
  299. }
  300. LeaveCriticalSection( &cs );
  301. if( !empf )
  302. return 0;
  303. if( !send )
  304. return 1;
  305. return 2;
  306. }
  307. CSKlient *ChatServer::zSendeKlient( int accountId )
  308. {
  309. CSKlient *ret = 0;
  310. EnterCriticalSection( &cs );
  311. for( int i = 0; i < klientAnzahl; i++ )
  312. {
  313. if( klients->z( i )->getAccountId() == accountId && !klients->z( i )->istEmpfang() )
  314. {
  315. ret = klients->z( i );
  316. break;
  317. }
  318. }
  319. LeaveCriticalSection( &cs );
  320. return ret;
  321. }
  322. // constant
  323. bool ChatServer::istAn() const
  324. {
  325. return db->serverIstNichtPausiert( id );
  326. }
  327. Server *ChatServer::zServer() const
  328. {
  329. return server;
  330. }
  331. CSDatenbank *ChatServer::zDB() const
  332. {
  333. return db;
  334. }
  335. bool ChatServer::hatClients() const
  336. {
  337. return klientAnzahl > 0;
  338. }
  339. int ChatServer::getId() const
  340. {
  341. return id;
  342. }
  343. char *ChatServer::getLetzterFehler() const
  344. {
  345. return fehler->getText();
  346. }
  347. // Reference Counting
  348. ChatServer *ChatServer::getThis()
  349. {
  350. ref++;
  351. return this;
  352. }
  353. ChatServer *ChatServer::release()
  354. {
  355. ref--;
  356. if( !ref )
  357. delete this;
  358. return 0;
  359. }
  360. // Inhalt der CSAKlient Klasse aus ChatServer.h
  361. // Konstruktor
  362. CSAKlient::CSAKlient( SKlient *klient, ChatServer *cs )
  363. : Thread()
  364. {
  365. this->klient = klient;
  366. unsigned char key[ 20 ] = { 51, 206, 196, 230, 31, 97, 186, 90, 5, 0, 166, 28, 40, 141, 16, 55, 36, 181, 203, 236 };
  367. klient->setSendeKey( (char*)key, 20 );
  368. klient->setEmpfangKey( (char*)key, 20 );
  369. name = new Text( "" );
  370. passwort = new Text( "" );
  371. adminId = 0;
  372. this->cs = cs;
  373. }
  374. // Destruktor
  375. CSAKlient::~CSAKlient()
  376. {
  377. klient->trenne();
  378. klient->release();
  379. cs->release();
  380. name->release();
  381. passwort->release();
  382. }
  383. // nicht constant
  384. void CSAKlient::thread()
  385. {
  386. while( 1 )
  387. {
  388. char c = 0;
  389. if( !klient->getNachrichtEncrypted( &c, 1 ) )
  390. break;
  391. else
  392. {
  393. bool br = 0;
  394. switch( c )
  395. {
  396. case 1: // Login
  397. if( 1 )
  398. {
  399. klient->sendeEncrypted( "\1", 1 );
  400. char nLen = 0;
  401. klient->getNachrichtEncrypted( &nLen, 1 );
  402. char *n = new char[ nLen + 1 ];
  403. n[ (int)nLen ] = 0;
  404. if( nLen )
  405. klient->getNachrichtEncrypted( n, nLen );
  406. char pLen = 0;
  407. klient->getNachrichtEncrypted( &pLen, 1 );
  408. char *p = new char[ pLen + 1 ];
  409. p[ (int)pLen ] = 0;
  410. if( pLen )
  411. klient->getNachrichtEncrypted( p, pLen );
  412. int adminId = cs->zDB()->istAdministrator( n, p );
  413. if( adminId )
  414. {
  415. klient->sendeEncrypted( "\1", 1 );
  416. name->setText( n );
  417. passwort->setText( p );
  418. this->adminId = adminId;
  419. }
  420. else
  421. errorZuKlient( "Falsche Kombination aus Name und Passwort." );
  422. delete[] n;
  423. delete[] p;
  424. }
  425. break;
  426. case 2: // Logout
  427. adminId = 0;
  428. name->setText( "" );
  429. passwort->setText( "" );
  430. klient->sendeEncrypted( "\1", 1 );
  431. break;
  432. case 3: // Trennen
  433. br = 1;
  434. klient->sendeEncrypted( "\1", 1 );
  435. break;
  436. case 4: // Server starten
  437. if( !adminId )
  438. errorZuKlient( "Du musst dich einloggen." );
  439. else
  440. {
  441. if( cs->zDB()->adminHatRecht( adminId, Admin_Recht::CSStarten ) )
  442. {
  443. if( !cs->serverStarten() )
  444. {
  445. Text *err = new Text();
  446. err->append( cs->getLetzterFehler() );
  447. errorZuKlient( err->getText() );
  448. err->release();
  449. }
  450. else
  451. klient->sendeEncrypted( "\1", 1 );
  452. }
  453. else
  454. errorZuKlient( "Du bist nicht berechtigt den Server zu starten." );
  455. }
  456. break;
  457. case 5: // Server beenden
  458. if( !adminId )
  459. errorZuKlient( "Du musst dich einloggen." );
  460. else
  461. {
  462. if( cs->zDB()->adminHatRecht( adminId, Admin_Recht::CSBeenden ) )
  463. {
  464. if( cs->serverBeenden() )
  465. klient->sendeEncrypted( "\1", 1 );
  466. else
  467. {
  468. Text *err = new Text();
  469. err->append( cs->getLetzterFehler() );
  470. errorZuKlient( err->getText() );
  471. err->release();
  472. }
  473. }
  474. else
  475. errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
  476. }
  477. break;
  478. case 6: // Programm Schließen
  479. if( !adminId )
  480. errorZuKlient( "Du musst dich einloggen." );
  481. else
  482. {
  483. bool ok = 0;
  484. if( cs->isRunning() )
  485. {
  486. if( cs->zDB()->adminHatRecht( adminId, Admin_Recht::CSBeenden ) )
  487. {
  488. if( cs->serverBeenden() )
  489. ok = 1;
  490. else
  491. {
  492. Text *err = new Text();
  493. err->append( cs->getLetzterFehler() );
  494. errorZuKlient( err->getText() );
  495. err->release();
  496. }
  497. }
  498. else
  499. errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
  500. }
  501. else
  502. ok = 1;
  503. if( ok && cs->hatClients() )
  504. {
  505. errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
  506. break;
  507. }
  508. if( ok )
  509. {
  510. klient->sendeEncrypted( "\1", 1 );
  511. std::cout << "CS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
  512. cs->close();
  513. br = 1;
  514. }
  515. }
  516. break;
  517. case 7: // Progtamm abstürzen
  518. if( !adminId )
  519. errorZuKlient( "Du musst dich einloggen." );
  520. else
  521. {
  522. bool ok = 0;
  523. if( cs->isRunning() )
  524. {
  525. if( cs->zDB()->adminHatRecht( adminId, Admin_Recht::CSBeenden ) )
  526. {
  527. cs->serverBeenden();
  528. ok = 1;
  529. }
  530. else
  531. errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
  532. }
  533. else
  534. ok = 1;
  535. if( ok )
  536. {
  537. klient->sendeEncrypted( "\1", 1 );
  538. std::cout << "CS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
  539. cs->close();
  540. br = 1;
  541. }
  542. }
  543. break;
  544. case 8: // Status Frage
  545. if( 1 )
  546. {
  547. char status = 0;
  548. if( cs->isRunning() )
  549. {
  550. status = 1;
  551. if( cs->istAn() )
  552. status = 2;
  553. }
  554. klient->sendeEncrypted( "\1", 1 );
  555. klient->sendeEncrypted( &status, 1 );
  556. }
  557. break;
  558. case 9: // Server pausieren
  559. if( !adminId )
  560. errorZuKlient( "Du musst dich einloggen." );
  561. else
  562. {
  563. klient->sendeEncrypted( "\1", 1 );
  564. char pause = 0;
  565. klient->getNachrichtEncrypted( &pause, 1 );
  566. if( cs->zDB()->adminHatRecht( adminId, Admin_Recht::CSPausieren ) )
  567. {
  568. bool ok = 0;
  569. if( pause )
  570. ok = cs->serverPause();
  571. else
  572. ok = cs->serverFortsetzen();
  573. if( ok )
  574. klient->sendeEncrypted( "\1", 1 );
  575. else
  576. {
  577. Text *err = new Text();
  578. err->append( cs->getLetzterFehler() );
  579. errorZuKlient( err->getText() );
  580. err->release();
  581. }
  582. }
  583. else
  584. {
  585. if( pause )
  586. errorZuKlient( "Du bist nicht berechtigt den Server zu pausieren." );
  587. else
  588. errorZuKlient( "Du bist nicht berechtigt den Server fortzusetzen." );
  589. }
  590. }
  591. break;
  592. case 0xA: // maximale Anzahl der Clients setzen
  593. if( !adminId )
  594. errorZuKlient( "Du musst dich einloggen." );
  595. else
  596. {
  597. klient->sendeEncrypted( "\1", 1 );
  598. int maxC = 0;
  599. klient->getNachrichtEncrypted( (char*)&maxC, 4 );
  600. if( cs->zDB()->adminHatRecht( adminId, Admin_Recht::CSMCChange ) )
  601. {
  602. if( cs->setMaxKlients( maxC ) )
  603. klient->sendeEncrypted( "\1", 1 );
  604. else
  605. {
  606. Text *err = new Text();
  607. err->append( cs->getLetzterFehler() );
  608. errorZuKlient( err->getText() );
  609. err->release();
  610. }
  611. }
  612. else
  613. errorZuKlient( "Du bist nicht berechtigt die maximale Anzahl der Clients zu verändern." );
  614. }
  615. break;
  616. case 0xC: // klient absturtz
  617. if( 1 )
  618. {
  619. klient->sendeEncrypted( "\1", 1 );
  620. int klientId = 0;
  621. klient->getNachrichtEncrypted( (char*)&klientId, 4 );
  622. if( klientId && cs->absturzKlient( klientId ) )
  623. klient->sendeEncrypted( "\1", 1 );
  624. else
  625. klient->sendeEncrypted( "\0", 1 );
  626. }
  627. break;
  628. default:
  629. errorZuKlient( "Unbekannte Nachricht!" );
  630. break;
  631. }
  632. if( br )
  633. break;
  634. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  635. cs->addGesendet( klient->getUploadBytes( 1 ) );
  636. }
  637. }
  638. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  639. cs->addGesendet( klient->getUploadBytes( 1 ) );
  640. delete this;
  641. }
  642. void CSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
  643. {
  644. klient->sendeEncrypted( "\3", 1 );
  645. char len = (char)textLength( nachricht );
  646. klient->sendeEncrypted( &len, 1 );
  647. klient->sendeEncrypted( nachricht, len );
  648. }
  649. // Inhalt der CSKlient aus ChatServer.h
  650. // Konstruktor
  651. CSKlient::CSKlient( SKlient *klient, ChatServer *cs )
  652. : Thread()
  653. {
  654. this->klient = klient;
  655. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  656. klient->setSendeKey( (char*)key, 20 );
  657. klient->setEmpfangKey( (char*)key, 20 );
  658. klientNummer = 0;
  659. this->cs = cs;
  660. accountId = 0;
  661. empfangen = 1;
  662. InitializeCriticalSection( &ts );
  663. ref = 1;
  664. }
  665. // Destruktor
  666. CSKlient::~CSKlient()
  667. {
  668. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  669. cs->addGesendet( klient->getUploadBytes( 1 ) );
  670. klient->release();
  671. cs->release();
  672. DeleteCriticalSection( &ts );
  673. }
  674. // nicht constant
  675. void CSKlient::lock()
  676. {
  677. EnterCriticalSection( &ts );
  678. }
  679. void CSKlient::unlock()
  680. {
  681. LeaveCriticalSection( &ts );
  682. }
  683. void CSKlient::absturz()
  684. {
  685. #ifdef WIN32
  686. if( GetCurrentThreadId() != GetThreadId( getThreadHandle() ) )
  687. ende();
  688. #else
  689. ende();
  690. #endif
  691. klient->trenne();
  692. if( empfangen )
  693. {
  694. cs->zDB()->unregisterKlient( klientNummer, cs->getId() );
  695. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  696. weiter->accountOffline( accountId );
  697. delete weiter;
  698. }
  699. }
  700. void CSKlient::thread()
  701. {
  702. int unbekannt = 0;
  703. while( 1 )
  704. {
  705. char c = 0;
  706. if( !klient->getNachrichtEncrypted( &c, 1 ) )
  707. break;
  708. else
  709. {
  710. bool br = 0;
  711. switch( c )
  712. {
  713. case 1: // Klient identifikation
  714. klient->getNachrichtEncrypted( (char*)&klientNummer, 4 );
  715. if( !cs->zDB()->proveKlient( klientNummer, cs->getId() ) )
  716. {
  717. klientNummer = 0;
  718. errorZuKlient( "Du bist nicht für diesen Server eingetragen" );
  719. }
  720. if( klientNummer )
  721. {
  722. accountId = cs->zDB()->getKlientAccountId( klientNummer );
  723. if( !accountId )
  724. {
  725. errorZuKlient( "Du bist nicht online" );
  726. klientNummer = 0;
  727. }
  728. else
  729. {
  730. int status = cs->getKlientStatus( klientNummer, this );
  731. if( status == 2 )
  732. {
  733. klientNummer = 0;
  734. accountId = 0;
  735. errorZuKlient( "Diese Klient Nummer ist bereits verbunden" );
  736. }
  737. else
  738. {
  739. Text *key = cs->zDB()->getKlientKey( klientNummer );
  740. if( !key )
  741. errorZuKlient( "Es konnte kein Schlüssel ermittelt werden." );
  742. else
  743. {
  744. klient->sendeEncrypted( "\1", 1 );
  745. klient->setEmpfangKey( *key, key->getLength() );
  746. klient->setSendeKey( *key, key->getLength() );
  747. key->release();
  748. if( status == 1 )
  749. {
  750. empfangen = 0;
  751. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  752. weiter->accountOnline( accountId );
  753. delete weiter;
  754. br = 1;
  755. }
  756. }
  757. }
  758. }
  759. }
  760. break;
  761. case 2: // Main / Erhaltung Server message
  762. if( 1 )
  763. {
  764. char befehl = 0;
  765. klient->getNachrichtEncrypted( &befehl, 1 );
  766. switch( befehl )
  767. {
  768. case 2: // klient absturtz
  769. if( 1 )
  770. {
  771. int klientId = 0;
  772. klient->getNachrichtEncrypted( (char*)&klientId, 4 );
  773. if( klientId && cs->absturzKlient( klientId ) )
  774. klient->sendeEncrypted( "\1", 1 );
  775. else
  776. klient->sendeEncrypted( "\0", 1 );
  777. }
  778. break;
  779. default:
  780. errorZuKlient( "Befehl nicht bekannt!" );
  781. break;
  782. }
  783. }
  784. break;
  785. case 3: // Verbindungsende
  786. if( 1 )
  787. {
  788. lock();
  789. klient->sendeEncrypted( "\1", 1 );
  790. unlock();
  791. br = 1;
  792. }
  793. break;
  794. case 4: // unregister Klient
  795. if( !klientNummer )
  796. {
  797. klient->sendeEncrypted( "\0", 1 );
  798. CSKlient *c = cs->zSendeKlient( accountId );
  799. if( c )
  800. c->errorZuKlient( "Du bist nicht Identifiziert." );
  801. break;
  802. }
  803. cs->zDB()->unregisterKlient( klientNummer, cs->getId() );
  804. klient->sendeEncrypted( "\1", 1 );
  805. break;
  806. case 5: // Server message
  807. if( 1 )
  808. {
  809. char byte = 0;
  810. char res = 1;
  811. klient->getNachrichtEncrypted( &byte, 1 );
  812. switch( byte )
  813. {
  814. case 1: // kick Klient
  815. if( 1 )
  816. {
  817. klient->sendeEncrypted( "\1", 1 );
  818. int id = 0;
  819. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&id, 4 ) );
  820. CSKlient *c = cs->zSendeKlient( id );
  821. if( c )
  822. {
  823. c->kick();
  824. cs->absturzKlient( c->getKlientNummer() );
  825. }
  826. cs->removeAccount( id );
  827. }
  828. break;
  829. case 2: // Account kommt online
  830. if( 1 )
  831. {
  832. klient->sendeEncrypted( "\1", 1 );
  833. int accId = 0;
  834. int freundId = 0;
  835. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accId, 4 ) );
  836. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&freundId, 4 ) );
  837. CSKlient *klient = cs->zSendeKlient( freundId );
  838. if( klient )
  839. res = (char)( res & (char)klient->freundOnline( accId ) );
  840. else
  841. res = 0;
  842. }
  843. break;
  844. case 3: // Account geht offline
  845. if( 1 )
  846. {
  847. klient->sendeEncrypted( "\1", 1 );
  848. int accId = 0;
  849. int freundId = 0;
  850. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accId, 4 ) );
  851. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&freundId, 4 ) );
  852. CSKlient *klient = cs->zSendeKlient( freundId );
  853. if( klient )
  854. res = (char)( res & (char)klient->freundOffline( accId ) );
  855. else
  856. res = 0;
  857. }
  858. break;
  859. case 4: // Chat nachricht
  860. if( 1 )
  861. {
  862. klient->sendeEncrypted( "\1", 1 );
  863. int vonAcc = 0;
  864. int zuAcc = 0;
  865. char len = 0;
  866. char *nachricht = 0;
  867. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&vonAcc, 4 ) );
  868. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  869. res = (char)( res & (char)klient->getNachrichtEncrypted( &len, 1 ) );
  870. if( len )
  871. {
  872. nachricht = new char[ len + 1 ];
  873. nachricht[ (int)len ] = 0;
  874. res = (char)( res & (char)klient->getNachrichtEncrypted( nachricht, len ) );
  875. CSKlient *klient = cs->zSendeKlient( zuAcc );
  876. if( klient )
  877. res = (char)( res & (char)klient->nachricht( vonAcc, nachricht ) );
  878. else
  879. res = 0;
  880. }
  881. delete[]nachricht;
  882. }
  883. break;
  884. case 5: // Gruppe einladung
  885. if( 1 )
  886. {
  887. klient->sendeEncrypted( "\1", 1 );
  888. int vonAcc = 0;
  889. int zuAcc = 0;
  890. int gruppeId = 0;
  891. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  892. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&vonAcc, 4 ) );
  893. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&gruppeId, 4 ) );
  894. CSKlient *klient = cs->zSendeKlient( zuAcc );
  895. if( klient )
  896. res = (char)( res & (char)klient->gruppeEinladung( vonAcc, gruppeId ) );
  897. else
  898. res = 0;
  899. }
  900. break;
  901. case 6: // Account Status ändert sich
  902. if( 1 )
  903. {
  904. klient->sendeEncrypted( "\1", 1 );
  905. int accId = 0;
  906. int freundId = 0;
  907. char len = 0;
  908. char *status = 0;
  909. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accId, 4 ) );
  910. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&freundId, 4 ) );
  911. res = (char)( res & (char)klient->getNachrichtEncrypted( &len, 1 ) );
  912. if( len )
  913. {
  914. status = new char[ len + 1 ];
  915. status[ (int)len ] = 0;
  916. res = (char)( res & (char)klient->getNachrichtEncrypted( status, len ) );
  917. CSKlient *klient = cs->zSendeKlient( freundId );
  918. if( klient )
  919. res = (char)( res & (char)klient->accountStatusChange( accId, status ) );
  920. else
  921. res = 0;
  922. }
  923. delete[]status;
  924. }
  925. break;
  926. case 7: // Account Name ändert sich
  927. if( 1 )
  928. {
  929. klient->sendeEncrypted( "\1", 1 );
  930. int accId = 0;
  931. int freundId = 0;
  932. char len = 0;
  933. char *name = 0;
  934. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accId, 4 ) );
  935. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&freundId, 4 ) );
  936. res = (char)( res & (char)klient->getNachrichtEncrypted( &len, 1 ) );
  937. if( len )
  938. {
  939. name = new char[ len + 1 ];
  940. name[ (int)len ] = 0;
  941. res = (char)( res & (char)klient->getNachrichtEncrypted( name, len ) );
  942. CSKlient *klient = cs->zSendeKlient( freundId );
  943. if( klient )
  944. res = (char)( res & (char)klient->accountNameChange( accId, name ) );
  945. else
  946. res = 0;
  947. }
  948. delete[]name;
  949. }
  950. break;
  951. case 8: // Kein Freund mehr
  952. if( 1 )
  953. {
  954. klient->sendeEncrypted( "\1", 1 );
  955. int accId = 0;
  956. int freundId = 0;
  957. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accId, 4 ) );
  958. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&freundId, 4 ) );
  959. CSKlient *klient = cs->zSendeKlient( freundId );
  960. if( klient )
  961. res = (char)( res & (char)klient->keinFreundMehr( accId ) );
  962. else
  963. res = 0;
  964. }
  965. break;
  966. case 9: // Freundesanfrage
  967. if( 1 )
  968. {
  969. klient->sendeEncrypted( "\1", 1 );
  970. int accId = 0;
  971. int freundId = 0;
  972. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accId, 4 ) );
  973. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&freundId, 4 ) );
  974. CSKlient *klient = cs->zSendeKlient( freundId );
  975. if( klient )
  976. res = (char)( res & (char)klient->freundesAnfrage( accId ) );
  977. else
  978. res = 0;
  979. }
  980. break;
  981. case 0xA: // Neuer Freund
  982. if( 1 )
  983. {
  984. klient->sendeEncrypted( "\1", 1 );
  985. int accId = 0;
  986. int freundId = 0;
  987. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accId, 4 ) );
  988. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&freundId, 4 ) );
  989. CSKlient *klient = cs->zSendeKlient( freundId );
  990. if( klient )
  991. res = (char)( res & (char)klient->neuerFreund( accountId ) );
  992. else
  993. res = 0;
  994. }
  995. break;
  996. case 0xB: // Einladung zum Chatroom
  997. if( 1 )
  998. {
  999. klient->sendeEncrypted( "\1", 1 );
  1000. int vonAcc = 0;
  1001. int zuAcc = 0;
  1002. int chatroomId = 0;
  1003. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&vonAcc, 4 ) );
  1004. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1005. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&chatroomId, 4 ) );
  1006. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1007. if( klient )
  1008. res = (char)( res & (char)klient->einladungZumChatroom( vonAcc, chatroomId ) );
  1009. else
  1010. res = 0;
  1011. }
  1012. break;
  1013. case 0xC: // Spieler betritt Chatroom
  1014. if( 1 )
  1015. {
  1016. klient->sendeEncrypted( "\1", 1 );
  1017. int accId = 0;
  1018. int zuAcc = 0;
  1019. int chatroomId = 0;
  1020. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accId, 4 ) );
  1021. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1022. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&chatroomId, 4 ) );
  1023. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1024. if( klient )
  1025. res = (char)( res & (char)klient->spielerBetrittChatroom( chatroomId, accId ) );
  1026. else
  1027. res = 0;
  1028. }
  1029. break;
  1030. case 0xD: // Chatroom nachricht
  1031. if( 1 )
  1032. {
  1033. klient->sendeEncrypted( "\1", 1 );
  1034. int vonAcc = 0;
  1035. int zuAcc = 0;
  1036. int chatroomId = 0;
  1037. char len = 0;
  1038. char *nachricht = 0;
  1039. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&vonAcc, 4 ) );
  1040. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1041. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&chatroomId, 4 ) );
  1042. res = (char)( res & (char)klient->getNachrichtEncrypted( &len, 1 ) );
  1043. if( len )
  1044. {
  1045. nachricht = new char[ len + 1 ];
  1046. nachricht[ (int)len ] = 0;
  1047. res = (char)( res & (char)klient->getNachrichtEncrypted( nachricht, len ) );
  1048. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1049. if( klient )
  1050. res = (char)( res & (char)klient->chatroomNachricht( chatroomId, vonAcc, nachricht ) );
  1051. else
  1052. res = 0;
  1053. }
  1054. delete[]nachricht;
  1055. }
  1056. break;
  1057. case 0xE: // Spieler verlässt Chatroom
  1058. if( 1 )
  1059. {
  1060. klient->sendeEncrypted( "\1", 1 );
  1061. int accId = 0;
  1062. int zuAcc = 0;
  1063. int chatroomId = 0;
  1064. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accId, 4 ) );
  1065. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1066. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&chatroomId, 4 ) );
  1067. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1068. if( klient )
  1069. res = (char)( res & (char)klient->spielerLeavesChatroom( chatroomId, accId ) );
  1070. else
  1071. res = 0;
  1072. }
  1073. break;
  1074. case 0xF: // Freund Einladung abgelehnt
  1075. if( 1 )
  1076. {
  1077. klient->sendeEncrypted( "\1", 1 );
  1078. int accId = 0;
  1079. int freundId = 0;
  1080. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accId, 4 ) );
  1081. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&freundId, 4 ) );
  1082. CSKlient *klient = cs->zSendeKlient( freundId );
  1083. if( klient )
  1084. res = (char)( res & (char)klient->freundesAnfrageAbgelehnt( accId ) );
  1085. else
  1086. res = 0;
  1087. }
  1088. break;
  1089. case 0x10: // Chatroom Einladungabgelehnt
  1090. if( 1 )
  1091. {
  1092. klient->sendeEncrypted( "\1", 1 );
  1093. int accId = 0;
  1094. int zuAcc = 0;
  1095. int chatroomId = 0;
  1096. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accId, 4 ) );
  1097. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1098. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&chatroomId, 4 ) );
  1099. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1100. if( klient )
  1101. res = (char)( res & (char)klient->einladungZumChatroomAbgelehnt( accId, chatroomId ) );
  1102. else
  1103. res = 0;
  1104. }
  1105. break;
  1106. case 0x11: // Fehler
  1107. if( 1 )
  1108. {
  1109. klient->sendeEncrypted( "\1", 1 );
  1110. int zuAcc = 0;
  1111. char len = 0;
  1112. char *nachricht = 0;
  1113. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1114. res = (char)( res & (char)klient->getNachrichtEncrypted( &len, 1 ) );
  1115. if( len )
  1116. {
  1117. nachricht = new char[ len + 1 ];
  1118. nachricht[ (int)len ] = 0;
  1119. res = (char)( res & (char)klient->getNachrichtEncrypted( nachricht, len ) );
  1120. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1121. if( klient )
  1122. res = (char)( res & (char)klient->errorZuKlient( nachricht ) );
  1123. else
  1124. res = 0;
  1125. }
  1126. delete[]nachricht;
  1127. }
  1128. break;
  1129. case 0x12: // Chatroom Admin
  1130. if( 1 )
  1131. {
  1132. klient->sendeEncrypted( "\1", 1 );
  1133. int zuAcc = 0;
  1134. int chatroomId = 0;
  1135. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1136. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&chatroomId, 4 ) );
  1137. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1138. if( klient )
  1139. res = (char)( res & (char)klient->chatroomAdmin( chatroomId ) );
  1140. else
  1141. res = 0;
  1142. }
  1143. break;
  1144. case 0x13: // Chatroom Kick
  1145. if( 1 )
  1146. {
  1147. klient->sendeEncrypted( "\1", 1 );
  1148. int zuAcc = 0;
  1149. int chatroomId = 0;
  1150. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1151. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&chatroomId, 4 ) );
  1152. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1153. if( klient )
  1154. res = (char)( res & (char)klient->chatroomKick( chatroomId ) );
  1155. else
  1156. res = 0;
  1157. }
  1158. break;
  1159. case 0x14: // spieler betritt gruppe
  1160. if( 1 )
  1161. {
  1162. klient->sendeEncrypted( "\1", 1 );
  1163. int zuAcc = 0;
  1164. int accountId = 0;
  1165. int gruppeId = 0;
  1166. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1167. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accountId, 4 ) );
  1168. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&gruppeId, 4 ) );
  1169. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1170. if( klient )
  1171. res = (char)( res & (char)klient->spielerBertittGruppe( accountId, gruppeId ) );
  1172. else
  1173. res = 0;
  1174. }
  1175. break;
  1176. case 0x15: // spieler verlässt gruppe
  1177. if( 1 )
  1178. {
  1179. klient->sendeEncrypted( "\1", 1 );
  1180. int zuAcc = 0;
  1181. int accountId = 0;
  1182. int gruppeId = 0;
  1183. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1184. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accountId, 4 ) );
  1185. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&gruppeId, 4 ) );
  1186. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1187. if( klient )
  1188. res = (char)( res & (char)klient->spielerLeavesGruppe( accountId, gruppeId ) );
  1189. else
  1190. res = 0;
  1191. }
  1192. break;
  1193. case 0x16: // kick spieler aus gruppe
  1194. if( 1 )
  1195. {
  1196. klient->sendeEncrypted( "\1", 1 );
  1197. int zuAcc = 0;
  1198. int gruppeId = 0;
  1199. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1200. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&gruppeId, 4 ) );
  1201. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1202. if( klient )
  1203. res = (char)( res & (char)klient->kickAusGruppe( gruppeId ) );
  1204. else
  1205. res = 0;
  1206. }
  1207. break;
  1208. case 0x17: // gruppe angemeldet
  1209. if( 1 )
  1210. {
  1211. klient->sendeEncrypted( "\1", 1 );
  1212. int zuAcc = 0;
  1213. int gruppeId = 0;
  1214. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1215. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&gruppeId, 4 ) );
  1216. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1217. if( klient )
  1218. res = (char)( res & (char)klient->gruppeAnmelden( gruppeId ) );
  1219. else
  1220. res = 0;
  1221. }
  1222. break;
  1223. case 0x18: // gruppe abgemeldet
  1224. if( 1 )
  1225. {
  1226. klient->sendeEncrypted( "\1", 1 );
  1227. int zuAcc = 0;
  1228. int gruppeId = 0;
  1229. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1230. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&gruppeId, 4 ) );
  1231. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1232. if( klient )
  1233. res = (char)( res & (char)klient->gruppeAbmelden( gruppeId ) );
  1234. else
  1235. res = 0;
  1236. }
  1237. break;
  1238. case 0x19: // gruppe nachricht
  1239. if( 1 )
  1240. {
  1241. klient->sendeEncrypted( "\1", 1 );
  1242. int zuAcc = 0;
  1243. int gruppeId = 0;
  1244. char len;
  1245. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1246. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&gruppeId, 4 ) );
  1247. res = (char)( res & (char)klient->getNachrichtEncrypted( &len, 1 ) );
  1248. char *nachricht = new char[ len + 1 ];
  1249. nachricht[ (int)len ] = 0;
  1250. if( len )
  1251. res = (char)( res & (char)klient->getNachrichtEncrypted( nachricht, len ) );
  1252. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1253. if( klient )
  1254. res = (char)( res & (char)klient->gruppeNachricht( gruppeId, nachricht ) );
  1255. else
  1256. res = 0;
  1257. delete[]nachricht;
  1258. }
  1259. break;
  1260. case 0x1A: // gruppe spiel starten
  1261. if( 1 )
  1262. {
  1263. klient->sendeEncrypted( "\1", 1 );
  1264. int zuAcc = 0;
  1265. int gruppeId = 0;
  1266. char starten;
  1267. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1268. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&gruppeId, 4 ) );
  1269. res = (char)( res & (char)klient->getNachrichtEncrypted( &starten, 1 ) );
  1270. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1271. if( klient )
  1272. res = (char)( res & (char)klient->gruppeSpielStarten( gruppeId, starten == 1 ) );
  1273. else
  1274. res = 0;
  1275. }
  1276. break;
  1277. case 0x1B: // gruppe admin
  1278. if( 1 )
  1279. {
  1280. klient->sendeEncrypted( "\1", 1 );
  1281. int zuAcc = 0;
  1282. int adminId = 0;
  1283. int gruppeId = 0;
  1284. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1285. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&adminId, 4 ) );
  1286. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&gruppeId, 4 ) );
  1287. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1288. if( klient )
  1289. res = (char)( res & (char)klient->setGruppeAdmin( gruppeId, adminId ) );
  1290. else
  1291. res = 0;
  1292. }
  1293. break;
  1294. case 0x1C: // gruppe Einladung abgelehnt
  1295. if( 1 )
  1296. {
  1297. klient->sendeEncrypted( "\1", 1 );
  1298. int zuAcc = 0;
  1299. int accountId = 0;
  1300. int gruppeId = 0;
  1301. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1302. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accountId, 4 ) );
  1303. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&gruppeId, 4 ) );
  1304. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1305. if( klient )
  1306. res = (char)( res & (char)klient->gruppeEinladungAbgelehnt( gruppeId, accountId ) );
  1307. else
  1308. res = 0;
  1309. }
  1310. break;
  1311. case 0x1D: // Spiel Server verbindungs aufforderung
  1312. if( 1 )
  1313. {
  1314. klient->sendeEncrypted( "\1", 1 );
  1315. int zuAcc = 0;
  1316. unsigned short port;
  1317. unsigned char *ip = new unsigned char[ 4 ];
  1318. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1319. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&port, 2 ) );
  1320. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)ip, 4 ) );
  1321. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1322. if( klient )
  1323. res = (char)( res & (char)klient->spielServerVerbindungsAnfrage( port, ip ) );
  1324. else
  1325. res = 0;
  1326. delete[] ip;
  1327. }
  1328. break;
  1329. case 0x1E: // gruppe einladung Abbrechen
  1330. if( 1 )
  1331. {
  1332. klient->sendeEncrypted( "\1", 1 );
  1333. int zuAcc = 0;
  1334. int gruppeId = 0;
  1335. int accountId = 0;
  1336. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1337. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&gruppeId, 4 ) );
  1338. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accountId, 4 ) );
  1339. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1340. if( klient )
  1341. res = (char)( res & (char)klient->gruppeEinladungAbgebrochen( gruppeId, accountId ) );
  1342. else
  1343. res = 0;
  1344. }
  1345. break;
  1346. case 0x1F: // gruppe einladung Neu
  1347. if( 1 )
  1348. {
  1349. klient->sendeEncrypted( "\1", 1 );
  1350. int zuAcc = 0;
  1351. int gruppeId = 0;
  1352. int accountId = 0;
  1353. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&zuAcc, 4 ) );
  1354. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&gruppeId, 4 ) );
  1355. res = (char)( res & (char)klient->getNachrichtEncrypted( (char*)&accountId, 4 ) );
  1356. CSKlient *klient = cs->zSendeKlient( zuAcc );
  1357. if( klient )
  1358. res = (char)( res & (char)klient->gruppeEinladungNeu( gruppeId, accountId ) );
  1359. else
  1360. res = 0;
  1361. }
  1362. break;
  1363. default:
  1364. res = 0;
  1365. break;
  1366. }
  1367. klient->sendeEncrypted( &res, 1 );
  1368. }
  1369. break;
  1370. case 6: // Chat Nachricht
  1371. if( 1 )
  1372. {
  1373. if( !accountId || !klientNummer )
  1374. {
  1375. klient->sendeEncrypted( "\0", 1 );
  1376. CSKlient *c = cs->zSendeKlient( accountId );
  1377. if( c )
  1378. c->errorZuKlient( "Du bist nicht identifiziert." );
  1379. break;
  1380. }
  1381. klient->sendeEncrypted( "\1", 1 );
  1382. int zuAccount = 0;
  1383. char len = 0;
  1384. char *nachricht = 0;
  1385. klient->getNachrichtEncrypted( (char*)&zuAccount, 4 );
  1386. klient->getNachrichtEncrypted( &len, 1 );
  1387. if( len )
  1388. {
  1389. nachricht = new char[ len + 1 ];
  1390. nachricht[ (int)len ] = 0;
  1391. klient->getNachrichtEncrypted( nachricht, len );
  1392. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1393. if( !weiter->chatNachricht( accountId, zuAccount, nachricht ) )
  1394. {
  1395. cs->zDB()->speicherChatNachricht( accountId, zuAccount, nachricht );
  1396. CSKlient *c = cs->zSendeKlient( accountId );
  1397. if( c )
  1398. c->errorZuKlient( "Der Account ist momentan nicht erreichbar." );
  1399. }
  1400. delete weiter;
  1401. delete[]nachricht;
  1402. }
  1403. }
  1404. break;
  1405. case 8: // Account Name ändern
  1406. if( 1 )
  1407. {
  1408. if( !accountId || !klientNummer )
  1409. {
  1410. klient->sendeEncrypted( "\0", 1 );
  1411. CSKlient *c = cs->zSendeKlient( accountId );
  1412. if( c )
  1413. c->errorZuKlient( "Du bist nicht identifiziert." );
  1414. break;
  1415. }
  1416. klient->sendeEncrypted( "\1", 1 );
  1417. char len;
  1418. char *name;
  1419. klient->getNachrichtEncrypted( &len, 1 );
  1420. if( len )
  1421. {
  1422. name = new char[ len + 1 ];
  1423. name[ (int)len ] = 0;
  1424. klient->getNachrichtEncrypted( name, len );
  1425. if( cs->zDB()->accountNameChange( accountId, name ) )
  1426. {
  1427. klient->sendeEncrypted( "\1", 1 );
  1428. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1429. weiter->accountNameChange( accountId, name );
  1430. delete weiter;
  1431. }
  1432. else
  1433. {
  1434. klient->sendeEncrypted( "\0", 1 );
  1435. CSKlient *c = cs->zSendeKlient( accountId );
  1436. if( c )
  1437. c->errorZuKlient( "Beim ändern des Namens ist ein Fehler aufgetreten." );
  1438. }
  1439. delete[]name;
  1440. }
  1441. }
  1442. break;
  1443. case 9: // Freundschaft beenden
  1444. if( 1 )
  1445. {
  1446. if( !accountId || !klientNummer )
  1447. {
  1448. klient->sendeEncrypted( "\0", 1 );
  1449. CSKlient *c = cs->zSendeKlient( accountId );
  1450. if( c )
  1451. c->errorZuKlient( "Du bist nicht identifiziert." );
  1452. break;
  1453. }
  1454. klient->sendeEncrypted( "\1", 1 );
  1455. int freundId = 0;
  1456. klient->getNachrichtEncrypted( (char*)&freundId, 4 );
  1457. if( cs->zDB()->beendeFreundschaft( accountId, freundId ) )
  1458. {
  1459. klient->sendeEncrypted( "\1", 1 );
  1460. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1461. weiter->accountKeinFreundMehr( accountId, freundId );
  1462. weiter->accountKeinFreundMehr( freundId, accountId );
  1463. delete weiter;
  1464. }
  1465. else
  1466. {
  1467. klient->sendeEncrypted( "\0", 1 );
  1468. CSKlient *c = cs->zSendeKlient( accountId );
  1469. if( c )
  1470. c->errorZuKlient( "Die Freundschaft konnte nicht beendet werden." );
  1471. }
  1472. }
  1473. break;
  1474. case 0xA: // Freundschaftsanfrage senden
  1475. if( 1 )
  1476. {
  1477. if( !accountId || !klientNummer )
  1478. {
  1479. klient->sendeEncrypted( "\0", 1 );
  1480. CSKlient *c = cs->zSendeKlient( accountId );
  1481. if( c )
  1482. c->errorZuKlient( "Du bist nicht identifiziert." );
  1483. break;
  1484. }
  1485. klient->sendeEncrypted( "\1", 1 );
  1486. int freundId = 0;
  1487. klient->getNachrichtEncrypted( (char*)&freundId, 4 );
  1488. if( cs->zDB()->proveFreundschaftsAnfrage( accountId, freundId ) )
  1489. {
  1490. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1491. if( !weiter->freundesAnfrage( accountId, freundId ) )
  1492. cs->zDB()->saveFreundschaftsAnfrage( accountId, freundId );
  1493. klient->sendeEncrypted( "\1", 1 );
  1494. delete weiter;
  1495. }
  1496. else
  1497. {
  1498. klient->sendeEncrypted( "\0", 1 );
  1499. CSKlient *c = cs->zSendeKlient( accountId );
  1500. if( c )
  1501. c->errorZuKlient( "Diesem Account konnte keine Freundschaftsanfrage gesendet werden." );
  1502. }
  1503. }
  1504. break;
  1505. case 0xB: // Freundschaftsanfrage beantworten
  1506. if( 1 )
  1507. {
  1508. if( !accountId || !klientNummer )
  1509. {
  1510. klient->sendeEncrypted( "\0", 1 );
  1511. CSKlient *c = cs->zSendeKlient( accountId );
  1512. if( c )
  1513. c->errorZuKlient( "Du bist nicht identifiziert." );
  1514. break;
  1515. }
  1516. klient->sendeEncrypted( "\1", 1 );
  1517. int zuAccount = 0;
  1518. char ok = 0;
  1519. klient->getNachrichtEncrypted( (char*)&zuAccount, 4 );
  1520. klient->getNachrichtEncrypted( &ok, 1 );
  1521. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1522. if( !ok )
  1523. {
  1524. weiter->freundEinladungAbgelehnt( accountId, zuAccount );
  1525. klient->sendeEncrypted( "\1", 1 );
  1526. }
  1527. else
  1528. {
  1529. if( cs->zDB()->neueFreundschaft( accountId, zuAccount ) )
  1530. {
  1531. weiter->neuerFreund( accountId, zuAccount );
  1532. weiter->neuerFreund( zuAccount, accountId );
  1533. if( cs->zDB()->accountIstOnline( zuAccount ) )
  1534. {
  1535. weiter->accountOnline( zuAccount );
  1536. weiter->accountOnline( accountId );
  1537. }
  1538. klient->sendeEncrypted( "\1", 1 );
  1539. }
  1540. else
  1541. {
  1542. klient->sendeEncrypted( "\0", 1 );
  1543. CSKlient *c = cs->zSendeKlient( accountId );
  1544. if( c )
  1545. c->errorZuKlient( "Fehler beim erstellen der neuen Freundschaft." );
  1546. weiter->fehler( zuAccount, "Fehler beim erstellen der neuen Freundschaft." );
  1547. }
  1548. }
  1549. delete weiter;
  1550. }
  1551. break;
  1552. case 0xC: // Chatroom erstellen
  1553. if( 1 )
  1554. {
  1555. if( !accountId || !klientNummer )
  1556. {
  1557. klient->sendeEncrypted( "\0", 1 );
  1558. CSKlient *c = cs->zSendeKlient( accountId );
  1559. if( c )
  1560. c->errorZuKlient( "Du bist nicht identifiziert." );
  1561. break;
  1562. }
  1563. klient->sendeEncrypted( "\1", 1 );
  1564. char nLen = 0;
  1565. char *name = 0;
  1566. klient->getNachrichtEncrypted( &nLen, 1 );
  1567. if( nLen )
  1568. {
  1569. name = new char[ nLen + 1 ];
  1570. name[ (int)nLen ] = 0;
  1571. klient->getNachrichtEncrypted( name, nLen );
  1572. }
  1573. if( !name )
  1574. {
  1575. klient->sendeEncrypted( "\0", 1 );
  1576. CSKlient *c = cs->zSendeKlient( accountId );
  1577. if( c )
  1578. c->errorZuKlient( "Du musst einen Namen eingeben." );
  1579. }
  1580. else
  1581. {
  1582. klient->sendeEncrypted( "\1", 1 );
  1583. int id = cs->zDB()->chatroomErstellen( accountId, name );
  1584. klient->sendeEncrypted( (char*)&id, 4 );
  1585. if( !id )
  1586. {
  1587. CSKlient *c = cs->zSendeKlient( accountId );
  1588. if( c )
  1589. c->errorZuKlient( "Das Chatroom konnte nicht erstellt werden." );
  1590. }
  1591. else
  1592. {
  1593. CSKlient *c = cs->zSendeKlient( accountId );
  1594. if( c )
  1595. {
  1596. c->spielerBetrittChatroom( id, accountId );
  1597. c->chatroomAdmin( id );
  1598. }
  1599. }
  1600. }
  1601. delete[]name;
  1602. }
  1603. break;
  1604. case 0xD: // Zum Chatroom einladen
  1605. if( 1 )
  1606. {
  1607. if( !accountId || !klientNummer )
  1608. {
  1609. klient->sendeEncrypted( "\0", 1 );
  1610. CSKlient *c = cs->zSendeKlient( accountId );
  1611. if( c )
  1612. c->errorZuKlient( "Du bist nicht identifiziert." );
  1613. break;
  1614. }
  1615. klient->sendeEncrypted( "\1", 1 );
  1616. int zuAccountId = 0;
  1617. int chatroomId = 0;
  1618. klient->getNachrichtEncrypted( (char*)&zuAccountId, 4 );
  1619. klient->getNachrichtEncrypted( (char*)&chatroomId, 4 );
  1620. if( cs->zDB()->proveChatroomEinladung( accountId, zuAccountId, chatroomId ) )
  1621. {
  1622. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1623. if( weiter->einladungZumChatroom( accountId, zuAccountId, chatroomId ) )
  1624. klient->sendeEncrypted( "\1", 1 );
  1625. else
  1626. {
  1627. klient->sendeEncrypted( "\0", 1 );
  1628. if( weiter->getLetzterFehler() )
  1629. {
  1630. CSKlient *c = cs->zSendeKlient( accountId );
  1631. if( c )
  1632. c->errorZuKlient( weiter->getLetzterFehler() );
  1633. }
  1634. }
  1635. delete weiter;
  1636. }
  1637. else
  1638. {
  1639. klient->sendeEncrypted( "\0", 1 );
  1640. CSKlient *c = cs->zSendeKlient( accountId );
  1641. if( c )
  1642. c->errorZuKlient( "Der Account konnte nicht eingeladen werden." );
  1643. }
  1644. }
  1645. break;
  1646. case 0xE: // Chatroom einladung ablehnen
  1647. if( 1 )
  1648. {
  1649. if( !accountId || !klientNummer )
  1650. {
  1651. klient->sendeEncrypted( "\0", 1 );
  1652. CSKlient *c = cs->zSendeKlient( accountId );
  1653. if( c )
  1654. c->errorZuKlient( "Du bist nicht identifiziert." );
  1655. break;
  1656. }
  1657. klient->sendeEncrypted( "\1", 1 );
  1658. int zuAccountId = 0;
  1659. int chatroomId = 0;
  1660. klient->getNachrichtEncrypted( (char*)&zuAccountId, 4 );
  1661. klient->getNachrichtEncrypted( (char*)&chatroomId, 4 );
  1662. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1663. weiter->chatroomEinladungAbgelehnt( accountId, chatroomId, zuAccountId );
  1664. delete weiter;
  1665. klient->sendeEncrypted( "\1", 1 );
  1666. }
  1667. break;
  1668. case 0xF: // Chatroom betreten
  1669. if( 1 )
  1670. {
  1671. if( !accountId || !klientNummer )
  1672. {
  1673. klient->sendeEncrypted( "\0", 1 );
  1674. CSKlient *c = cs->zSendeKlient( accountId );
  1675. if( c )
  1676. c->errorZuKlient( "Du bist nicht identifiziert." );
  1677. break;
  1678. }
  1679. klient->sendeEncrypted( "\1", 1 );
  1680. int chatroomId = 0;
  1681. klient->getNachrichtEncrypted( (char*)&chatroomId, 4 );
  1682. if( cs->zDB()->chatroomBeitreten( accountId, chatroomId ) )
  1683. {
  1684. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1685. weiter->spielerBetrittChatroom( accountId, chatroomId );
  1686. delete weiter;
  1687. klient->sendeEncrypted( "\1", 1 );
  1688. Array< int > *accounts = new Array< int >();
  1689. int anzahl = cs->zDB()->getChatroomAccount( chatroomId, accounts );
  1690. CSKlient *c = cs->zSendeKlient( accountId );
  1691. if( c )
  1692. {
  1693. if( !c->spielerImChatroom( chatroomId, (char)anzahl, accounts ) )
  1694. c->errorZuKlient( "Fehler beim senden der momentanen Spieler im Chatroom." );
  1695. }
  1696. accounts->release();
  1697. }
  1698. else
  1699. klient->sendeEncrypted( "\0", 1 );
  1700. }
  1701. break;
  1702. case 0x10: // Chatroom Nachricht
  1703. if( 1 )
  1704. {
  1705. if( !accountId || !klientNummer )
  1706. {
  1707. klient->sendeEncrypted( "\0", 1 );
  1708. CSKlient *c = cs->zSendeKlient( accountId );
  1709. if( c )
  1710. c->errorZuKlient( "Du bist nicht identifiziert." );
  1711. break;
  1712. }
  1713. klient->sendeEncrypted( "\1", 1 );
  1714. int chatroomId = 0;
  1715. char len = 0;
  1716. char *nachricht = 0;
  1717. klient->getNachrichtEncrypted( (char*)&chatroomId, 4 );
  1718. klient->getNachrichtEncrypted( &len, 1 );
  1719. if( len )
  1720. {
  1721. nachricht = new char[ len + 1 ];
  1722. nachricht[ (int)len ] = 0;
  1723. klient->getNachrichtEncrypted( nachricht, len );
  1724. Text *message = cs->zDB()->getAccountRufName( accountId );
  1725. message->append( ": " );
  1726. message->append( nachricht );
  1727. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1728. if( weiter->chatroomNachricht( accountId, message->getText(), chatroomId ) )
  1729. klient->sendeEncrypted( "\1", 1 );
  1730. else
  1731. {
  1732. klient->sendeEncrypted( "\0", 1 );
  1733. if( weiter->getLetzterFehler() )
  1734. {
  1735. CSKlient *c = cs->zSendeKlient( accountId );
  1736. if( c )
  1737. c->errorZuKlient( weiter->getLetzterFehler() );
  1738. }
  1739. }
  1740. message->release();
  1741. delete weiter;
  1742. delete[]nachricht;
  1743. }
  1744. else
  1745. klient->sendeEncrypted( "\0", 1 );
  1746. }
  1747. break;
  1748. case 0x11: // Chatroom verlassen
  1749. if( 1 )
  1750. {
  1751. if( !accountId || !klientNummer )
  1752. {
  1753. klient->sendeEncrypted( "\0", 1 );
  1754. CSKlient *c = cs->zSendeKlient( accountId );
  1755. if( c )
  1756. c->errorZuKlient( "Du bist nicht identifiziert." );
  1757. break;
  1758. }
  1759. klient->sendeEncrypted( "\1", 1 );
  1760. int chatroomId = 0;
  1761. klient->getNachrichtEncrypted( (char*)&chatroomId, 4 );
  1762. int aktion = cs->zDB()->chatroomVerlassen( accountId, chatroomId );
  1763. if( !aktion )
  1764. klient->sendeEncrypted( "\0", 1 );
  1765. else
  1766. {
  1767. if( aktion == 3 )
  1768. {
  1769. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1770. weiter->chatroomAdmin( chatroomId, cs->zDB()->getChatroomAdmin( chatroomId ) );
  1771. delete weiter;
  1772. }
  1773. if( aktion != 2 )
  1774. {
  1775. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1776. weiter->spielerLeavestChatroom( accountId, chatroomId );
  1777. delete weiter;
  1778. }
  1779. klient->sendeEncrypted( "\1", 1 );
  1780. }
  1781. }
  1782. break;
  1783. case 0x12: // Chatroom Kick
  1784. if( 1 )
  1785. {
  1786. if( !accountId || !klientNummer )
  1787. {
  1788. klient->sendeEncrypted( "\0", 1 );
  1789. CSKlient *c = cs->zSendeKlient( accountId );
  1790. if( c )
  1791. c->errorZuKlient( "Du bist nicht identifiziert." );
  1792. break;
  1793. }
  1794. klient->sendeEncrypted( "\1", 1 );
  1795. int chatroomId = 0;
  1796. int accountId = 0;
  1797. klient->getNachrichtEncrypted( (char*)&chatroomId, 4 );
  1798. klient->getNachrichtEncrypted( (char*)&accountId, 4 );
  1799. if( accountId == (int)this->accountId )
  1800. {
  1801. klient->sendeEncrypted( "\0", 1 );
  1802. CSKlient *c = cs->zSendeKlient( accountId );
  1803. if( c )
  1804. c->errorZuKlient( "Du kannst dich selbst nicht kicken." );
  1805. break;
  1806. }
  1807. if( cs->zDB()->getChatroomAdmin( chatroomId ) == (int)this->accountId )
  1808. {
  1809. if( cs->zDB()->chatroomVerlassen( accountId, chatroomId ) )
  1810. {
  1811. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1812. weiter->chatroomKick( chatroomId, accountId );
  1813. weiter->spielerLeavestChatroom( accountId, chatroomId );
  1814. delete weiter;
  1815. klient->sendeEncrypted( "\1", 1 );
  1816. }
  1817. else
  1818. {
  1819. klient->sendeEncrypted( "\0", 1 );
  1820. CSKlient *c = cs->zSendeKlient( accountId );
  1821. if( c )
  1822. c->errorZuKlient( "Der Spieler konnte nicht entfernt werden." );
  1823. }
  1824. }
  1825. else
  1826. {
  1827. klient->sendeEncrypted( "\0", 1 );
  1828. CSKlient *c = cs->zSendeKlient( accountId );
  1829. if( c )
  1830. c->errorZuKlient( "Du bist nicht der Administrator dieses Chatrooms." );
  1831. }
  1832. }
  1833. break;
  1834. case 0x13: // Anfrage nach Freundes Liste
  1835. if( 1 )
  1836. {
  1837. klient->sendeEncrypted( "\1", 1 );
  1838. Array< int > *freundId = new Array< int >();
  1839. int anz = cs->zDB()->getAccountFreunde( accountId, freundId );
  1840. CSKlient *c = cs->zSendeKlient( accountId );
  1841. if( c )
  1842. c->freunde( (char)anz, freundId );
  1843. freundId->release();
  1844. freundId = new Array< int >();
  1845. anz = cs->zDB()->getAccountOnlineFreunde( accountId, freundId );
  1846. for( int i = 0; i < anz; i++ )
  1847. {
  1848. if( c )
  1849. c->freundOnline( freundId->get( i ) );
  1850. }
  1851. freundId->release();
  1852. }
  1853. break;
  1854. case 0x14: // Anfrage nach chat nachrichten in abwesenheit
  1855. if( 1 )
  1856. {
  1857. klient->sendeEncrypted( "\1", 1 );
  1858. Array< int > *vonAccount = new Array< int >();
  1859. RCArray< Text > *nachricht = new RCArray< Text >();
  1860. int anzahl = cs->zDB()->getChatNachrichten( accountId, vonAccount, nachricht );
  1861. CSKlient *c = cs->zSendeKlient( accountId );
  1862. if( c )
  1863. {
  1864. for( int i = 0; i < anzahl; i++ )
  1865. c->nachricht( vonAccount->get( i ), nachricht->z( i )->getText() );
  1866. }
  1867. vonAccount->leeren();
  1868. nachricht->release();
  1869. anzahl = cs->zDB()->getFreundschaftsAnfragen( accountId, vonAccount );
  1870. if( c )
  1871. {
  1872. for( int i = 0; i < anzahl; i++ )
  1873. c->freundesAnfrage( vonAccount->get( i ) );
  1874. }
  1875. vonAccount->release();
  1876. }
  1877. break;
  1878. case 0x15: // ping
  1879. if( 1 )
  1880. {
  1881. if( !klientNummer )
  1882. {
  1883. errorZuKlient( "Du bist nicht Identifiziert." );
  1884. break;
  1885. }
  1886. klient->sendeEncrypted( "\1", 1 );
  1887. CSKlient *c = cs->zSendeKlient( accountId );
  1888. if( c )
  1889. c->keepAlive();
  1890. }
  1891. break;
  1892. default:
  1893. unbekannt++;
  1894. errorZuKlient( "Unbekannte Nachricht!" );
  1895. break;
  1896. }
  1897. if( br || unbekannt >= 10 )
  1898. break;
  1899. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  1900. cs->addGesendet( klient->getUploadBytes( 1 ) );
  1901. }
  1902. }
  1903. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  1904. cs->addGesendet( klient->getUploadBytes( 1 ) );
  1905. if( empfangen )
  1906. {
  1907. trenne();
  1908. if( klientNummer )
  1909. {
  1910. if( accountId )
  1911. {
  1912. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1913. weiter->accountOffline( accountId );
  1914. delete weiter;
  1915. }
  1916. cs->removeKlient( klientNummer );
  1917. }
  1918. else
  1919. cs->removeKlient( this );
  1920. }
  1921. }
  1922. bool CSKlient::kick()
  1923. {
  1924. lock();
  1925. if( empfangen )
  1926. {
  1927. klient->trenne();
  1928. warteAufThread( 100 );
  1929. ende();
  1930. MSGWeiterleitung *weiter = new MSGWeiterleitung( cs->getThis() );
  1931. weiter->accountOffline( accountId );
  1932. delete weiter;
  1933. }
  1934. else
  1935. {
  1936. klient->sendeEncrypted( "\1", 1 );
  1937. Sleep( 100 );
  1938. klient->trenne();
  1939. }
  1940. unlock();
  1941. return 1;
  1942. }
  1943. bool CSKlient::nachricht( int vonAccount, const char *txt )
  1944. {
  1945. if( empfangen )
  1946. return 0;
  1947. char len = (char)textLength( txt );
  1948. if( len )
  1949. {
  1950. lock();
  1951. klient->sendeEncrypted( "\4", 1 );
  1952. klient->sendeEncrypted( (char*)&vonAccount, 4 );
  1953. klient->sendeEncrypted( &len, 1 );
  1954. klient->sendeEncrypted( txt, len );
  1955. unlock();
  1956. }
  1957. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  1958. cs->addGesendet( klient->getUploadBytes( 1 ) );
  1959. return 1;
  1960. }
  1961. bool CSKlient::gruppeEinladung( int vonAccount, int gruppeId )
  1962. {
  1963. if( empfangen )
  1964. return 0;
  1965. lock();
  1966. klient->sendeEncrypted( "\5", 1 );
  1967. klient->sendeEncrypted( (char*)&vonAccount, 4 );
  1968. klient->sendeEncrypted( (char*)&gruppeId, 4 );
  1969. unlock();
  1970. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  1971. cs->addGesendet( klient->getUploadBytes( 1 ) );
  1972. return 1;
  1973. }
  1974. bool CSKlient::accountStatusChange( int account, const char *status )
  1975. {
  1976. if( empfangen )
  1977. return 0;
  1978. char len = (char)( status ? textLength( status ) : 0 );
  1979. if( len )
  1980. {
  1981. lock();
  1982. klient->sendeEncrypted( "\6", 1 );
  1983. klient->sendeEncrypted( (char*)&account, 4 );
  1984. klient->sendeEncrypted( &len, 1 );
  1985. klient->sendeEncrypted( status, len );
  1986. unlock();
  1987. }
  1988. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  1989. cs->addGesendet( klient->getUploadBytes( 1 ) );
  1990. return 1;
  1991. }
  1992. bool CSKlient::accountNameChange( int account, const char *name )
  1993. {
  1994. if( empfangen )
  1995. return 0;
  1996. char len = (char)( name ? textLength( name ) : 0 );
  1997. if( len )
  1998. {
  1999. lock();
  2000. klient->sendeEncrypted( "\7", 1 );
  2001. klient->sendeEncrypted( (char*)&account, 4 );
  2002. klient->sendeEncrypted( &len, 1 );
  2003. klient->sendeEncrypted( name, len );
  2004. unlock();
  2005. }
  2006. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2007. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2008. return 1;
  2009. }
  2010. bool CSKlient::keinFreundMehr( int account )
  2011. {
  2012. if( empfangen )
  2013. return 0;
  2014. lock();
  2015. klient->sendeEncrypted( "\x8", 1 );
  2016. klient->sendeEncrypted( (char*)&account, 4 );
  2017. unlock();
  2018. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2019. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2020. return 1;
  2021. }
  2022. bool CSKlient::freundesAnfrage( int vonAccount )
  2023. {
  2024. if( empfangen )
  2025. return 0;
  2026. lock();
  2027. klient->sendeEncrypted( "\x9", 1 );
  2028. klient->sendeEncrypted( (char*)&vonAccount, 4 );
  2029. unlock();
  2030. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2031. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2032. return 1;
  2033. }
  2034. bool CSKlient::neuerFreund( int account )
  2035. {
  2036. if( empfangen )
  2037. return 0;
  2038. lock();
  2039. klient->sendeEncrypted( "\xA", 1 );
  2040. klient->sendeEncrypted( (char*)&account, 4 );
  2041. unlock();
  2042. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2043. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2044. return 1;
  2045. }
  2046. bool CSKlient::freundesAnfrageAbgelehnt( int account )
  2047. {
  2048. if( empfangen )
  2049. return 0;
  2050. lock();
  2051. klient->sendeEncrypted( "\xB", 1 );
  2052. klient->sendeEncrypted( (char*)&account, 4 );
  2053. unlock();
  2054. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2055. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2056. return 1;
  2057. }
  2058. bool CSKlient::einladungZumChatroom( int vonAccount, int chatroomId )
  2059. {
  2060. if( empfangen )
  2061. return 0;
  2062. lock();
  2063. klient->sendeEncrypted( "\xC", 1 );
  2064. klient->sendeEncrypted( (char*)&vonAccount, 4 );
  2065. klient->sendeEncrypted( (char*)&chatroomId, 4 );
  2066. unlock();
  2067. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2068. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2069. return 1;
  2070. }
  2071. bool CSKlient::einladungZumChatroomAbgelehnt( int account, int chatroomId )
  2072. {
  2073. if( empfangen )
  2074. return 0;
  2075. lock();
  2076. klient->sendeEncrypted( "\xD", 1 );
  2077. klient->sendeEncrypted( (char*)&account, 4 );
  2078. klient->sendeEncrypted( (char*)&chatroomId, 4 );
  2079. unlock();
  2080. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2081. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2082. return 1;
  2083. }
  2084. bool CSKlient::spielerBetrittChatroom( int chatroomId, int account )
  2085. {
  2086. if( empfangen )
  2087. return 0;
  2088. lock();
  2089. klient->sendeEncrypted( "\xE", 1 );
  2090. klient->sendeEncrypted( (char*)&chatroomId, 4 );
  2091. klient->sendeEncrypted( (char*)&account, 4 );
  2092. unlock();
  2093. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2094. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2095. return 1;
  2096. }
  2097. bool CSKlient::chatroomNachricht( int chatroomId, int vonAccount, const char *nachricht )
  2098. {
  2099. if( empfangen )
  2100. return 0;
  2101. char len = (char)( nachricht ? textLength( nachricht ) : 0);
  2102. if( len )
  2103. {
  2104. lock();
  2105. klient->sendeEncrypted( "\xF", 1 );
  2106. klient->sendeEncrypted( (char*)&chatroomId, 4 );
  2107. klient->sendeEncrypted( (char*)&vonAccount, 4 );
  2108. klient->sendeEncrypted( &len, 1 );
  2109. klient->sendeEncrypted( nachricht, len );
  2110. unlock();
  2111. }
  2112. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2113. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2114. return 1;
  2115. }
  2116. bool CSKlient::spielerLeavesChatroom( int chatroomId, int accountId )
  2117. {
  2118. if( empfangen )
  2119. return 0;
  2120. lock();
  2121. klient->sendeEncrypted( "\x10", 1 );
  2122. klient->sendeEncrypted( (char*)&chatroomId, 4 );
  2123. klient->sendeEncrypted( (char*)&accountId, 4 );
  2124. unlock();
  2125. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2126. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2127. return 1;
  2128. }
  2129. bool CSKlient::freunde( char anzahl, Array< int > *zAccountId )
  2130. {
  2131. if( empfangen )
  2132. return 0;
  2133. lock();
  2134. klient->sendeEncrypted( "\x11", 1 );
  2135. klient->sendeEncrypted( &anzahl, 1 );
  2136. for( int i = 0; i < anzahl; i++ )
  2137. {
  2138. int accId = zAccountId->get( i );
  2139. klient->sendeEncrypted( (char*)&accId, 4 );
  2140. }
  2141. unlock();
  2142. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2143. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2144. return 1;
  2145. }
  2146. bool CSKlient::spielerImChatroom( int chatroomId, char anzahl, Array< int > *zAccountId )
  2147. {
  2148. if( empfangen )
  2149. return 0;
  2150. lock();
  2151. klient->sendeEncrypted( "\x12", 1 );
  2152. klient->sendeEncrypted( (char*)&chatroomId, 4 );
  2153. klient->sendeEncrypted( &anzahl, 1 );
  2154. for( int i = 0; i < anzahl; i++ )
  2155. {
  2156. int accId = zAccountId->get( i );
  2157. klient->sendeEncrypted( (char*)&accId, 4 );
  2158. }
  2159. unlock();
  2160. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2161. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2162. return 1;
  2163. }
  2164. bool CSKlient::freundOnline( int accountId )
  2165. {
  2166. if( empfangen )
  2167. return 0;
  2168. lock();
  2169. klient->sendeEncrypted( "\x13", 1 );
  2170. klient->sendeEncrypted( (char*)&accountId, 4 );
  2171. unlock();
  2172. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2173. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2174. return 1;
  2175. }
  2176. bool CSKlient::freundOffline( int accountId )
  2177. {
  2178. if( empfangen )
  2179. return 0;
  2180. lock();
  2181. klient->sendeEncrypted( "\x14", 1 );
  2182. klient->sendeEncrypted( (char*)&accountId, 4 );
  2183. unlock();
  2184. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2185. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2186. return 1;
  2187. }
  2188. bool CSKlient::chatroomAdmin( int chatroomId )
  2189. {
  2190. if( empfangen )
  2191. return 0;
  2192. lock();
  2193. klient->sendeEncrypted( "\x15", 1 );
  2194. klient->sendeEncrypted( (char*)&chatroomId, 4 );
  2195. unlock();
  2196. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2197. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2198. return 1;
  2199. }
  2200. bool CSKlient::chatroomKick( int chatroomId )
  2201. {
  2202. if( empfangen )
  2203. return 0;
  2204. lock();
  2205. klient->sendeEncrypted( "\x16", 1 );
  2206. klient->sendeEncrypted( (char*)&chatroomId, 4 );
  2207. unlock();
  2208. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2209. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2210. return 1;
  2211. }
  2212. bool CSKlient::spielerBertittGruppe( int accountId, int gruppeId )
  2213. {
  2214. if( empfangen )
  2215. return 0;
  2216. lock();
  2217. klient->sendeEncrypted( "\x17", 1 );
  2218. klient->sendeEncrypted( (char*)&accountId, 4 );
  2219. klient->sendeEncrypted( (char*)&gruppeId, 4 );
  2220. unlock();
  2221. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2222. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2223. return 1;
  2224. }
  2225. bool CSKlient::spielerLeavesGruppe( int accountId, int gruppeId )
  2226. {
  2227. if( empfangen )
  2228. return 0;
  2229. lock();
  2230. klient->sendeEncrypted( "\x18", 1 );
  2231. klient->sendeEncrypted( (char*)&accountId, 4 );
  2232. klient->sendeEncrypted( (char*)&gruppeId, 4 );
  2233. unlock();
  2234. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2235. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2236. return 1;
  2237. }
  2238. bool CSKlient::gruppeNachricht( int gruppeId, char *nachricht )
  2239. {
  2240. if( empfangen )
  2241. return 0;
  2242. char len = (char)textLength( nachricht );
  2243. if( !len )
  2244. return 1;
  2245. lock();
  2246. klient->sendeEncrypted( "\x19", 1 );
  2247. klient->sendeEncrypted( (char*)&gruppeId, 4 );
  2248. klient->sendeEncrypted( &len, 1 );
  2249. klient->sendeEncrypted( nachricht, len );
  2250. unlock();
  2251. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2252. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2253. return 1;
  2254. }
  2255. bool CSKlient::gruppeAnmelden( int gruppeId )
  2256. {
  2257. if( empfangen )
  2258. return 0;
  2259. lock();
  2260. klient->sendeEncrypted( "\x1A", 1 );
  2261. klient->sendeEncrypted( (char*)&gruppeId, 4 );
  2262. unlock();
  2263. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2264. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2265. return 1;
  2266. }
  2267. bool CSKlient::gruppeAbmelden( int gruppeId )
  2268. {
  2269. if( empfangen )
  2270. return 0;
  2271. lock();
  2272. klient->sendeEncrypted( "\x1B", 1 );
  2273. klient->sendeEncrypted( (char*)&gruppeId, 4 );
  2274. unlock();
  2275. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2276. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2277. return 1;
  2278. }
  2279. bool CSKlient::gruppeSpielStarten( int gruppeId, bool starten )
  2280. {
  2281. if( empfangen )
  2282. return 0;
  2283. lock();
  2284. klient->sendeEncrypted( "\x1C", 1 );
  2285. klient->sendeEncrypted( (char*)&gruppeId, 4 );
  2286. if( starten )
  2287. klient->sendeEncrypted( "\1", 1 );
  2288. else
  2289. klient->sendeEncrypted( "\0", 1 );
  2290. unlock();
  2291. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2292. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2293. return 1;
  2294. }
  2295. bool CSKlient::setGruppeAdmin( int gruppeId, int adminId )
  2296. {
  2297. if( empfangen )
  2298. return 0;
  2299. lock();
  2300. klient->sendeEncrypted( "\x1E", 1 );
  2301. klient->sendeEncrypted( (char*)&gruppeId, 4 );
  2302. klient->sendeEncrypted( (char*)&adminId, 4 );
  2303. unlock();
  2304. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2305. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2306. return 1;
  2307. }
  2308. bool CSKlient::kickAusGruppe( int gruppeId )
  2309. {
  2310. if( empfangen )
  2311. return 0;
  2312. lock();
  2313. klient->sendeEncrypted( "\x1D", 1 );
  2314. klient->sendeEncrypted( (char*)&gruppeId, 4 );
  2315. unlock();
  2316. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2317. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2318. return 1;
  2319. }
  2320. bool CSKlient::gruppeEinladungAbgelehnt( int gruppeId, int accountId )
  2321. {
  2322. if( empfangen )
  2323. return 0;
  2324. lock();
  2325. klient->sendeEncrypted( "\x1F", 1 );
  2326. klient->sendeEncrypted( (char*)&gruppeId, 4 );
  2327. klient->sendeEncrypted( (char*)&accountId, 4 );
  2328. unlock();
  2329. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2330. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2331. return 1;
  2332. }
  2333. bool CSKlient::spielServerVerbindungsAnfrage( unsigned short port, unsigned char *ip )
  2334. {
  2335. if( empfangen )
  2336. return 0;
  2337. lock();
  2338. klient->sendeEncrypted( "\x20", 1 );
  2339. klient->sendeEncrypted( (char*)&port, 2 );
  2340. klient->sendeEncrypted( (char*)ip, 4 );
  2341. unlock();
  2342. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2343. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2344. return 1;
  2345. }
  2346. bool CSKlient::gruppeEinladungAbgebrochen( int gruppeId, int accountId )
  2347. {
  2348. if( empfangen )
  2349. return 0;
  2350. lock();
  2351. klient->sendeEncrypted( "\x21", 1 );
  2352. klient->sendeEncrypted( (char*)&gruppeId, 4 );
  2353. klient->sendeEncrypted( (char*)&accountId, 4 );
  2354. unlock();
  2355. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2356. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2357. return 1;
  2358. }
  2359. bool CSKlient::gruppeEinladungNeu( int gruppeId, int accountId )
  2360. {
  2361. if( empfangen )
  2362. return 0;
  2363. lock();
  2364. klient->sendeEncrypted( "\x22", 1 );
  2365. klient->sendeEncrypted( (char*)&gruppeId, 4 );
  2366. klient->sendeEncrypted( (char*)&accountId, 4 );
  2367. unlock();
  2368. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2369. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2370. return 1;
  2371. }
  2372. bool CSKlient::errorZuKlient( const char *nachricht ) // sendet eine Fehlernachricht zum Klient
  2373. {
  2374. char len = (char)textLength( nachricht );
  2375. if( len )
  2376. {
  2377. lock();
  2378. klient->sendeEncrypted( "\3", 1 );
  2379. klient->sendeEncrypted( &len, 1 );
  2380. klient->sendeEncrypted( nachricht, len );
  2381. unlock();
  2382. }
  2383. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2384. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2385. return 1;
  2386. }
  2387. bool CSKlient::keepAlive() // erhält die Verbindung aufrecht
  2388. {
  2389. char res = 0;
  2390. lock();
  2391. klient->sendeEncrypted( "\x23", 1 );
  2392. klient->getNachrichtEncrypted( &res, 1 );
  2393. unlock();
  2394. return res == 1;
  2395. }
  2396. void CSKlient::trenne()
  2397. {
  2398. klient->trenne();
  2399. }
  2400. // constant
  2401. int CSKlient::getKlientNummer() const
  2402. {
  2403. return klientNummer;
  2404. }
  2405. int CSKlient::getAccountId() const
  2406. {
  2407. return accountId;
  2408. }
  2409. bool CSKlient::istEmpfang() const
  2410. {
  2411. return empfangen;
  2412. }
  2413. // Reference Counting
  2414. CSKlient *CSKlient::getThis()
  2415. {
  2416. ref++;
  2417. return this;
  2418. }
  2419. CSKlient *CSKlient::release()
  2420. {
  2421. ref--;
  2422. if( !ref )
  2423. delete this;
  2424. return 0;
  2425. }
  2426. // Inhalt der MSGWeiterleitung Klasse aus ChatServer.h
  2427. // Konstruktor
  2428. MSGWeiterleitung::MSGWeiterleitung( ChatServer *cs )
  2429. {
  2430. klient = 0;
  2431. this->cs = cs;
  2432. letzterFehler = new Text( "" );
  2433. }
  2434. // Destruktor
  2435. MSGWeiterleitung::~MSGWeiterleitung()
  2436. {
  2437. if( klient )
  2438. {
  2439. klient->trenne();
  2440. klient->release();
  2441. }
  2442. letzterFehler->release();
  2443. cs->release();
  2444. }
  2445. // nicht constant
  2446. bool MSGWeiterleitung::kickKlient( int accountId )
  2447. {
  2448. bool ret = 1;
  2449. int server = cs->zDB()->getChatServerId( accountId );
  2450. if( server == cs->getId() )
  2451. {
  2452. CSKlient *klient = cs->zSendeKlient( accountId );
  2453. if( klient )
  2454. {
  2455. ret = klient->kick();
  2456. klient->trenne();
  2457. }
  2458. ret = ret & cs->removeAccount( accountId );
  2459. }
  2460. else
  2461. {
  2462. char *ip = 0;
  2463. unsigned short port = 0;
  2464. ret = cs->zDB()->getChatServerIpPort( server, &port, &ip );
  2465. if( ip )
  2466. {
  2467. klient = new Klient();
  2468. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  2469. klient->setSendeKey( (char*)key, 20 );
  2470. klient->setEmpfangKey( (char*)key, 20 );
  2471. ret = ret & klient->verbinde( port, ip );
  2472. ret = ret & klient->sendeEncrypted( "\5\1", 2 );
  2473. char res = 0;
  2474. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2475. if( res )
  2476. {
  2477. ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
  2478. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2479. }
  2480. ret = (char)ret & res;
  2481. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2482. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2483. klient->trenne();
  2484. klient = klient->release();
  2485. }
  2486. delete[]ip;
  2487. }
  2488. if( !ret )
  2489. letzterFehler->setText( "Der Account ist nicht erreichbar" );
  2490. return ret;
  2491. }
  2492. bool MSGWeiterleitung::accountOnline( int accountId )
  2493. {
  2494. bool ret = 1;
  2495. Array< int > *accId = new Array< int >();
  2496. int anzahl = cs->zDB()->getAccountOnlineFreunde( accountId, accId );
  2497. for( int i = 0; i < anzahl; i++ )
  2498. {
  2499. int account = accId->get( i );
  2500. int server = cs->zDB()->getChatServerId( account );
  2501. if( server == cs->getId() )
  2502. {
  2503. CSKlient *klient = cs->zSendeKlient( account );
  2504. if( klient )
  2505. ret = ret & klient->freundOnline( accountId );
  2506. else
  2507. ret = 0;
  2508. }
  2509. else
  2510. {
  2511. char *ip = 0;
  2512. unsigned short port = 0;
  2513. ret = ret & cs->zDB()->getChatServerIpPort( server, &port, &ip );
  2514. if( ip )
  2515. {
  2516. klient = new Klient();
  2517. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  2518. klient->setSendeKey( (char*)key, 20 );
  2519. klient->setEmpfangKey( (char*)key, 20 );
  2520. ret = ret & klient->verbinde( port, ip );
  2521. ret = ret & klient->sendeEncrypted( "\5\2", 2 );
  2522. char res = 0;
  2523. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2524. if( res )
  2525. {
  2526. ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
  2527. ret = ret & klient->sendeEncrypted( (char*)&account, 4 );
  2528. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2529. }
  2530. ret = (char)ret & res;
  2531. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2532. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2533. klient->trenne();
  2534. klient = klient->release();
  2535. }
  2536. delete[]ip;
  2537. }
  2538. }
  2539. accId->release();
  2540. if( !ret )
  2541. letzterFehler->setText( "Einer oder mehr Accounts konnen nicht erreicht werden" );
  2542. return ret;
  2543. }
  2544. bool MSGWeiterleitung::accountOffline( int accountId )
  2545. {
  2546. bool ret = 1;
  2547. Array< int > *accId = new Array< int >();
  2548. int anzahl = cs->zDB()->getAccountOnlineFreunde( accountId, accId );
  2549. for( int i = 0; i < anzahl; i++ )
  2550. {
  2551. int account = accId->get( i );
  2552. int server = cs->zDB()->getChatServerId( account );
  2553. if( server == cs->getId() )
  2554. {
  2555. CSKlient *klient = cs->zSendeKlient( account );
  2556. if( klient )
  2557. ret = ret & klient->freundOffline( accountId );
  2558. else
  2559. ret = 0;
  2560. }
  2561. else
  2562. {
  2563. char *ip = 0;
  2564. unsigned short port = 0;
  2565. ret = ret & cs->zDB()->getChatServerIpPort( server, &port, &ip );
  2566. if( ip )
  2567. {
  2568. klient = new Klient();
  2569. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  2570. klient->setSendeKey( (char*)key, 20 );
  2571. klient->setEmpfangKey( (char*)key, 20 );
  2572. ret = ret & klient->verbinde( port, ip );
  2573. ret = ret & klient->sendeEncrypted( "\5\3", 2 );
  2574. char res = 0;
  2575. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2576. if( res )
  2577. {
  2578. ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
  2579. ret = ret & klient->sendeEncrypted( (char*)&account, 4 );
  2580. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2581. }
  2582. ret = (char)ret & res;
  2583. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2584. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2585. klient->trenne();
  2586. klient = klient->release();
  2587. }
  2588. delete[]ip;
  2589. }
  2590. }
  2591. accId->release();
  2592. if( !ret )
  2593. letzterFehler->setText( "Einer oder mehr Accounts konnen nicht erreicht werden" );
  2594. return ret;
  2595. }
  2596. bool MSGWeiterleitung::chatNachricht( int vonAccount, int zuAccount, const char *nachricht )
  2597. {
  2598. bool ret = 1;
  2599. char len = (char)textLength( nachricht );
  2600. if( !len )
  2601. return 1;
  2602. int server = cs->zDB()->getChatServerId( zuAccount );
  2603. if( server == cs->getId() )
  2604. {
  2605. CSKlient *klient = cs->zSendeKlient( zuAccount );
  2606. if( klient )
  2607. ret = klient->nachricht( vonAccount, nachricht );
  2608. else
  2609. ret = 0;
  2610. }
  2611. else
  2612. {
  2613. char *ip = 0;
  2614. unsigned short port = 0;
  2615. ret = cs->zDB()->getChatServerIpPort( server, &port, &ip );
  2616. if( ip )
  2617. {
  2618. klient = new Klient();
  2619. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  2620. klient->setSendeKey( (char*)key, 20 );
  2621. klient->setEmpfangKey( (char*)key, 20 );
  2622. ret = ret & klient->verbinde( port, ip );
  2623. ret = ret & klient->sendeEncrypted( "\5\4", 2 );
  2624. char res = 0;
  2625. ret = ret & klient->getNachrichtEncrypted( (char*)&res, 1 );
  2626. if( res )
  2627. {
  2628. ret = ret & klient->sendeEncrypted( (char*)&vonAccount, 4 );
  2629. ret = ret & klient->sendeEncrypted( (char*)&zuAccount, 4 );
  2630. ret = ret & klient->sendeEncrypted( &len, 1 );
  2631. ret = ret & klient->sendeEncrypted( (char*)nachricht, len );
  2632. ret = ret & klient->getNachrichtEncrypted( (char*)&res, 1 );
  2633. }
  2634. ret = (char)ret & res;
  2635. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2636. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2637. klient->trenne();
  2638. klient = klient->release();
  2639. }
  2640. delete[]ip;
  2641. }
  2642. if( !ret )
  2643. letzterFehler->setText( "Der Account konnte nicht erreicht werden. Die Nachricht wird zugestellt, sobald es möglich ist." );
  2644. return ret;
  2645. }
  2646. bool MSGWeiterleitung::accountStatusChange( int accountId, const char *status )
  2647. {
  2648. bool ret = 1;
  2649. char len = (char)textLength( status );
  2650. if( !len )
  2651. return 1;
  2652. Array< int > *accId = new Array< int >();
  2653. int anzahl = cs->zDB()->getAccountOnlineFreunde( accountId, accId );
  2654. for( int i = 0; i < anzahl; i++ )
  2655. {
  2656. int account = accId->get( i );
  2657. int server = cs->zDB()->getChatServerId( account );
  2658. if( server == cs->getId() )
  2659. {
  2660. CSKlient *klient = cs->zSendeKlient( account );
  2661. if( klient )
  2662. ret = ret & klient->accountStatusChange( accountId, status );
  2663. else
  2664. ret = 0;
  2665. }
  2666. else
  2667. {
  2668. char *ip = 0;
  2669. unsigned short port = 0;
  2670. ret = ret & cs->zDB()->getChatServerIpPort( server, &port, &ip );
  2671. if( ip )
  2672. {
  2673. klient = new Klient();
  2674. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  2675. klient->setSendeKey( (char*)key, 20 );
  2676. klient->setEmpfangKey( (char*)key, 20 );
  2677. ret = ret & klient->verbinde( port, ip );
  2678. ret = ret & klient->sendeEncrypted( "\5\6", 2 );
  2679. char res = 0;
  2680. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2681. if( res )
  2682. {
  2683. ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
  2684. ret = ret & klient->sendeEncrypted( (char*)&account, 4 );
  2685. ret = ret & klient->sendeEncrypted( (char*)&len, 1 );
  2686. ret = ret & klient->sendeEncrypted( (char*)status, len );
  2687. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2688. }
  2689. ret = (char)ret & res;
  2690. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2691. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2692. klient->trenne();
  2693. klient = klient->release();
  2694. }
  2695. delete[]ip;
  2696. }
  2697. }
  2698. accId->release();
  2699. if( !ret )
  2700. letzterFehler->setText( "Einer oder mehr Accounts konnen nicht erreicht werden" );
  2701. return ret;
  2702. }
  2703. bool MSGWeiterleitung::accountNameChange( int accountId, const char *name )
  2704. {
  2705. bool ret = 1;
  2706. char len = (char)textLength( name );
  2707. if( !name )
  2708. return 1;
  2709. Array< int > *accId = new Array< int >();
  2710. int anzahl = cs->zDB()->getAccountOnlineFreunde( accountId, accId );
  2711. for( int i = 0; i < anzahl; i++ )
  2712. {
  2713. int account = accId->get( i );
  2714. int server = cs->zDB()->getChatServerId( account );
  2715. if( server == cs->getId() )
  2716. {
  2717. CSKlient *klient = cs->zSendeKlient( account );
  2718. if( klient )
  2719. ret = ret & klient->accountNameChange( accountId, name );
  2720. else
  2721. ret = 0;
  2722. }
  2723. else
  2724. {
  2725. char *ip = 0;
  2726. unsigned short port = 0;
  2727. ret = ret & cs->zDB()->getChatServerIpPort( server, &port, &ip );
  2728. if( ip )
  2729. {
  2730. klient = new Klient();
  2731. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  2732. klient->setSendeKey( (char*)key, 20 );
  2733. klient->setEmpfangKey( (char*)key, 20 );
  2734. ret = ret & klient->verbinde( port, ip );
  2735. ret = ret & klient->sendeEncrypted( "\5\7", 2 );
  2736. char res = 0;
  2737. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2738. if( res )
  2739. {
  2740. ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
  2741. ret = ret & klient->sendeEncrypted( (char*)&account, 4 );
  2742. ret = ret & klient->sendeEncrypted( (char*)&len, 1 );
  2743. ret = ret & klient->sendeEncrypted( (char*)name, len );
  2744. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2745. }
  2746. ret = (char)ret & res;
  2747. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2748. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2749. klient->trenne();
  2750. klient = klient->release();
  2751. }
  2752. delete[]ip;
  2753. }
  2754. }
  2755. accId->release();
  2756. if( !ret )
  2757. letzterFehler->setText( "Einer oder mehr Accounts konnen nicht erreicht werden" );
  2758. return ret;
  2759. }
  2760. bool MSGWeiterleitung::accountKeinFreundMehr( int accountId, int zielAccountId )
  2761. {
  2762. bool ret = 1;
  2763. int server = cs->zDB()->getChatServerId( zielAccountId );
  2764. if( server == cs->getId() )
  2765. {
  2766. CSKlient *klient = cs->zSendeKlient( zielAccountId );
  2767. if( klient )
  2768. ret = ret & klient->keinFreundMehr( accountId );
  2769. else
  2770. ret = 0;
  2771. }
  2772. else
  2773. {
  2774. char *ip = 0;
  2775. unsigned short port = 0;
  2776. ret = cs->zDB()->getChatServerIpPort( server, &port, &ip );
  2777. if( ip )
  2778. {
  2779. klient = new Klient();
  2780. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  2781. klient->setSendeKey( (char*)key, 20 );
  2782. klient->setEmpfangKey( (char*)key, 20 );
  2783. ret = ret & klient->verbinde( port, ip );
  2784. ret = ret & klient->sendeEncrypted( "\5\x8", 2 );
  2785. char res = 0;
  2786. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2787. if( res )
  2788. {
  2789. ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
  2790. ret = ret & klient->sendeEncrypted( (char*)&zielAccountId, 4 );
  2791. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2792. }
  2793. ret = (char)ret & res;
  2794. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2795. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2796. klient->trenne();
  2797. klient = klient->release();
  2798. }
  2799. delete[]ip;
  2800. }
  2801. if( !ret )
  2802. letzterFehler->setText( "Der Account konnte nicht erreicht werden" );
  2803. return ret;
  2804. }
  2805. bool MSGWeiterleitung::freundesAnfrage( int vonAccountId, int zuAccountId )
  2806. {
  2807. bool ret = 1;
  2808. int server = cs->zDB()->getChatServerId( zuAccountId );
  2809. if( server == cs->getId() )
  2810. {
  2811. CSKlient *klient = cs->zSendeKlient( zuAccountId );
  2812. if( klient )
  2813. ret = ret & klient->freundesAnfrage( vonAccountId );
  2814. else
  2815. ret = 0;
  2816. }
  2817. else
  2818. {
  2819. char *ip = 0;
  2820. unsigned short port = 0;
  2821. ret = cs->zDB()->getChatServerIpPort( server, &port, &ip );
  2822. if( ip )
  2823. {
  2824. klient = new Klient();
  2825. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  2826. klient->setSendeKey( (char*)key, 20 );
  2827. klient->setEmpfangKey( (char*)key, 20 );
  2828. ret = ret & klient->verbinde( port, ip );
  2829. ret = ret & klient->sendeEncrypted( "\5\x9", 2 );
  2830. char res = 0;
  2831. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2832. if( res )
  2833. {
  2834. ret = ret & klient->sendeEncrypted( (char*)&vonAccountId, 4 );
  2835. ret = ret & klient->sendeEncrypted( (char*)&zuAccountId, 4 );
  2836. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2837. }
  2838. ret = (char)ret & res;
  2839. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2840. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2841. klient->trenne();
  2842. klient = klient->release();
  2843. }
  2844. delete[]ip;
  2845. }
  2846. if( !ret )
  2847. letzterFehler->setText( "Der Account konnte nicht erreicht werden" );
  2848. return ret;
  2849. }
  2850. bool MSGWeiterleitung::neuerFreund( int accountId, int zuAccountId )
  2851. {
  2852. bool ret = 1;
  2853. int server = cs->zDB()->getChatServerId( zuAccountId );
  2854. if( server == cs->getId() )
  2855. {
  2856. CSKlient *klient = cs->zSendeKlient( zuAccountId );
  2857. if( klient )
  2858. ret = ret & klient->neuerFreund( accountId );
  2859. else
  2860. ret = 0;
  2861. }
  2862. else
  2863. {
  2864. char *ip = 0;
  2865. unsigned short port = 0;
  2866. ret = cs->zDB()->getChatServerIpPort( server, &port, &ip );
  2867. if( ip )
  2868. {
  2869. klient = new Klient();
  2870. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  2871. klient->setSendeKey( (char*)key, 20 );
  2872. klient->setEmpfangKey( (char*)key, 20 );
  2873. ret = ret & klient->verbinde( port, ip );
  2874. ret = ret & klient->sendeEncrypted( "\5\xA", 2 );
  2875. char res = 0;
  2876. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2877. if( res )
  2878. {
  2879. ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
  2880. ret = ret & klient->sendeEncrypted( (char*)&zuAccountId, 4 );
  2881. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2882. }
  2883. ret = (char)ret & res;
  2884. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2885. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2886. klient->trenne();
  2887. klient = klient->release();
  2888. }
  2889. delete[]ip;
  2890. }
  2891. if( !ret )
  2892. letzterFehler->setText( "Der Account konnte nicht erreicht werden" );
  2893. return ret;
  2894. }
  2895. bool MSGWeiterleitung::einladungZumChatroom( int vonAccountId, int zuAccountId, int chatroomId )
  2896. {
  2897. bool ret = 1;
  2898. int server = cs->zDB()->getChatServerId( zuAccountId );
  2899. if( server == cs->getId() )
  2900. {
  2901. CSKlient *klient = cs->zSendeKlient( zuAccountId );
  2902. if( klient )
  2903. ret = ret & klient->einladungZumChatroom( vonAccountId, chatroomId );
  2904. else
  2905. ret = 0;
  2906. }
  2907. else
  2908. {
  2909. char *ip = 0;
  2910. unsigned short port = 0;
  2911. ret = cs->zDB()->getChatServerIpPort( server, &port, &ip );
  2912. if( ip )
  2913. {
  2914. klient = new Klient();
  2915. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  2916. klient->setSendeKey( (char*)key, 20 );
  2917. klient->setEmpfangKey( (char*)key, 20 );
  2918. ret = ret & klient->verbinde( port, ip );
  2919. ret = ret & klient->sendeEncrypted( "\5\xB", 2 );
  2920. char res = 0;
  2921. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2922. if( res )
  2923. {
  2924. ret = ret & klient->sendeEncrypted( (char*)&vonAccountId, 4 );
  2925. ret = ret & klient->sendeEncrypted( (char*)&zuAccountId, 4 );
  2926. ret = ret & klient->sendeEncrypted( (char*)&chatroomId, 4 );
  2927. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2928. }
  2929. ret = (char)ret & res;
  2930. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2931. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2932. klient->trenne();
  2933. klient = klient->release();
  2934. }
  2935. delete[]ip;
  2936. }
  2937. if( !ret )
  2938. letzterFehler->setText( "Der Account konnte nicht erreicht werden" );
  2939. return ret;
  2940. }
  2941. bool MSGWeiterleitung::spielerBetrittChatroom( int accountId, int chatroomId )
  2942. {
  2943. bool ret = 1;
  2944. Array< int > *accId = new Array< int >();
  2945. int anzahl = cs->zDB()->getChatroomAccount( chatroomId, accId );
  2946. for( int i = 0; i < anzahl; i++ )
  2947. {
  2948. int account = accId->get( i );
  2949. if( account == accountId )
  2950. continue;
  2951. int server = cs->zDB()->getChatServerId( account );
  2952. if( server == cs->getId() )
  2953. {
  2954. CSKlient *klient = cs->zSendeKlient( account );
  2955. if( klient )
  2956. ret = ret & klient->spielerBetrittChatroom( chatroomId, accountId );
  2957. else
  2958. ret = 0;
  2959. }
  2960. else
  2961. {
  2962. char *ip = 0;
  2963. unsigned short port = 0;
  2964. ret = ret & cs->zDB()->getChatServerIpPort( server, &port, &ip );
  2965. if( ip )
  2966. {
  2967. klient = new Klient();
  2968. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  2969. klient->setSendeKey( (char*)key, 20 );
  2970. klient->setEmpfangKey( (char*)key, 20 );
  2971. ret = ret & klient->verbinde( port, ip );
  2972. ret = ret & klient->sendeEncrypted( "\5\xC", 2 );
  2973. char res = 0;
  2974. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2975. if( res )
  2976. {
  2977. ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
  2978. ret = ret & klient->sendeEncrypted( (char*)&account, 4 );
  2979. ret = ret & klient->sendeEncrypted( (char*)&chatroomId, 4 );
  2980. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  2981. }
  2982. ret = (char)ret & res;
  2983. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  2984. cs->addGesendet( klient->getUploadBytes( 1 ) );
  2985. klient->trenne();
  2986. klient = klient->release();
  2987. }
  2988. delete[]ip;
  2989. }
  2990. }
  2991. accId->release();
  2992. if( !ret )
  2993. letzterFehler->setText( "Einer oder mehr Accounts konnen nicht erreicht werden" );
  2994. return ret;
  2995. }
  2996. bool MSGWeiterleitung::chatroomNachricht( int vonAccount, const char *nachricht, int chatroomId )
  2997. {
  2998. bool ret = 1;
  2999. char len = (char)textLength( nachricht );
  3000. if( !len )
  3001. return 1;
  3002. Array< int > *accId = new Array< int >();
  3003. int anzahl = cs->zDB()->getChatroomAccount( chatroomId, accId );
  3004. for( int i = 0; i < anzahl; i++ )
  3005. {
  3006. int account = accId->get( i );
  3007. int server = cs->zDB()->getChatServerId( account );
  3008. if( server == cs->getId() )
  3009. {
  3010. CSKlient *klient = cs->zSendeKlient( account );
  3011. if( klient )
  3012. ret = ret & klient->chatroomNachricht( chatroomId, vonAccount, nachricht );
  3013. else
  3014. ret = 0;
  3015. }
  3016. else
  3017. {
  3018. char *ip = 0;
  3019. unsigned short port = 0;
  3020. ret = ret & cs->zDB()->getChatServerIpPort( server, &port, &ip );
  3021. if( ip )
  3022. {
  3023. klient = new Klient();
  3024. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  3025. klient->setSendeKey( (char*)key, 20 );
  3026. klient->setEmpfangKey( (char*)key, 20 );
  3027. ret = ret & klient->verbinde( port, ip );
  3028. ret = ret & klient->sendeEncrypted( "\5\xD", 2 );
  3029. char res = 0;
  3030. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3031. if( res )
  3032. {
  3033. ret = ret & klient->sendeEncrypted( (char*)&vonAccount, 4 );
  3034. ret = ret & klient->sendeEncrypted( (char*)&account, 4 );
  3035. ret = ret & klient->sendeEncrypted( (char*)&chatroomId, 4 );
  3036. ret = ret & klient->sendeEncrypted( &len, 1 );
  3037. ret = ret & klient->sendeEncrypted( (char*)nachricht, len );
  3038. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3039. }
  3040. ret = (char)ret & res;
  3041. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  3042. cs->addGesendet( klient->getUploadBytes( 1 ) );
  3043. klient->trenne();
  3044. klient = klient->release();
  3045. }
  3046. delete[]ip;
  3047. }
  3048. }
  3049. accId->release();
  3050. if( !ret )
  3051. letzterFehler->setText( "Einer oder mehr Accounts konnen nicht erreicht werden" );
  3052. return ret;
  3053. }
  3054. bool MSGWeiterleitung::spielerLeavestChatroom( int accountId, int chatroomId )
  3055. {
  3056. bool ret = 1;
  3057. Array< int > *accId = new Array< int >();
  3058. int anzahl = cs->zDB()->getChatroomAccount( chatroomId, accId );
  3059. for( int i = 0; i < anzahl; i++ )
  3060. {
  3061. int account = accId->get( i );
  3062. int server = cs->zDB()->getChatServerId( account );
  3063. if( server == cs->getId() )
  3064. {
  3065. CSKlient *klient = cs->zSendeKlient( account );
  3066. if( klient )
  3067. ret = ret & klient->spielerLeavesChatroom( chatroomId, accountId );
  3068. else
  3069. ret = 0;
  3070. }
  3071. else
  3072. {
  3073. char *ip = 0;
  3074. unsigned short port = 0;
  3075. ret = ret & cs->zDB()->getChatServerIpPort( server, &port, &ip );
  3076. if( ip )
  3077. {
  3078. klient = new Klient();
  3079. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  3080. klient->setSendeKey( (char*)key, 20 );
  3081. klient->setEmpfangKey( (char*)key, 20 );
  3082. ret = ret & klient->verbinde( port, ip );
  3083. ret = ret & klient->sendeEncrypted( "\5\xE", 2 );
  3084. char res = 0;
  3085. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3086. if( res )
  3087. {
  3088. ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
  3089. ret = ret & klient->sendeEncrypted( (char*)&account, 4 );
  3090. ret = ret & klient->sendeEncrypted( (char*)&chatroomId, 4 );
  3091. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3092. }
  3093. ret = (char)ret & res;
  3094. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  3095. cs->addGesendet( klient->getUploadBytes( 1 ) );
  3096. klient->trenne();
  3097. klient = klient->release();
  3098. }
  3099. delete[]ip;
  3100. }
  3101. }
  3102. accId->release();
  3103. if( !ret )
  3104. letzterFehler->setText( "Einer oder mehr Accounts konnen nicht erreicht werden" );
  3105. return ret;
  3106. }
  3107. bool MSGWeiterleitung::freundEinladungAbgelehnt( int accountId, int zuAccountId )
  3108. {
  3109. bool ret = 1;
  3110. int server = cs->zDB()->getChatServerId( zuAccountId );
  3111. if( server == cs->getId() )
  3112. {
  3113. CSKlient *klient = cs->zSendeKlient( zuAccountId );
  3114. if( klient )
  3115. ret = ret & klient->freundesAnfrageAbgelehnt( accountId );
  3116. else
  3117. ret = 0;
  3118. }
  3119. else
  3120. {
  3121. char *ip = 0;
  3122. unsigned short port = 0;
  3123. ret = cs->zDB()->getChatServerIpPort( server, &port, &ip );
  3124. if( ip )
  3125. {
  3126. klient = new Klient();
  3127. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  3128. klient->setSendeKey( (char*)key, 20 );
  3129. klient->setEmpfangKey( (char*)key, 20 );
  3130. ret = ret & klient->verbinde( port, ip );
  3131. ret = ret & klient->sendeEncrypted( "\5\xF", 2 );
  3132. char res = 0;
  3133. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3134. if( res )
  3135. {
  3136. ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
  3137. ret = ret & klient->sendeEncrypted( (char*)&zuAccountId, 4 );
  3138. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3139. }
  3140. ret = (char)ret & res;
  3141. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  3142. cs->addGesendet( klient->getUploadBytes( 1 ) );
  3143. klient->trenne();
  3144. klient = klient->release();
  3145. }
  3146. delete[]ip;
  3147. }
  3148. if( !ret )
  3149. letzterFehler->setText( "Der Account konnte nicht erreicht werden" );
  3150. return ret;
  3151. }
  3152. bool MSGWeiterleitung::chatroomEinladungAbgelehnt( int accountId, int chatroomId, int zuAccountId )
  3153. {
  3154. bool ret = 1;
  3155. int server = cs->zDB()->getChatServerId( zuAccountId );
  3156. if( server == cs->getId() )
  3157. {
  3158. CSKlient *klient = cs->zSendeKlient( zuAccountId );
  3159. if( klient )
  3160. ret = ret & klient->einladungZumChatroomAbgelehnt( accountId, chatroomId );
  3161. else
  3162. ret = 0;
  3163. }
  3164. else
  3165. {
  3166. char *ip = 0;
  3167. unsigned short port = 0;
  3168. ret = cs->zDB()->getChatServerIpPort( server, &port, &ip );
  3169. if( ip )
  3170. {
  3171. klient = new Klient();
  3172. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  3173. klient->setSendeKey( (char*)key, 20 );
  3174. klient->setEmpfangKey( (char*)key, 20 );
  3175. ret = ret & klient->verbinde( port, ip );
  3176. ret = ret & klient->sendeEncrypted( "\5\x10", 2 );
  3177. char res = 0;
  3178. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3179. if( res )
  3180. {
  3181. ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
  3182. ret = ret & klient->sendeEncrypted( (char*)&zuAccountId, 4 );
  3183. ret = ret & klient->sendeEncrypted( (char*)&chatroomId, 4 );
  3184. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3185. }
  3186. ret = (char)ret & res;
  3187. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  3188. cs->addGesendet( klient->getUploadBytes( 1 ) );
  3189. klient->trenne();
  3190. klient = klient->release();
  3191. }
  3192. delete[]ip;
  3193. }
  3194. if( !ret )
  3195. letzterFehler->setText( "Der Account konnte nicht erreicht werden" );
  3196. return ret;
  3197. }
  3198. bool MSGWeiterleitung::fehler( int zuAccountId, const char *fehler )
  3199. {
  3200. bool ret = 1;
  3201. char len = (char)textLength( fehler );
  3202. if( !len )
  3203. return 1;
  3204. int server = cs->zDB()->getChatServerId( zuAccountId );
  3205. if( server == cs->getId() )
  3206. {
  3207. CSKlient *klient = cs->zSendeKlient( zuAccountId );
  3208. if( klient )
  3209. ret = ret & klient->errorZuKlient( fehler );
  3210. else
  3211. ret = 0;
  3212. }
  3213. else
  3214. {
  3215. char *ip = 0;
  3216. unsigned short port = 0;
  3217. ret = cs->zDB()->getChatServerIpPort( server, &port, &ip );
  3218. if( ip )
  3219. {
  3220. klient = new Klient();
  3221. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  3222. klient->setSendeKey( (char*)key, 20 );
  3223. klient->setEmpfangKey( (char*)key, 20 );
  3224. ret = ret & klient->verbinde( port, ip );
  3225. ret = ret & klient->sendeEncrypted( "\5\x11", 2 );
  3226. char res = 0;
  3227. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3228. if( res )
  3229. {
  3230. ret = ret & klient->sendeEncrypted( (char*)&zuAccountId, 4 );
  3231. ret = ret & klient->sendeEncrypted( &len, 1 );
  3232. ret = ret & klient->sendeEncrypted( (char*)&fehler, len );
  3233. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3234. }
  3235. ret = (char)ret & res;
  3236. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  3237. cs->addGesendet( klient->getUploadBytes( 1 ) );
  3238. klient->trenne();
  3239. klient = klient->release();
  3240. }
  3241. delete[]ip;
  3242. }
  3243. if( !ret )
  3244. letzterFehler->setText( "Der Account konnte nicht erreicht werden" );
  3245. return ret;
  3246. }
  3247. bool MSGWeiterleitung::chatroomAdmin( int chatroomId, int zuAccountId )
  3248. {
  3249. bool ret = 1;
  3250. int server = cs->zDB()->getChatServerId( zuAccountId );
  3251. if( server == cs->getId() )
  3252. {
  3253. CSKlient *klient = cs->zSendeKlient( zuAccountId );
  3254. if( klient )
  3255. ret = ret & klient->chatroomAdmin( chatroomId );
  3256. else
  3257. ret = 0;
  3258. }
  3259. else
  3260. {
  3261. char *ip = 0;
  3262. unsigned short port = 0;
  3263. ret = cs->zDB()->getChatServerIpPort( server, &port, &ip );
  3264. if( ip )
  3265. {
  3266. klient = new Klient();
  3267. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  3268. klient->setSendeKey( (char*)key, 20 );
  3269. klient->setEmpfangKey( (char*)key, 20 );
  3270. ret = ret & klient->verbinde( port, ip );
  3271. ret = ret & klient->sendeEncrypted( "\5\x12", 2 );
  3272. char res = 0;
  3273. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3274. if( res )
  3275. {
  3276. ret = ret & klient->sendeEncrypted( (char*)&zuAccountId, 4 );
  3277. ret = ret & klient->sendeEncrypted( (char*)&chatroomId, 4 );
  3278. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3279. }
  3280. ret = (char)ret & res;
  3281. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  3282. cs->addGesendet( klient->getUploadBytes( 1 ) );
  3283. klient->trenne();
  3284. klient = klient->release();
  3285. }
  3286. delete[]ip;
  3287. }
  3288. if( !ret )
  3289. letzterFehler->setText( "Der Account konnte nicht erreicht werden" );
  3290. return ret;
  3291. }
  3292. bool MSGWeiterleitung::chatroomKick( int chatroomId, int accountId )
  3293. {
  3294. bool ret = 1;
  3295. int server = cs->zDB()->getChatServerId( accountId );
  3296. if( server == cs->getId() )
  3297. {
  3298. CSKlient *klient = cs->zSendeKlient( accountId );
  3299. if( klient )
  3300. ret = ret & klient->chatroomKick( chatroomId );
  3301. else
  3302. ret = 0;
  3303. }
  3304. else
  3305. {
  3306. char *ip = 0;
  3307. unsigned short port = 0;
  3308. ret = cs->zDB()->getChatServerIpPort( server, &port, &ip );
  3309. if( ip )
  3310. {
  3311. klient = new Klient();
  3312. unsigned char key[ 20 ] = { 79, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
  3313. klient->setSendeKey( (char*)key, 20 );
  3314. klient->setEmpfangKey( (char*)key, 20 );
  3315. ret = ret & klient->verbinde( port, ip );
  3316. ret = ret & klient->sendeEncrypted( "\5\x13", 2 );
  3317. char res = 0;
  3318. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3319. if( res )
  3320. {
  3321. ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
  3322. ret = ret & klient->sendeEncrypted( (char*)&chatroomId, 4 );
  3323. ret = ret & klient->getNachrichtEncrypted( &res, 1 );
  3324. }
  3325. ret = (char)ret & res;
  3326. cs->addEmpfangen( klient->getDownloadBytes( 1 ) );
  3327. cs->addGesendet( klient->getUploadBytes( 1 ) );
  3328. klient->trenne();
  3329. klient = klient->release();
  3330. }
  3331. delete[]ip;
  3332. }
  3333. if( !ret )
  3334. letzterFehler->setText( "Der Account konnte nicht erreicht werden" );
  3335. return ret;
  3336. }
  3337. // constant
  3338. const char *MSGWeiterleitung::getLetzterFehler()
  3339. {
  3340. return letzterFehler->getText();
  3341. }