Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFNUL  (Read 53766 times)

0 Members and 1 Guest are viewing this topic.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: SFNUL
« Reply #30 on: February 23, 2014, 08:32:09 pm »
I can not believe that such a briliant piece of code is not buildable in windows. I dont want to believe it.

It is possible to build SFNUL using MSVC 2013, I just did it myself. Here is what it took for me to get it to build.

  • Add "BOTAN_DLL=" to the preprocessor
  • Add "NOEXCEPT=" to the preprocessor
  • Add "__func__=__FUNCTION__" to the preprocessor
  • Replace all instances of "noexcept" keyword with "NOEXCEPT" including in the external libraries
  • Add default constructors to the Botan::HTTP::Response and Botan::OCSP::Response classes

Also change the code in tls_channel.h

from:
      std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states =
         { { 0, nullptr } };
      std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states =
         { { 0, nullptr } };

to:
      std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states;
      std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states;

and the code in tls_channel.cpp

from:
Channel::Channel(std::function<void (const byte[], size_t)> output_fn,
                 std::function<void (const byte[], size_t)> data_cb,
                 std::function<void (Alert, const byte[], size_t)> alert_cb,
                 std::function<bool (const Session&)> handshake_cb,
                 Session_Manager& session_manager,
                 RandomNumberGenerator& rng,
                 size_t reserved_io_buffer_size) :
   m_handshake_cb(handshake_cb),
   m_data_cb(data_cb),
   m_alert_cb(alert_cb),
   m_output_fn(output_fn),
   m_rng(rng),
   m_session_manager(session_manager)
   {
   m_writebuf.reserve(reserved_io_buffer_size);
   m_readbuf.reserve(reserved_io_buffer_size);
   }

to:
Channel::Channel(std::function<void (const byte[], size_t)> output_fn,
                 std::function<void (const byte[], size_t)> data_cb,
                 std::function<void (Alert, const byte[], size_t)> alert_cb,
                 std::function<bool (const Session&)> handshake_cb,
                 Session_Manager& session_manager,
                 RandomNumberGenerator& rng,
                 size_t reserved_io_buffer_size) :
   m_handshake_cb(handshake_cb),
   m_data_cb(data_cb),
   m_alert_cb(alert_cb),
   m_output_fn(output_fn),
   m_rng(rng),
   m_session_manager(session_manager),
   m_write_cipher_states(),
   m_read_cipher_states()
   {
   m_write_cipher_states.insert({ 0, nullptr });
   m_read_cipher_states.insert({ 0, nullptr });
   m_writebuf.reserve(reserved_io_buffer_size);
   m_readbuf.reserve(reserved_io_buffer_size);
   }
« Last Edit: February 24, 2014, 02:53:37 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: SFNUL
« Reply #31 on: February 23, 2014, 09:16:00 pm »
The old style replacement for noexcept (with a slightly different meaning) would be an empty "throw()" clause.

TypeOverride

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: SFNUL
« Reply #32 on: February 24, 2014, 02:43:17 am »
Thanks guys for helping me here. Sry to be such a rookie.

I hope i will get it working tomorrow. Only for checking if im doing it right:

root folder is C:\SFNUL

1) GIT for C:\SFNUL (Right Mouse -> Git Bash)
$ git clone https://github.com/binary1248/SFNUL.git

2) GIT for C:\SFNUL\SFNUL (Right Mouse -> Git Bash)
$ git submodule update --init --recursive

3) CMAKE (over DOS-prompt)
<E:\GIT\SFNUL\SFNUL> C:\"Program Files (x86)"\"CMake 2.8"\bin\cmake .

Is this all? What does he mean with

make install (as root)

on https://github.com/binary1248/SFNUL ?

Do i miss a step?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: SFNUL
« Reply #33 on: February 24, 2014, 03:01:08 am »
Quote
make install

Those are commands just for linux. After you generate a project file with cmake you then just need to follow what I posted above.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

io

  • Jr. Member
  • **
  • Posts: 52
  • z/OS by day, SFML by night
    • View Profile
Re: SFNUL
« Reply #34 on: February 24, 2014, 03:36:45 am »
Hey Binary,

I remember you mentioning this library a while back to me in pm. I'm still lurking around here, just low on time :(.  Wanted to pop in and just say congrats and thanks for releasing this! 

I'm sure it is quality and I look forward to using it when I have the time to get into game coding again :)


TypeOverride

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: SFNUL
« Reply #35 on: February 24, 2014, 07:34:08 am »
I can not believe that such a briliant piece of code is not buildable in windows. I dont want to believe it.

It is possible to build SFNUL using MSVC 2013, I just did it myself. Here is what it took for me to get it to build.

  • Add "BOTAN_DLL=" to the preprocessor
  • Add "NOEXCEPT=" to the preprocessor
  • Add "__func__=__FUNCTION__" to the preprocessor
  • Replace all instances of "noexcept" keyword with "NOEXCEPT" including in the external libraries
  • Add default constructors to the Botan::HTTP::Response and Botan::OCSP::Response classes

