QTfrontend/newnetclient.cpp
changeset 1308 d5dcd6cfa5e2
parent 1307 ce26e16d18ab
child 1310 4616e15d566f
equal deleted inserted replaced
1307:ce26e16d18ab 1308:d5dcd6cfa5e2
   107   RawSendNet(str.toUtf8());
   107   RawSendNet(str.toUtf8());
   108 }
   108 }
   109 
   109 
   110 void HWNewNet::RawSendNet(const QByteArray & buf)
   110 void HWNewNet::RawSendNet(const QByteArray & buf)
   111 {
   111 {
   112   qDebug() << "Client: " << buf;
   112   qDebug() << "Client: " << QString(buf).split("\n");
   113   NetSocket.write(buf);
   113   NetSocket.write(buf);
   114   NetSocket.write("\n\n", 2);
   114   NetSocket.write("\n\n", 2);
   115 }
   115 }
   116 
   116 
   117 void HWNewNet::ClientRead()
   117 void HWNewNet::ClientRead()
   169 	{
   169 	{
   170 		qWarning("Net client: Bad message");
   170 		qWarning("Net client: Bad message");
   171 		return;
   171 		return;
   172 	}
   172 	}
   173 
   173 
       
   174 	if ((lst[0] == "NICK") || (lst[0] == "PROTO"))
       
   175 		return ;
       
   176 
   174 	if (lst[0] == "ERROR") {
   177 	if (lst[0] == "ERROR") {
   175 		if (lst.size() == 2)
   178 		if (lst.size() == 2)
   176 			QMessageBox::information(0, 0, "Error: " + lst[1]);
   179 			QMessageBox::information(0, 0, "Error: " + lst[1]);
   177 		else
   180 		else
   178 			QMessageBox::information(0, 0, "Unknown error");
   181 			QMessageBox::information(0, 0, "Unknown error");
   185 		else
   188 		else
   186 			QMessageBox::information(0, 0, "Unknown warning");
   189 			QMessageBox::information(0, 0, "Unknown warning");
   187 		return;
   190 		return;
   188 	}
   191 	}
   189 
   192 
   190   if (lst[0] == "CONNECTED") {
   193 	if (lst[0] == "CONNECTED") {
   191     m_game_connected=true;
   194 		m_game_connected=true;
   192     emit Connected();
   195 		emit Connected();
   193     emit EnteredGame();
   196 		emit EnteredGame();
   194     return;
   197 		return;
   195   }
   198 	}
   196 
   199 
   197   if (lst[0] == "CHAT_STRING") {
   200 	if (lst[0] == "CHAT_STRING") {
   198     if(lst.size() < 3)
   201 		if(lst.size() < 3)
   199     {
   202 		{
   200 	  qWarning("Net: Empty CHAT_STRING message");
   203 		qWarning("Net: Empty CHAT_STRING message");
   201 	  return;
   204 		return;
   202     }
   205 		}
   203     QStringList tmp = lst;
   206 		QStringList tmp = lst;
   204     tmp.removeFirst();
   207 		tmp.removeFirst();
   205     emit chatStringFromNet(tmp);
   208 		emit chatStringFromNet(tmp);
   206     return;
   209 		return;
   207   }
   210 	}
   208 
   211 
   209   if (lst[0] == "ADDTEAM:") {
   212   if (lst[0] == "ADDTEAM:") {
   210     if(lst.size() < 22)
   213     if(lst.size() < 22)
   211     {
   214     {
   212 	  qWarning("Net: Too short ADDTEAM message");
   215 	  qWarning("Net: Too short ADDTEAM message");
   226     }
   229     }
   227     m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1], lst[2].toUInt()));
   230     m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1], lst[2].toUInt()));
   228     return;
   231     return;
   229   }
   232   }
   230 
   233 
   231   if(lst[0]=="SLAVE") {
   234 /*	if(lst[0] == "SLAVE") { // клиент знает CREATE он делал или JOIN
   232     m_pGameCFGWidget->setEnabled(false);
   235 		m_pGameCFGWidget->setEnabled(false);
   233     m_pTeamSelWidget->setNonInteractive();
   236 		m_pTeamSelWidget->setNonInteractive();
   234     return;
   237 		return;
   235   }
   238 	}*/
   236 
   239 
   237   if(lst[0]=="JOINED") {
   240 	if(lst[0]=="JOINED") {
   238     if(lst.size() < 2)
   241 		if(lst.size() < 2)
   239     {
   242 		{
   240       qWarning("Net: Bad JOINED message");
   243 			qWarning("Net: Bad JOINED message");
   241       return;
   244 			return;
   242     }
   245 		}
   243     emit nickAdded(lst[1]);
   246 		for(int i = 1; i < lst.size(); ++i)
   244     return;
   247 			emit nickAdded(lst[i]);
   245   }
   248 		return;
       
   249 	}
   246 
   250 
   247   if(lst[0]=="LEFT") {
   251   if(lst[0]=="LEFT") {
   248     if(lst.size() < 2)
   252     if(lst.size() < 2)
   249     {
   253     {
   250       qWarning("Net: Bad LEFT message");
   254       qWarning("Net: Bad LEFT message");