Subversion Repository Public Repository

Divide-Framework

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "Headers/tcp_session_impl.h"

#include "Server/Headers/Server.h"
#include "Server/Utility/Headers/Patch.h"

#include "Scenes/NetworkScene/Network/Headers/OPCodesImpl.h"

#include <iostream>

namespace Divide {

tcp_session_impl::tcp_session_impl(boost::asio::io_service& io_service,
                                   channel& ch)
    : tcp_session_tpl(io_service, ch) {}

void tcp_session_impl::handlePacket(WorldPacket& p) {
    switch (p.opcode()) {
        case OPCodesEx::MSG_HEARTBEAT:
            std::cout << "Received [ MSG_HEARTBEAT ]" << std::endl;
            HandleHeartBeatOpCode(p);
            break;
        case OPCodesEx::CMSG_PING:
            std::cout << "Received [ CMSG_PING ]" << std::endl;
            HandlePingOpCode(p);
            break;
        case OPCodesEx::CMSG_REQUEST_DISCONNECT:
            HandleDisconnectOpCode(p);
            break;
        case OPCodesEx::CMSG_GEOMETRY_LIST:
            HandleGeometryListOpCode(p);
            break;
        case OPCodesEx::CMSG_REQUEST_GEOMETRY:
            HandleRequestGeometry(p);
            break;
        default:
            std::cout << "Received unknow OPCode [ 0x" << p.opcode() << " ]"
                      << std::endl;
            break;
    };
}
void tcp_session_impl::HandleHeartBeatOpCode(WorldPacket& p) {
    ACKNOWLEDGE_UNUSED(p);

    WorldPacket r(OPCodesEx::MSG_HEARTBEAT);
    std::cout << "Sending  [ MSG_HEARTBEAT]" << std::endl;
    r << (I8)0;
    sendPacket(r);
}

void tcp_session_impl::HandlePingOpCode(WorldPacket& p) {
    F32 time = 0;
    p >> time;
    std::cout << "Sending  [ SMSG_PONG ] with data: " << time << std::endl;
    WorldPacket r(OPCodesEx::SMSG_PONG);
    r << time;
    sendPacket(r);
}

void tcp_session_impl::HandleDisconnectOpCode(WorldPacket& p) {
    stringImpl client;
    p >> client;
    std::cout << "Received [ CMSG_REQUEST_DISCONNECT ] from: [ " << client
              << " ]" << std::endl;
    WorldPacket r(OPCodesEx::SMSG_DISCONNECT);
    r << (U8)0;  // this will be the error code returned after safely saving
                 // client
    sendPacket(r);
}

void tcp_session_impl::HandleGeometryListOpCode(WorldPacket& p) {
    PatchData data;
    p >> data.sceneName;
    p >> data.size;
    std::cout << "Received [ CMSG_GEOMERTY_LIST ] with : " << data.size
              << " models" << std::endl;
    for (U32 i = 0; i < data.size; i++) {
        stringImpl name, modelname;
        U32 version = 0;
        p >> name;
        p >> modelname;
        p >> version;
        data.name.push_back(name);
        data.modelName.push_back(modelname);
        data.version.push_back(to_float(version));
    }
    bool updated = Patch::instance().compareData(data);

    if (!updated) {
        WorldPacket r(OPCodesEx::SMSG_GEOMETRY_APPEND);

        vectorImpl<FileData> PatchData = Patch::instance().updateClient();
        r << PatchData.size();
        for (vectorImpl<FileData>::iterator _iter = std::begin(PatchData);
             _iter != std::end(PatchData); _iter++) {
            r << (*_iter).ItemName;
            r << (*_iter).ModelName;
            r << (*_iter).orientation.x;
            r << (*_iter).orientation.y;
            r << (*_iter).orientation.z;
            r << (*_iter).position.x;
            r << (*_iter).position.y;
            r << (*_iter).position.z;
            r << (*_iter).scale.x;
            r << (*_iter).scale.y;
            r << (*_iter).scale.z;
            if ((*_iter).type == GeometryType::MESH) {
                r << 0;
            } else if ((*_iter).type == GeometryType::VEGETATION) {
                r << 1;
            } else {
                r << 2;
            }
            r << (*_iter).version;
        }
        std::cout << "Sending [SMSG_GEOMETRY_APPEND] with : "
                  << PatchData.size() << " models to update" << std::endl;
        sendPacket(r);
        Patch::instance().reset();
    }
}

void tcp_session_impl::HandleRequestGeometry(WorldPacket& p) {
    stringImpl file;
    p >> file;

    std::cout << "Sending SMSG_SEND_FILE with item: " << file << std::endl;
    WorldPacket r(OPCodesEx::SMSG_SEND_FILE);
    r << (U8)0;
    sendPacket(r);
    sendFile(file);
}

};  // namespace Divide

