| 562 | { |
| 563 | public: |
| 564 | TargetControl(Network::Socket *sock, rdcstr clientName, bool forceConnection) |
| 565 | : m_Socket(sock), |
| 566 | reader(new StreamReader(sock, Ownership::Nothing), Ownership::Stream), |
| 567 | writer(new StreamWriter(sock, Ownership::Nothing), Ownership::Stream) |
| 568 | { |
| 569 | bytebuf payload; |
| 570 | |
| 571 | writer.SetStreamingMode(true); |
| 572 | reader.SetStreamingMode(true); |
| 573 | |
| 574 | m_PID = 0; |
| 575 | |
| 576 | { |
| 577 | WRITE_DATA_SCOPE(); |
| 578 | |
| 579 | { |
| 580 | SCOPED_SERIALISE_CHUNK(ePacket_Handshake); |
| 581 | SERIALISE_ELEMENT(TargetControlProtocolVersion); |
| 582 | SERIALISE_ELEMENT(clientName); |
| 583 | SERIALISE_ELEMENT(forceConnection); |
| 584 | } |
| 585 | |
| 586 | if(writer.IsErrored()) |
| 587 | { |
| 588 | SAFE_DELETE(m_Socket); |
| 589 | return; |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | PacketType type = reader.ReadChunk<PacketType>(); |
| 594 | |
| 595 | if(reader.IsErrored()) |
| 596 | { |
| 597 | SAFE_DELETE(m_Socket); |
| 598 | return; |
| 599 | } |
| 600 | |
| 601 | if(type != ePacket_Handshake && type != ePacket_Busy) |
| 602 | { |
| 603 | RDCERR("Expected handshake packet, got %d", type); |
| 604 | SAFE_DELETE(m_Socket); |
| 605 | } |
| 606 | |
| 607 | // failed handshaking |
| 608 | if(m_Socket == NULL) |
| 609 | return; |
| 610 | |
| 611 | m_Version = 0; |
| 612 | |
| 613 | if(type == ePacket_Handshake) |
| 614 | { |
| 615 | READ_DATA_SCOPE(); |
| 616 | SERIALISE_ELEMENT(m_Version); |
| 617 | SERIALISE_ELEMENT(m_Target); |
| 618 | SERIALISE_ELEMENT(m_PID); |
| 619 | } |
| 620 | else if(type == ePacket_Busy) |
| 621 | { |
nothing calls this directly
no test coverage detected