#include "StdAfx.h" #include "gconect_srv.h" //***************************************************************************************************************** Cgconect_srv::Cgconect_srv(void) { nconex=0; fin=FALSE; } //***************************************************************************************************************** Cgconect_srv::~Cgconect_srv(void) { } //***************************************************************************************************************** void Cgconect_srv::log_ext( __time64_t tiemp, char *modulo, char *fmt ) { Msg_evento_log m; m.tiempo=tiemp; strcpy(m.nivel,modulo); strcpy(m.nivel,fmt); inter_msg.entro(); mens+m; inter_msg.salgo(); } //***************************************************************************************************************** Cproceso_cliente* Cgconect_srv::crea_cliente( void ) { if (fin) return NULL; Cclient_gconect_srv *cli=new Cclient_gconect_srv(); if (!cli) return NULL; strcpy(cli->nombre, "Cliente gconex_srv"); cli->principal = this; nconex++; return cli; } //***************************************************************************************************************** //***************************************************************************************************************** void Cclient_gconect_srv::rum() { int nv=0;//numero de veces esperando sin recivir nada int nb;//numero de bytes recividos en el paquete BOOL procesa=FALSE;//indica si hay paquetes a procesar BYTE *buffer;//buffer donde se almacena paquete recibido BYTE buf[256];//buffer secundario de envios Usuario_conx_0 *usu=NULL;//usuario logeado codifica=FALSE;//indica si la comunicacion va cifrada while(!*soc->pirate && nv<6000 && !principal->fin) { //pillapaquete----------------------------------------- if(!soc->recibe_package(0)) { Sleep(10); nv++; } else { if (soc->cab.nb>0) { nb=soc->cab.nb; procesa=TRUE; codifica=0; nv=0; if (soc->cab.flags & FLAG_PACKAGE_HEAD_0_ENCRIPT1) codifica=1; } } if (nbfin ) continue; nv=0; procesa=FALSE; //se resta lo que ocupa el entero nb-=sizeof(int); if (nb>0) buffer=&soc->buf[sizeof(int)]; else buffer=FALSE; //procesa paquete------------------------------------------------------------------- switch(*(int*)soc->buf) { case PETICION_GENERAL_PRESENTA: { break; } case PETICION_GENERAL_OK: { //theApp.log.loguea(_time64(NULL),"cliente","Recivido paquete ok"); buf[0]=PETICION_GENERAL_OK; soc->envia_package(buf,1,codifica); break; } case PETICION_GENERAL_DESCONECTA: { break; } case PETICION_GENERAL_DAME_LOG://hace falta login { break; } case PETICION_GENERAL_TOMA_COMANDO://hace falta login { principal->escucha->on_recivido(soc,buffer,nb); break; } default://paquete desconocido se cierra socket { *soc->pirate=TRUE;//sale el thead } } } //descontamos thread--------------------------------------------------------- principal->escucha->borra_cliente(this); } //*****************************************************************************************************************