Rev 1642 | Rev 1646 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1642 | Rev 1644 | ||
|---|---|---|---|
| Line 39... | Line 39... | ||
| 39 | 39 | ||
| 40 | Timer::Timer(boost::asio::io_service& io_service) : Plugin(io_service) |
40 | Timer::Timer(boost::asio::io_service& io_service) : Plugin(io_service) |
| 41 | { |
41 | { |
| 42 | this->name_ = "timer"; |
42 | this->name_ = "timer"; |
| 43 | 43 | ||
| 44 | this->ExportFunction(" |
44 | this->ExportFunction("TimerExport_StartTimer", Timer::Export_StartTimer); |
| 45 | this->ExportFunction(" |
45 | this->ExportFunction("TimerExport_ClearTimer", Timer::Export_ClearTimer); |
| 46 | this->ExportFunction(" |
46 | this->ExportFunction("TimerExport_Sleep", Timer::Export_Sleep); |
| 47 | } |
47 | } |
| 48 | 48 | ||
| 49 | Timer::~Timer() |
49 | Timer::~Timer() |
| 50 | { |
50 | { |
| 51 | 51 | ||
| Line 94... | Line 94... | ||
| 94 | 94 | ||
| 95 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
95 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 96 | 96 | ||
| 97 | if (args.Length() < 2) |
97 | if (args.Length() < 2) |
| 98 | { |
98 | { |
| 99 | LOG.Error("To few arguments."); |
99 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 100 | } |
100 | } |
| 101 | 101 | ||
| 102 | timer::TimerId timer_id = timer::Manager::Instance()->Set(args[0]->Uint32Value(), args[1]->BooleanValue()); |
102 | timer::TimerId timer_id = timer::Manager::Instance()->Set(args[0]->Uint32Value(), args[1]->BooleanValue()); |
| 103 | 103 | ||
| 104 | Timer::timers_.insert(timer_id); |
104 | Timer::timers_.insert(timer_id); |
| Line 112... | Line 112... | ||
| 112 | 112 | ||
| 113 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
113 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 114 | 114 | ||
| 115 | if (args.Length() < 1) |
115 | if (args.Length() < 1) |
| 116 | { |
116 | { |
| 117 | LOG.Error("To few arguments."); |
117 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 118 | } |
118 | } |
| 119 | 119 | ||
| 120 | Timers::iterator it = Timer::timers_.find(args[0]->IsUint32()); |
120 | Timers::iterator it = Timer::timers_.find(args[0]->IsUint32()); |
| 121 | 121 | ||
| 122 | if (it != Timer::timers_.end()) |
122 | if (it != Timer::timers_.end()) |
| Line 134... | Line 134... | ||
| 134 | 134 | ||
| 135 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
135 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 136 | 136 | ||
| 137 | if (args.Length() < 1) |
137 | if (args.Length() < 1) |
| 138 | { |
138 | { |
| 139 | LOG.Error("To few arguments."); |
139 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 140 | } |
140 | } |
| 141 | 141 | ||
| 142 | boost::this_thread::sleep(boost::posix_time::milliseconds(args[0]->Uint32Value())); |
142 | boost::this_thread::sleep(boost::posix_time::milliseconds(args[0]->Uint32Value())); |
| 143 | 143 | ||
| 144 | return v8::Undefined(); |
144 | return v8::Undefined(); |