diff --git a/chat.bsdesign b/chat.bsdesign index afcc1a0..820d849 100644 Binary files a/chat.bsdesign and b/chat.bsdesign differ diff --git a/main.c b/main.c index dd28acd..e8ce02b 100644 --- a/main.c +++ b/main.c @@ -183,6 +183,7 @@ int main(void) { char file[64]; int k = peer_getPeer(peerList1, sock); sprintf(file,"%s%s.txt",DEFAULT_WWW_FOLDER,peerList1.array[k].peerData.id); + logger_log("Message received from %s",peerList1.array[k].peerData.id); FILE *fp; fp = fopen(file,"a"); fprintf(fp,"%s\n",map_getValue(m,"message")); diff --git a/modules/webio/webio.c b/modules/webio/webio.c index 26abd6e..3fc5564 100644 --- a/modules/webio/webio.c +++ b/modules/webio/webio.c @@ -175,7 +175,7 @@ int webio_handleGETrequest(SOCKET client,WebIO wio,char* file,peerList list){ "Content-Language: en\r\n" "Content-Type: text/html\r\n\r\n" ); - strcat(response,getPeerPage(wio.folder,list.array[peer_getIDPeer(list,file)])); + strcat(response,getPeerPage(wio.folder,peer_getPeerByID(list,file) ) ); } else{ strcat(path, file); @@ -232,7 +232,7 @@ int webio_handlePOSTrequest(SOCKET client,WebIO wio,peerList list,map post){ sprintf(response, "HTTP/1.1 304 Not Modified " ); - //strcat(response,getPeerPage(wio.folder,)); + int res = send(client,response,strlen(response),0); if(res == SOCKET_ERROR ) { @@ -241,6 +241,12 @@ int webio_handlePOSTrequest(SOCKET client,WebIO wio,peerList list,map post){ } shutdown(client,SD_SEND); if(map_isFound(post,"id") && map_isFound(post,"message")){ + char file[64]; + sprintf(file,"%s%s.txt",wio.folder,map_getValue(post,"id")); + FILE * f; + f = fopen(file,"a"); + fprintf(f,"Me: %s\n",map_getValue(post,"message")); + fclose(f); char buf[DEFAULT_BUFLEN]; sprintf(buf,"@message=%s",map_getValue(post,"message")); res = send(list.array[peer_getIDPeer(list,map_getValue(post,"id"))].socket,buf,DEFAULT_BUFLEN,0); @@ -313,6 +319,55 @@ char *getPeerPage(char *folder, Peer p) { char * header = webio_getHeader(folder); sprintf(content,"%s\n" "