main.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #include "RakPeerInterface.h"
  11. #include "FileOperations.h"
  12. #include "RakMemoryOverride.h"
  13. #include "ConsoleServer.h"
  14. #include "LogCommandParser.h"
  15. #include "RakNetCommandParser.h"
  16. #include "PacketLogger.h"
  17. #include "DS_List.h"
  18. #include "SocketLayer.h"
  19. #include "RakSleep.h"
  20. #include "TCPInterface.h"
  21. using namespace RakNet;
  22. void* MyMalloc (size_t size)
  23. {
  24. return malloc(size);
  25. }
  26. void* MyRealloc (void *p, size_t size)
  27. {
  28. return realloc(p,size);
  29. }
  30. void MyFree (void *p)
  31. {
  32. free(p);
  33. }
  34. // This project is used to test the DLL system to make sure necessary classes are exported
  35. int main()
  36. {
  37. // Just test allocation and deallocation across the DLL. If it crashes it failed, otherwise it worked.
  38. ConsoleServer* a=ConsoleServer::GetInstance( );
  39. LogCommandParser* c=LogCommandParser::GetInstance( );
  40. PacketLogger* d=PacketLogger::GetInstance( );
  41. RakNetCommandParser* e=RakNetCommandParser::GetInstance( );
  42. RakPeerInterface * f=RakPeerInterface::GetInstance( );
  43. TCPInterface *g=TCPInterface::GetInstance();
  44. SystemAddress sa = UNASSIGNED_SYSTEM_ADDRESS;
  45. SocketDescriptor sd(5555,0);
  46. if(f->Startup(32,&sd,1) != RAKNET_STARTED) {
  47. printf("NetworkNode::startup(): failed to start server\n");
  48. return 0;
  49. }
  50. f->SetMaximumIncomingConnections(32);
  51. DataStructures::List<RakNetSocket2* > sockets;
  52. f->GetSockets(sockets);
  53. f->ReleaseSockets(sockets);
  54. // See RakMemoryOverride.h
  55. SetMalloc(MyMalloc);
  56. SetRealloc(MyRealloc);
  57. SetFree(MyFree);
  58. char *cArray = RakNet::OP_NEW_ARRAY<char>(10,_FILE_AND_LINE_);
  59. RakNet::OP_DELETE_ARRAY(cArray,_FILE_AND_LINE_);
  60. DataStructures::List<int> intList;
  61. intList.Push(5, _FILE_AND_LINE_ );
  62. f->GetMTUSize(RakNet::UNASSIGNED_SYSTEM_ADDRESS);
  63. SystemAddress p1;
  64. SystemAddress p2;
  65. p1=p2;
  66. RakSleep(300);
  67. ConsoleServer::DestroyInstance( a );
  68. LogCommandParser::DestroyInstance( c );
  69. PacketLogger::DestroyInstance( d );
  70. RakNetCommandParser::DestroyInstance( e );
  71. RakNet::RakPeerInterface::DestroyInstance( f );
  72. TCPInterface::DestroyInstance( g );
  73. return 0;
  74. }
粤ICP备19079148号