MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / SendMsg

Method SendMsg

engine/Poseidon/Network/NetTransportNet.cpp:1343–1431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1341 NetLog("NetClient::Init: address=%s, port=%d", address.GetLength() ? (const char*)address : "none", port);
1342#endif
1343#endif
1344 enterSnd();
1345 if (channel)
1346 { // already connected => error
1347 leaveSnd();
1348 return CRError;
1349 }
1350 magicApp = magic;
1351 RString ip;
1352 struct sockaddr_in daddr;
1353 if (address.GetLength() == 0)
1354 { // use "localhost"
1355 char buf[64];
1356 snprintf(buf, sizeof(buf), "127.0.0.1:%d", port);
1357 address = buf;
1358 }
1359 decodeURLAddress(address, ip, port);
1360 if (!getHostAddress(daddr, (const char*)ip, port))
1361 {
1362 leaveSnd();
1363 return CRError;
1364 }
1365 // now "daddr" contains valid IP address..
1366 sessionTerminated = false;
1367 whySessionTerminated = NTROther;
1368
1369 // create a new NetChannel for client <-> server communication:
1370 poolLock.enter();
1371 if (getPool())
1372 {
1373 channel = getPool()->createChannel(daddr, getClientPeer());
1374 }
1375 if (!channel)
1376 {
1377 poolLock.leave();
1378 leaveSnd();
1379 return CRError;
1380 }
1381 poolLock.leave();
1382
1383 channel->setProcessRoutine(clientReceive, channel);
1384
1385 amIBot = botClient;
1386
1387 // put together the "CreatePlayer" message:
1388 CreatePlayerPacket packet;
1389 packet.magic = MAGIC_CREATE_PLAYER;
1390 packet.magicApplication = magicApp;
1391 strncpy(packet.name, player, LEN_PLAYER_NAME);
1392 packet.name[LEN_PLAYER_NAME - 1] = (char)0;
1393 strncpy(packet.password, password, LEN_PASSWORD_NAME);
1394 packet.password[LEN_PASSWORD_NAME - 1] = (char)0;
1395 packet.actualVersion = versionInfo.versionActual;
1396 packet.requiredVersion = versionInfo.versionRequired;
1397 strncpy(packet.mod, versionInfo.mod, MOD_LENGTH);
1398 packet.mod[MOD_LENGTH - 1] = (char)0;
1399 strncpy(packet.versionTag, versionInfo.versionTag, VERSION_TAG_LENGTH);
1400 packet.versionTag[VERSION_TAG_LENGTH - 1] = (char)0;

Callers

nothing calls this directly

Calls 15

getServerPeerFunction · 0.85
getChannelIdMethod · 0.80
setFlagsMethod · 0.80
setOrderedPreviousMethod · 0.80
setDataMethod · 0.80
setCallbackMethod · 0.80
setSendTimeoutMethod · 0.80
getPeerIdMethod · 0.80
checkIntegrityMethod · 0.80
maxMessageDataMethod · 0.45
sendMethod · 0.45
getDataMethod · 0.45

Tested by

no test coverage detected