diff --git a/channel.c b/channel.c index 3dd3aa4..fd9381d 100644 --- a/channel.c +++ b/channel.c @@ -27,7 +27,7 @@ tuveSendAllInChan(channel,userConnection,output); /* Notify people in the channel that someone has joined */ - sprintf(output,"chanmsg:TUveD:%s:%s has joined the channel.\n",channel,userConnection->userInfo.username); + sprintf(output,"CHANMSG:TUveD:%s:%s has joined the channel.\n",channel,userConnection->userInfo.username); tuveSendAllInChan(channel,userConnection,output); return(0x0); @@ -42,7 +42,7 @@ tmpChan2 = tmpChan; for (;tmpChan != 0x0;tmpChan = tmpChan->next) { - sprintf(output,"chanmsg:TUveD:%s:%s Quit (%s)\n",tmpChan->channel,userConnection->userInfo.username,msg); + sprintf(output,"CHANMSG:TUveD:%s:%s Quit (%s)\n",tmpChan->channel,userConnection->userInfo.username,msg); tuveSendAllInChan(tmpChan->channel,userConnection,output); sprintf(output,"PART:%s:%s\n",tmpChan->channel,userConnection->userInfo.username); tuveSendAllInChan(tmpChan->channel,userConnection,output); @@ -123,7 +123,7 @@ tmpChannel = findChan(channel); if (tmpChannel == 0x0) { - writeLog("Channel %s Does Not Exist Adding To List\n",channel); + writeLog("Channel %s Does Not Exist Adding To List\n",channel); tmpChannel = addChan(channel); } @@ -158,10 +158,13 @@ else sprintf(output,"JOIN:%s:%s",tmpChannel->channel,tmpUsers->user->userInfo.username); } - sprintf(output,"%s\n",output); - send(userConnection->fd,output,strlen(output),MSG_NOSIGNAL); - sprintf(output,"TOPIC:%s:%s",tmpChannel->channel,tmpChannel->topic); + if (strlen(output) > 0) { + sprintf(output,"%s\n",output); + send(userConnection->fd,output,strlen(output),MSG_NOSIGNAL); + } + + sprintf(output,"TOPIC:%s:%s\n",tmpChannel->channel,tmpChannel->topic); send(userConnection->fd,output,strlen(output),MSG_NOSIGNAL); writeLog("Added user: %s to Channel: %s\n",userConnection->userInfo.username,channel); @@ -191,7 +194,7 @@ channels->prev = 0x0; channels->users = 0x0; sprintf(channels->channel,channel); - sprintf(channels->topic,"General Information About The TUve Network\n"); + sprintf(channels->topic,"No Topic Set"); writeLog("ADDED CHAN1\n"); tmpChannel = channels; } @@ -223,7 +226,9 @@ tmpUsers = tmpChannel->users; for (;tmpUsers != 0x0;tmpUsers = tmpUsers->next) { - if (strcasecmp(tmpUsers->user->userInfo.username,userConnection->userInfo.username)) { + if (userConnection == 0x0) + send(tmpUsers->user->fd,output,strlen(output),MSG_NOSIGNAL); + else if (strcasecmp(tmpUsers->user->userInfo.username,userConnection->userInfo.username)) { send(tmpUsers->user->fd,output,strlen(output),MSG_NOSIGNAL); } } @@ -244,6 +249,8 @@ sprintf(tmpChannel->topic,topic); sprintf(output,"TOPIC:%s:%s\n",chan,tmpChannel->topic); + tuveSendAllInChan(chan,0x0,output); + sprintf(output,"CHANMSG:TUveD:%s:%s Has Set The Topic\n",chan,userConnection->userInfo.username); tuveSendAllInChan(chan,userConnection,output); return(0x0); diff --git a/socket.c b/socket.c index 216a60e..bbee55f 100644 --- a/socket.c +++ b/socket.c @@ -225,11 +225,11 @@ tmpConnection->userInfo.pfailed++; tmpConnection->userInfo.pong = ping; if (tmpConnection->userInfo.ident == 0x1) - send(tmpConnection->fd,"PING",sizeof("PING"),MSG_NOSIGNAL); + send(tmpConnection->fd,"PING\n",sizeof("PING\n"),MSG_NOSIGNAL); } } else { - send(tmpConnection->fd,"TIMEOUT",sizeof("TIMEOUT"),MSG_NOSIGNAL); + send(tmpConnection->fd,"TIMEOUT\n",sizeof("TIMEOUT\n"),MSG_NOSIGNAL); tuveDelUserChans(tmpConnection,"TIMEOUT"); tmpConnection->userInfo.status = -1; } diff --git a/tuve.c b/tuve.c index 5b06933..ca3cd48 100644 --- a/tuve.c +++ b/tuve.c @@ -165,7 +165,7 @@ } else if (strcasecmp(cmd,"chanmsg") == 0x0) { msg = strtok_r(data,":",&tok_last); - sprintf(output,"chanmsg:%s:%s:%s\n",userConnection->userInfo.username,msg,strtok_r(NULL,"\n",&tok_last)); + sprintf(output,"CHANMSG:%s:%s:%s\n",userConnection->userInfo.username,msg,strtok_r(NULL,"\n",&tok_last)); tuveSendAllInChan(msg,userConnection,output); } else if (strcasecmp(cmd,"topic") == 0x0) {