live_peer.h

main 95 lines · 2.5 KB Raw
Alex Alex Commit Map Editor 18/10/2026 23:40
1//////////////////////////////////////////////////////////////////////
2// This file is part of Remere's Map Editor
3//////////////////////////////////////////////////////////////////////
4// Remere's Map Editor is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Remere's Map Editor is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//////////////////////////////////////////////////////////////////////
17
18#ifndef _RME_LIVE_PEER_H_
19#define _RME_LIVE_PEER_H_
20
21#include "live_socket.h"
22#include "net_connection.h"
23
24class LiveServer;
25class LivePeer : public LiveSocket {
26public:
27 LivePeer(LiveServer* server, boost::asio::ip::tcp::socket socket);
28 ~LivePeer();
29
30 void close();
31 bool handleError(const boost::system::error_code& error);
32
33 //
34 uint32_t getId() const {
35 return id;
36 }
37 uint32_t getClientId() const {
38 return clientId;
39 }
40
41 std::string getHostName() const;
42
43 wxColor getUsedColor() const {
44 return color;
45 }
46 void setUsedColor(const wxColor& newColor) {
47 color = newColor;
48 }
49
50 //
51 void receiveHeader() override;
52 void receive(uint32_t packetSize) override;
53 void send(NetworkMessage& message) override;
54 void sendChat(const wxString& chatMessage) override;
55
56 //
57 void updateCursor(const Position& position) override;
58
59protected:
60 void parseLoginPacket(NetworkMessage message);
61 void parseEditorPacket(NetworkMessage message);
62
63 // login packets
64 void parseHello(NetworkMessage& message);
65 void parseReady(NetworkMessage& message);
66
67 // editor packets
68 void parseNodeRequest(NetworkMessage& message);
69 void parseReceiveChanges(NetworkMessage& message);
70 void parseAddHouse(NetworkMessage& message);
71 void parseEditHouse(NetworkMessage& message);
72 void parseRemoveHouse(NetworkMessage& message);
73 void parseCursorUpdate(NetworkMessage& message);
74 void parseChatMessage(NetworkMessage& message);
75 void parseClientColorUpdate(NetworkMessage& message);
76
77 //
78 NetworkMessage readMessage;
79
80 LiveServer* server;
81 boost::asio::ip::tcp::socket socket;
82
83 wxColor color;
84
85 uint32_t id;
86 uint32_t clientId;
87
88 bool connected;
89
90 friend class LiveLogTab;
91 friend class LiveServer;
92};
93
94#endif
95
Top