Thanks a lot. I am very close to the goal ^^.

i did every step and i get this error now (perhaps i did the constructor thing wrong?)


Error   4   error C2664: 'std::map<Botan::u16bit,std::shared_ptr<Botan::TLS::Connection_Cipher_State>,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>::map(std::initializer_list<std::pair<const _Kty,_Ty>>,const std::less<_Kty> &,const std::allocator<std::pair<const _Kty,_Ty>> &)' : cannot convert argument 1 from 'initializer-list' to 'const std::allocator<std::pair<const _Kty,_Ty>> &'   E:\GIT\SFNUL\SFNUL\extlibs\botan\include\botan\tls_channel.h   245   1   sfnul

the error occurs in tls_channel.h on
std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states =
         { { 0, nullptr } };
      std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states =
         { { 0, nullptr } };

what i did before was simple:

extlibs\botan\src\lib\utils\http_util\http_util.h
extlibs\botan\include\botan\http_util.h

Response() {}

and to

extlibs\botan\src\lib\cert\x509\http_util.h
extlibs\botan\include\botan\http_util.h

 Response() {}


Edit: Ok i compiled it success.

In tls_channel.h i did:
     std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states; // =
        // { { 0, nullptr } };
     std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states; // =
         //{ { 0, nullptr } };


And in tls_channel.cpp i did in the Channel::Channel(..) constructor

m_write_cipher_states.insert(std::pair<u16bit, std::shared_ptr<Connection_Cipher_State>>(0, nullptr));
   m_read_cipher_states.insert(std::pair<u16bit, std::shared_ptr<Connection_Cipher_State>>(0, nullptr));


I think its a compiler bug. With this it is compilable. Now i have to check if it is runnable at runtime.

Thanks guys!!!!!


« Last Edit: February 24, 2014, 02:34:07 pm by TypeOverride »

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: SFNUL
« Reply #36 on: February 24, 2014, 10:15:50 am »
Hi!

Which networking libraries did you use for your project ?

Personally I only use Openssl for the networking and it works well on windows. (Except the extensions for the SSL certificates which give me compilation errors so I generate random keys and I put them into a certificate automatically in the library because I just need the hashing keys and not all the certificates stuff and verifications.

I don't think you need to do all verifications that the SSL protocol does to have a secure network communication.

For the rest of the functionnalities it doesn't mind for me to use the selectors and the sfml base classes, it's what I use for my project but, I'm curious so I would like to know how do you proceed to do assynchroneous communication, did you use a thread ?

In my project I just have a server and a client class which use a thread to recieve messages and put them into a stack of another class, and the user can process the datas when he want.

And I use a selector in this thread.

I have also a mutex to lock the socket when the server or the client receive or send a packet to avoid to have concurrent thread access on the socket because the messages are send inthe main thread and are received in another thread. (I was having hard to find this bug because I've forgot to use the mutex)

Do you also process like that or, do you have another system ?

PS: I'll also put that in my framework because I'm pised off to use the same code for all of my projects.




« Last Edit: February 24, 2014, 10:24:20 am by Lolilolight »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10909
    • View Profile
    • development blog
    • Email
Re: SFNUL
« Reply #37 on: February 24, 2014, 11:08:44 am »
Why don't you simply look at the source code? Or well at least read the README?

Quote from: README on GitHub
Dependencies:
 - ASIO (standalone C++11 version) provided in extlibs as a submodule
 - Botan provided in extlibs as a submodule
 - http-parser provided in extlibs as a submodule
 - SFML 2.x for the optional SFML synchronization example (http://sfml-dev.org/)

ASIO is used for the basic networking. Botan is used to TLS. For details look at the source code.
« Last Edit: February 24, 2014, 11:17:53 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: SFNUL
« Reply #38 on: February 24, 2014, 12:01:57 pm »
:o

I don't know this library : Botan.

So I've used openssl directly.

If only I've known that such a library exist..., but too late now. ^^ (I've already rewritten this with openssl for the encryption)








TypeOverride

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: SFNUL
« Reply #39 on: February 24, 2014, 02:39:49 pm »
I compiled it success under Visual Studio 2013.

After each step "zsbzsb" gave me (Thanks! Thanks! Thanks!).
I had todo last one step. I think its a compiler bug workaround here.

------
In tls_channel.h i did:
     std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states; // =
        // { { 0, nullptr } };
     std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states; // =
         //{ { 0, nullptr } };

And in tls_channel.cpp i did in the Channel::Channel(..) constructor
     m_write_cipher_states.insert(std::pair<u16bit, std::shared_ptr<Connection_Cipher_State>>(0, nullptr));
     m_read_cipher_states.insert(std::pair<u16bit, std::shared_ptr<Connection_Cipher_State>>(0, nullptr));
------

Now i have to check if it is all running at runtime.

Thanks guys!!!!!
« Last Edit: February 24, 2014, 02:41:57 pm by TypeOverride »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: SFNUL
« Reply #40 on: February 24, 2014, 02:47:40 pm »
Sorry about that TypeOverride, I had to do the same thing and forgot to mention it.  ;)

Also I updated my above post.  :)
« Last Edit: February 24, 2014, 02:54:27 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

