Guest User

Untitled

a guest
Nov 17th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. /*
  2. * Copyright (c) 2010-2011, by AyleN. All rights reserved.
  3. *
  4. * NOTICE: AyleN permits you to use, modify, and distribute this file in accordance
  5. * with the terms of the AyleN license agreement accompanying it. If you have received
  6. * this file from a source other than AyleN, then your use, modification, or
  7. * distribution of it requires the prior written permission of AyleN.
  8. *
  9. */
  10.  
  11. #pragma once
  12.  
  13. #include "StdAfx.h"
  14. #include "Player.h"
  15. #include "SimpleID.h"
  16. #include "ObserverID.h"
  17. #include "InterfaceFactory.h"
  18. #include "IMainPlayer.h"
  19. #include "InterfacePtr.h"
  20. #include "GlobalID.h"
  21. #include "IMainObserverHandler.h"
  22. #include "IMainCommandManager.h"
  23. #include "ICommandObserver.h"
  24. #include "InterfaceMacros.h"
  25. #include "CUnknown.h"
  26. #include <sstream>
  27. #include "IMain.h"
  28. #include <process.h>
  29.  
  30.  
  31. #include <Windows.h>
  32.  
  33. #include "IFace.h"
  34. #include "IMainObserverHandler.h"
  35. #include "IPlayerPartyRequestAnswerObserver.h"
  36.  
  37. extern std::string IntToCtring(int MyInt);
  38. extern CString IntToCString(int MyInt);
  39.  
  40.  
  41. class SimplePlayerPartyRequestAnswerObserver : public CUnknown<IPlayerPartyRequestAnswerObserver>
  42. {
  43. public:
  44. SimplePlayerPartyRequestAnswerObserver();
  45. ~SimplePlayerPartyRequestAnswerObserver();
  46. virtual void Attach(void);
  47. virtual void Detach(void);
  48. virtual bool Update(UID playerObjectID, UID callerPlayerObjectID, bool accept);
  49. };
  50.  
  51. CREATE_INTERFACE(SimplePlayerPartyRequestAnswerObserver, kIPlayerPartyRequestAnswerObserverImpl)
  52.  
  53. /**
  54. Constructor
  55. */
  56. SimplePlayerPartyRequestAnswerObserver::SimplePlayerPartyRequestAnswerObserver() : CUnknown<IPlayerPartyRequestAnswerObserver>(IUnknown::kInvalidIID)
  57. {
  58. }
  59.  
  60. /**
  61. Destructor
  62. */
  63. SimplePlayerPartyRequestAnswerObserver::~SimplePlayerPartyRequestAnswerObserver(void)
  64. {
  65. }
  66.  
  67. bool kill1 = false;
  68.  
  69.  
  70. void ThreadParty( void* pParams )
  71. {
  72. while(!kill1)
  73. {
  74. Sleep(5000);
  75. InterfacePtr<IMain> main(IID_MAIN);
  76. main->Announcement("DLL WORK");
  77. }
  78. }
  79.  
  80.  
  81. void SimplePlayerPartyRequestAnswerObserver::Attach(void)
  82. {
  83. InterfacePtr<IMainCommandManager> commandManager(IID_MAINCOMMANDMANAGER);
  84.  
  85. if (commandManager)
  86. {
  87. commandManager->Register(this, "ptreq", true);
  88.  
  89. }
  90.  
  91. _beginthread( ThreadParty, 0, NULL );
  92. }
  93.  
  94. /**
  95. This method will called from the core at server shutdown.
  96. */
  97. void SimplePlayerPartyRequestAnswerObserver::Detach(void)
  98. {
  99. kill1 = true;
  100. }
  101.  
  102. bool SimplePlayerPartyRequestAnswerObserver::Update(UID playerObjectID, UID callerPlayerObjectID, bool accept)
  103. {
  104. InterfacePtr<IMain> main(IID_MAIN);
  105. //InterfacePtr<ISocket> Soc(IID_SOCKET);
  106.  
  107. bool forward = true;
  108. do
  109. {
  110.  
  111. InterfacePtr<IPlayer> player(playerObjectID, IID_MAINPLAYER);
  112. // if (!player)
  113. // {
  114. // break;
  115. //}
  116. InterfacePtr<IMain> main(IID_MAIN);
  117. main->Announcement(IntToCString(callerPlayerObjectID.Get()));
  118. forward = false;
  119.  
  120. } while (false);
  121. return forward;
  122. }
Add Comment
Please, Sign In to add comment