MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / process

Method process

Engine/source/console/telnetConsole.cpp:154–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154void TelnetConsole::process()
155{
156 NetAddress address;
157
158 if(mAcceptSocket != NetSocket::INVALID)
159 {
160 // ok, see if we have any new connections:
161 NetSocket newConnection;
162 newConnection = Net::accept(mAcceptSocket, &address);
163
164 if(newConnection != NetSocket::INVALID)
165 {
166 char buffer[256];
167 Net::addressToString(&address, buffer);
168 Con::printf("Telnet connection from %s", buffer);
169
170 TelnetClient *cl = new TelnetClient;
171 cl->socket = newConnection;
172 cl->curPos = 0;
173#if defined(TORQUE_SHIPPING) && defined(TORQUE_DISABLE_TELNET_CONSOLE_PASSWORD)
174 // disable the password in a ship build? WTF. lets make an error:
175 PleaseMakeSureYouKnowWhatYouAreDoingAndCommentOutThisLineIfSo.
176#elif !defined(TORQUE_SHIPPING) && defined(TORQUE_DISABLE_TELNET_CONSOLE_PASSWORD)
177 cl->state = FullAccessConnected;
178#else
179 cl->state = PasswordTryOne;
180#endif
181
182 Net::setBlocking(newConnection, false);
183
184 const char *prompt = Con::getVariable("Con::Prompt");
185 char connectMessage[1024];
186 dSprintf(connectMessage, sizeof(connectMessage),
187 "Torque Telnet Remote Console\r\n\r\n%s",
188 cl->state == FullAccessConnected ? prompt : "Enter Password:");
189
190 Net::send(cl->socket, (const unsigned char*)connectMessage, dStrlen(connectMessage)+1);
191 cl->nextClient = mClientList;
192 mClientList = cl;
193 }
194 }
195
196 char recvBuf[256];
197 char reply[1024];
198
199 // see if we have any input to process...
200
201 for(TelnetClient *client = mClientList; client; client = client->nextClient)
202 {
203 S32 numBytes;
204 Net::Error err = Net::recv(client->socket, (unsigned char*)recvBuf, sizeof(recvBuf), &numBytes);
205
206 if((err != Net::NoError && err != Net::WouldBlock) || numBytes == 0)
207 {
208 Net::closeSocket(client->socket);
209 client->socket = NetSocket::INVALID;
210 continue;
211 }

Callers

nothing calls this directly

Calls 6

printfFunction · 0.85
getVariableFunction · 0.85
dSprintfFunction · 0.85
dStrncmpFunction · 0.85
dStrlenFunction · 0.50
triggerMethod · 0.45

Tested by

no test coverage detected