Commits for Divide-Framework/trunk/Source Code/Server/Scenes/NetworkScene/tcp_session_impl.cpp

Diff revisions: vs.
Revision Author Commited Message
827 Diff Diff IonutCava picture IonutCava Sun 22 Jan, 2017 21:59:36 +0000

[IonutCava]
- ShaderBuffers now decide heuristically if they get persistently mapped or not (depends on size. Current limit is 512Kb for subData calls.
- Separate visible node command generation into 2 steps: onRender and getDrawPackage. onRender allows the creation of parallel tasks that should finish by the time the second call, getDrawPackage reaches the same node
- Update ParticleEmitter to take into account multiple players and increase parallelism at the cost of memory consumption and complexity.
- Add a default bounding box for Players (add extents to SceneTransform nodes)
- All buffers (ShaderBuffer, d3dConstantBuffer, glUniformBuffer, glBufferImpl, glGenericBuffer, etc) use BufferParams for creation.
— Constructor and create calls have been merged together

670 Diff Diff IonutCava picture IonutCava Wed 06 Apr, 2016 16:21:35 +0000

[IonutCava]
- getInstance() renamed to instance() for simplicity (should really go away altogether, but that’s a different issue)
- some particle emitter threading updates

466 Diff Diff IonutCava picture IonutCava Fri 05 Jun, 2015 15:07:17 +0000

[Ionut]
- Moved EASTL, SimpleINI and Threadpool libraries from Dependencies repo to engine repo
- Disabled EASTL string and vector support as they are really out of date and missing required features.
— EASTL hash map is still usable

456 Diff Diff IonutCava picture IonutCava Mon 01 Jun, 2015 16:11:31 +0000

[Ionut]
- More linux port work (does not compile)

444 Diff Diff IonutCava picture IonutCava Thu 21 May, 2015 16:06:53 +0000

[Ionut]
- More platform independent code cleanup:
— Moved platform specific defines to their respective header files (e.g. THREAD_LOCAL)
— Moved most preprocessor defines from the VisualC++ projects into source code
— Removed compiler specific code (e.g. warning disables) and fixed most warning resulting from this

395 Diff Diff IonutCava picture IonutCava Wed 01 Apr, 2015 16:06:28 +0000

[Ionut]
- Shader management improvements
- More singleton fixes
- Automatic core count detection and threadpool adjustment at startup
- Replaced most static C-arrays with std::array
- Replace most file manipulation code from C-style FILE based system to ifstream/ofstream

366 Diff Diff IonutCava picture IonutCava Tue 10 Mar, 2015 16:56:30 +0000

[Ionut]
- More type safe enum replacement

353 Diff Diff IonutCava picture IonutCava Tue 17 Feb, 2015 17:08:27 +0000

[Ionut]
- Compatibility updates for Boost 1.57 (some warnings still exist for now)
- Fixed some non-conforming code
- Added ALL OF THE MISSING FILES FROM THE LAST 15 commits ...........

350 Diff Diff IonutCava picture IonutCava Tue 10 Feb, 2015 16:25:39 +0000

[Ionut]
- Simplified some Util-namespace level functions by using STL algorithms where possible
- Formatted the entire codebase using clang-format with the following style: "{BasedOnStyle: Google, IndentWidth: 4}"
- Attempted to make ProfileTimer thread-safe (temp fix until std::chrono works properly in Visual Studio)

347 IonutCava picture IonutCava Thu 05 Feb, 2015 13:39:09 +0000

[Ionut]
- Changed all begin/end calls on containers to non-member versions
- Replaced all useless “auto” keywords from code. (“auto” only makes sense for return values for delegate functions)
- Replaced useless code in Util::Mat4::Multiply with something that makes sense