TypeOverride

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: SFNUL
« Reply #41 on: February 24, 2014, 03:59:52 pm »
Sorry about that TypeOverride, I had to do the same thing and forgot to mention it.  ;)

Also I updated my above post.  :)

Thanks alot ! Without your help i would be lost in code.

TypeOverride

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: SFNUL
« Reply #42 on: April 10, 2014, 02:21:53 am »
So ive implemented this library for a prototype to test the features i need to making a working solution for my game.

At the moment i see a problem when try to remove a synchronized object that is not the last object that was pushed to the list. Its not working proper.

There is no way to use pointers for the synchronizer, so i have to carry around values.

When using _synchronizerServer.CreateObject<Entity>();
Also, the copy constructor will be called 2 times. With a pointer it shouldnt be such a cost problem.

But the main problem is that Synchroned Objects are values which i get over the CreateObject-Method where i cant really make a reference from, beside the list where the synchronized objects stored.

The memory allocation is changing automaticly when objects are removed form the STL containers, i guess.
 
I cant see how the STL container-classes manage the allocation of memory, but i see that something is wrong when i try to make something like:

_entities.push_back(_synchronizerServer->CreateObject<Entity>());
Entity& entityA = _entities.back();

So when i try to use entityA later, after i removed some other objects out of the _entities-list, it will shows that the reference is not valid anymore.

I think without modifying the synchronizer it wont work. I need pointers. Interrupt me, when im wrong, but is see no other way for the problem.
 
So ive manipulated the synchronizer.inl file like this and use now _synchronizerServer->CreateObject2<Entity>()

template<typename T, typename... Args>
T* SynchronizerServer::CreateObject2(Args&&... args) {
        T* object = new T(std::forward<Args>(args)...);

        object->SetSynchronizer(this);

        return object;
}

And now it works for me like it should.

I see two architecture hurdles,
A) Synchronization of sub-syncObjects of a syncObject.
B) Different views. At the moment i see that all syncObjects are there for synchronize all clients with the same objects, but why should objects be synchronized with clients/players where the object is currently dont visible. So i need more than one synchronizer (for each client (player)) that only synchronize the visible objects for a client.

So at the end it cant be solved in the way that the synchronizer handles the creation of the SyncObjects like it do with the CreateObject-Method.

With this way there is for each synchronizer a represenation of a SyncObject on Server-Side. So i have to remove the CreateObject-Method and give the synchronizer directly the SyncObject to make it possible to share the syncObject with all synchronizer (for each client) on the server.
« Last Edit: April 13, 2014, 06:55:02 am by TypeOverride »

Turbine

  • Full Member
  • ***
  • Posts: 102
    • View Profile
Re: SFNUL
« Reply #43 on: April 29, 2014, 01:29:59 am »
This doesn't compile for me, I get a heap of errors (MinGW 4.8.2):

Quote
||=== Build: all in SFNUL (compiler: GNU GCC Compiler) ===|
D:\projects\sfnul\extlibs\botan\include\botan\scan_name.h|97|error: 'mutex' in namespace 'std' does not name a type|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|65|error: 'mutex' in namespace 'std' does not name a type|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|178|error: 'mutex' is not a member of 'std'|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|178|error: 'mutex' is not a member of 'std'|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|178|error: template argument 1 is invalid|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|178|error: invalid type in declaration before '(' token|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|178|error: 's_alias_map_mutex' was not declared in this scope|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|186|error: 'mutex' is not a member of 'std'|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|186|error: 'mutex' is not a member of 'std'|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|186|error: template argument 1 is invalid|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|186|error: invalid type in declaration before '(' token|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|186|error: 's_alias_map_mutex' was not declared in this scope|
CMakeFiles\sfnul.dir\build.make|81|recipe for target 'CMakeFiles/sfnul.dir/extlibs/botan/src/lib/algo_base/scan_name.cpp.obj' failed|
CMakeFiles\Makefile2|62|recipe for target 'CMakeFiles/sfnul.dir/all' failed|
D:\projects\sfnul_bin\Makefile|115|recipe for target 'all' failed|
||=== Build failed: 15 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: SFNUL
« Reply #44 on: April 29, 2014, 01:39:27 am »
This doesn't compile for me, I get a heap of errors (MinGW 4.8.2)
What is the full version of your MinGW g++? You can find out by issuing the command g++ -v in the MinGW console. Post it here.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

 

anything