MainPage.xaml.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. //
  11. // MainPage.xaml.cpp
  12. // Implementation of the MainPage class.
  13. //
  14. #include "pch.h"
  15. #include "MainPage.xaml.h"
  16. using namespace RakNet_WindowsStore8_VS2012;
  17. using namespace Platform;
  18. using namespace Windows::Foundation;
  19. using namespace Windows::Foundation::Collections;
  20. using namespace Windows::UI::Xaml;
  21. using namespace Windows::UI::Xaml::Controls;
  22. using namespace Windows::UI::Xaml::Controls::Primitives;
  23. using namespace Windows::UI::Xaml::Data;
  24. using namespace Windows::UI::Xaml::Input;
  25. using namespace Windows::UI::Xaml::Media;
  26. using namespace Windows::UI::Xaml::Navigation;
  27. // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
  28. #include "RakPeerInterface.h"
  29. #include "RakSleep.h"
  30. #include "MessageIdentifiers.h"
  31. using namespace RakNet;
  32. #define DEFAULT_SERVER_PORT 61111
  33. #define DEFAULT_SERVER_ADDRESS "natpunch.jenkinssoftware.com"
  34. MainPage::MainPage()
  35. {
  36. InitializeComponent();
  37. // #error "add raknet init code, what happened to windows phone?"
  38. RakPeerInterface *rakPeer = RakPeerInterface::GetInstance();
  39. SocketDescriptor sd;
  40. StartupResult sr = rakPeer->Startup(1, &sd, 1);
  41. assert(sr==RAKNET_STARTED);
  42. ConnectionAttemptResult car = rakPeer->Connect(DEFAULT_SERVER_ADDRESS, DEFAULT_SERVER_PORT, 0, 0);
  43. assert(car==CONNECTION_ATTEMPT_STARTED);
  44. RakSleep(1000);
  45. Packet *packet;
  46. packet=rakPeer->Receive();
  47. if (packet)
  48. {
  49. RakAssert(packet->data[0]==ID_CONNECTION_REQUEST_ACCEPTED);
  50. }
  51. }
  52. /// <summary>
  53. /// Invoked when this page is about to be displayed in a Frame.
  54. /// </summary>
  55. /// <param name="e">Event data that describes how this page was reached. The Parameter
  56. /// property is typically used to configure the page.</param>
  57. void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
  58. {
  59. (void) e; // Unused parameter
  60. }
粤ICP备19079148号