Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 336 vs 337 for /trunk/Source Code/Server/Scenes/NetworkScene/tcp_session_impl.cpp

Diff revisions: vs.
  @@ -16,120 +16,120 @@
16 16
17 17 void tcp_session_impl::handlePacket(WorldPacket& p)
18 18 {
19 - switch(p.getOpcode())
20 - {
21 - case MSG_HEARTBEAT:
22 - std::cout << "Received [ MSG_HEARTBEAT ]" << std::endl;
23 - HandleHeartBeatOpCode(p);
24 - break;
25 - case CMSG_PING:
26 - std::cout << "Received [ CMSG_PING ]" << std::endl;
27 - HandlePingOpCode(p);
28 - break;
29 - case CMSG_REQUEST_DISCONNECT:
30 - HandleDisconnectOpCode(p);
31 - break;
32 - case CMSG_GEOMETRY_LIST:
33 - HandleGeometryListOpCode(p);
34 - break;
35 - case CMSG_REQUEST_GEOMETRY:
36 - HandleRequestGeometry(p);
37 - break;
38 - default:
39 - std::cout << "Received unknow OPCode [ 0x" << p.getOpcode() << " ]" << std::endl;
40 - break;
41 - };
19 + switch(p.getOpcode())
20 + {
21 + case MSG_HEARTBEAT:
22 + std::cout << "Received [ MSG_HEARTBEAT ]" << std::endl;
23 + HandleHeartBeatOpCode(p);
24 + break;
25 + case CMSG_PING:
26 + std::cout << "Received [ CMSG_PING ]" << std::endl;
27 + HandlePingOpCode(p);
28 + break;
29 + case CMSG_REQUEST_DISCONNECT:
30 + HandleDisconnectOpCode(p);
31 + break;
32 + case CMSG_GEOMETRY_LIST:
33 + HandleGeometryListOpCode(p);
34 + break;
35 + case CMSG_REQUEST_GEOMETRY:
36 + HandleRequestGeometry(p);
37 + break;
38 + default:
39 + std::cout << "Received unknow OPCode [ 0x" << p.getOpcode() << " ]" << std::endl;
40 + break;
41 + };
42 42 }
43 43 void tcp_session_impl::HandleHeartBeatOpCode(WorldPacket& p)
44 44 {
45 - WorldPacket r(MSG_HEARTBEAT);
46 - std::cout << "Sending [ MSG_HEARTBEAT]" << std::endl;
47 - r << (I8)0;
48 - sendPacket(r);
45 + WorldPacket r(MSG_HEARTBEAT);
46 + std::cout << "Sending [ MSG_HEARTBEAT]" << std::endl;
47 + r << (I8)0;
48 + sendPacket(r);
49 49 }
50 50
51 51 void tcp_session_impl::HandlePingOpCode(WorldPacket& p)
52 52 {
53 - F32 time = 0;
54 - p >> time;
55 - std::cout << "Sending [ SMSG_PONG ] with data: " << time << std::endl;
56 - WorldPacket r(SMSG_PONG);
57 - r << time;
58 - sendPacket(r);
53 + F32 time = 0;
54 + p >> time;
55 + std::cout << "Sending [ SMSG_PONG ] with data: " << time << std::endl;
56 + WorldPacket r(SMSG_PONG);
57 + r << time;
58 + sendPacket(r);
59 59 }
60 60
61 61 void tcp_session_impl::HandleDisconnectOpCode(WorldPacket& p)
62 62 {
63 - std::string client;
64 - p >> client;
65 - std::cout << "Received [ CMSG_REQUEST_DISCONNECT ] from: [ " << client << " ]" << std::endl;
66 - WorldPacket r(SMSG_DISCONNECT);
67 - r << (U8)0; //this will be the error code returned after safely saving client
68 - sendPacket(r);
63 + std::string client;
64 + p >> client;
65 + std::cout << "Received [ CMSG_REQUEST_DISCONNECT ] from: [ " << client << " ]" << std::endl;
66 + WorldPacket r(SMSG_DISCONNECT);
67 + r << (U8)0; //this will be the error code returned after safely saving client
68 + sendPacket(r);
69 69 }
70 70
71 71 void tcp_session_impl::HandleGeometryListOpCode(WorldPacket& p)
72 72 {
73 - PatchData data;
74 - p >> data.sceneName;
75 - p >> data.size;
76 - std::cout << "Received [ CMSG_GEOMERTY_LIST ] with : " << data.size << " models" << std::endl;
77 - for(U32 i = 0; i < data.size; i++)
78 - {
79 - stringImpl name, modelname;
80 - U32 version = 0;
81 - p >> name;
82 - p >> modelname;
83 - p >> version;
84 - data.name.push_back(name);
85 - data.modelName.push_back(modelname);
86 - data.version.push_back(version);
87 - }
88 - bool updated = Patch::getInstance().compareData(data);
89 -
90 - if(!updated)
91 - {
92 - WorldPacket r(SMSG_GEOMETRY_APPEND);
93 -
94 - vectorImpl<FileData> PatchData = Patch::getInstance().updateClient();
95 - r << PatchData.size();
96 - for(vectorImpl<FileData>::iterator _iter = PatchData.begin(); _iter != PatchData.end(); _iter++)
97 - {
98 - r << (*_iter).ItemName;
99 - r << (*_iter).ModelName;
100 - r << (*_iter).orientation.x;
101 - r << (*_iter).orientation.y;
102 - r << (*_iter).orientation.z;
103 - r << (*_iter).position.x;
104 - r << (*_iter).position.y;
105 - r << (*_iter).position.z;
106 - r << (*_iter).scale.x;
107 - r << (*_iter).scale.y;
108 - r << (*_iter).scale.z;
109 - if((*_iter).type == MESH)
110 - r << 0;
111 - else if((*_iter).type == VEGETATION)
112 - r << 1;
113 - else
114 - r << 2;
115 - r << (*_iter).version;
116 - }
117 - std::cout << "Sending [SMSG_GEOMETRY_APPEND] with : " << PatchData.size() << " models to update" << std::endl;
118 - sendPacket(r);
119 - Patch::getInstance().reset();
120 - }
73 + PatchData data;
74 + p >> data.sceneName;
75 + p >> data.size;
76 + std::cout << "Received [ CMSG_GEOMERTY_LIST ] with : " << data.size << " models" << std::endl;
77 + for(U32 i = 0; i < data.size; i++)
78 + {
79 + stringImpl name, modelname;
80 + U32 version = 0;
81 + p >> name;
82 + p >> modelname;
83 + p >> version;
84 + data.name.push_back(name);
85 + data.modelName.push_back(modelname);
86 + data.version.push_back(version);
87 + }
88 + bool updated = Patch::getInstance().compareData(data);
89 +
90 + if(!updated)
91 + {
92 + WorldPacket r(SMSG_GEOMETRY_APPEND);
93 +
94 + vectorImpl<FileData> PatchData = Patch::getInstance().updateClient();
95 + r << PatchData.size();
96 + for(vectorImpl<FileData>::iterator _iter = PatchData.begin(); _iter != PatchData.end(); _iter++)
97 + {
98 + r << (*_iter).ItemName;
99 + r << (*_iter).ModelName;
100 + r << (*_iter).orientation.x;
101 + r << (*_iter).orientation.y;
102 + r << (*_iter).orientation.z;
103 + r << (*_iter).position.x;
104 + r << (*_iter).position.y;
105 + r << (*_iter).position.z;
106 + r << (*_iter).scale.x;
107 + r << (*_iter).scale.y;
108 + r << (*_iter).scale.z;
109 + if((*_iter).type == MESH)
110 + r << 0;
111 + else if((*_iter).type == VEGETATION)
112 + r << 1;
113 + else
114 + r << 2;
115 + r << (*_iter).version;
116 + }
117 + std::cout << "Sending [SMSG_GEOMETRY_APPEND] with : " << PatchData.size() << " models to update" << std::endl;
118 + sendPacket(r);
119 + Patch::getInstance().reset();
120 + }
121 121 }
122 122
123 123 void tcp_session_impl::HandleRequestGeometry(WorldPacket& p)
124 124 {
125 - stringImpl file;
126 - p >> file;
125 + stringImpl file;
126 + p >> file;
127 127
128 - std::cout << "Sending SMSG_SEND_FILE with item: " << stringAlg::fromBase(file) << std::endl;
129 - WorldPacket r(SMSG_SEND_FILE);
130 - r << (U8)0;
131 - sendPacket(r);
132 - sendFile(file);
128 + std::cout << "Sending SMSG_SEND_FILE with item: " << stringAlg::fromBase(file) << std::endl;
129 + WorldPacket r(SMSG_SEND_FILE);
130 + r << (U8)0;
131 + sendPacket(r);
132 + sendFile(file);
133 133 }
134 134
135 135 }; //namespace Divide