-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client/server/shared: Move resource events to shared
- Loading branch information
1 parent
c251a06
commit e9c7db7
Showing
3 changed files
with
42 additions
and
47 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "V8ResourceImpl.h" | ||
#include "V8Helpers.h" | ||
|
||
#include "cpp-sdk/events/CResourceStartEvent.h" | ||
#include "cpp-sdk/events/CResourceStopEvent.h" | ||
#include "cpp-sdk/events/CResourceErrorEvent.h" | ||
#include "cpp-sdk/SDK.h" | ||
|
||
using EventType = alt::CEvent::Type; | ||
|
||
V8_EVENT_HANDLER anyResourceStart( | ||
EventType::RESOURCE_START, | ||
[](V8ResourceImpl* resource, const alt::CEvent* e) { | ||
auto ev = static_cast<const alt::CResourceStartEvent*>(e); | ||
|
||
return resource->GetLocalHandlers("anyResourceStart"); | ||
}, | ||
[](V8ResourceImpl* resource, const alt::CEvent* e, std::vector<v8::Local<v8::Value>>& args) { | ||
auto ev = static_cast<const alt::CResourceStartEvent*>(e); | ||
|
||
args.push_back(V8Helpers::JSValue(ev->GetResource()->GetName())); | ||
}); | ||
|
||
V8_EVENT_HANDLER anyResourceStop( | ||
EventType::RESOURCE_STOP, | ||
[](V8ResourceImpl* resource, const alt::CEvent* e) { | ||
auto ev = static_cast<const alt::CResourceStopEvent*>(e); | ||
|
||
return resource->GetLocalHandlers("anyResourceStop"); | ||
}, | ||
[](V8ResourceImpl* resource, const alt::CEvent* e, std::vector<v8::Local<v8::Value>>& args) { | ||
auto ev = static_cast<const alt::CResourceStopEvent*>(e); | ||
|
||
args.push_back(V8Helpers::JSValue(ev->GetResource()->GetName())); | ||
}); | ||
|
||
V8_LOCAL_EVENT_HANDLER anyResourceError(EventType::RESOURCE_ERROR, "anyResourceError", [](V8ResourceImpl* resource, const alt::CEvent* e, std::vector<v8::Local<v8::Value>>& args) { | ||
auto ev = static_cast<const alt::CResourceErrorEvent*>(e); | ||
v8::Isolate* isolate = resource->GetIsolate(); | ||
|
||
args.push_back(V8Helpers::JSValue(ev->GetResource()->GetName())); | ||
}); |