| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| LoadingMonitoring |
|
| 0.0;0 |
| 1 | /* | |
| 2 | * Licensed under the MIT License | |
| 3 | * | |
| 4 | * Copyright 2011 (c) Flávio Silva, flsilva.com | |
| 5 | * | |
| 6 | * Permission is hereby granted, free of charge, to any person | |
| 7 | * obtaining a copy of this software and associated documentation | |
| 8 | * files (the "Software"), to deal in the Software without | |
| 9 | * restriction, including without limitation the rights to use, | |
| 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 11 | * copies of the Software, and to permit persons to whom the | |
| 12 | * Software is furnished to do so, subject to the following | |
| 13 | * conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be | |
| 16 | * included in all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
| 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | |
| 20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
| 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
| 22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
| 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
| 25 | * OTHER DEALINGS IN THE SOFTWARE. | |
| 26 | * | |
| 27 | * http://www.opensource.org/licenses/mit-license.php | |
| 28 | */ | |
| 29 | 1 | package org.vostokframework.application.monitoring |
| 30 | { | |
| 31 | /** | |
| 32 | * description | |
| 33 | * | |
| 34 | * @author Flávio Silva | |
| 35 | */ | |
| 36 | public class LoadingMonitoring | |
| 37 | { | |
| 38 | /** | |
| 39 | * description | |
| 40 | */ | |
| 41 | private var _bufferBytesRemaining:int; | |
| 42 | private var _bufferBytesTotal:int; | |
| 43 | private var _bufferPercent:int; | |
| 44 | private var _bytesLoaded:int; | |
| 45 | private var _bytesRemaining:int; | |
| 46 | private var _bytesTotal:int; | |
| 47 | private var _elapsedTime:int; | |
| 48 | private var _latency:int; | |
| 49 | private var _percent:int; | |
| 50 | ||
| 51 | public function get averageSpeed(): int { return 0; } | |
| 52 | ||
| 53 | /** | |
| 54 | * description | |
| 55 | */ | |
| 56 | public function get bufferBytesRemaining(): int { return _bufferBytesRemaining; } | |
| 57 | ||
| 58 | /** | |
| 59 | * description | |
| 60 | */ | |
| 61 | public function get bufferPercent(): int { return _bufferPercent; } | |
| 62 | ||
| 63 | /** | |
| 64 | * description | |
| 65 | */ | |
| 66 | public function get bytesLoaded(): int { return _bytesLoaded; } | |
| 67 | ||
| 68 | /** | |
| 69 | * description | |
| 70 | */ | |
| 71 | public function get bytesRemaining(): int { return _bytesRemaining; } | |
| 72 | ||
| 73 | /** | |
| 74 | * description | |
| 75 | */ | |
| 76 | public function get bytesTotal(): int { return _bytesTotal; } | |
| 77 | ||
| 78 | /** | |
| 79 | * description | |
| 80 | */ | |
| 81 | public function get currentSpeed(): int { return 0; } | |
| 82 | ||
| 83 | /** | |
| 84 | * description | |
| 85 | */ | |
| 86 | public function get elapsedTime(): int { return _elapsedTime; } | |
| 87 | ||
| 88 | /** | |
| 89 | * description | |
| 90 | */ | |
| 91 | public function get latency(): int { return _latency; } | |
| 92 | ||
| 93 | /** | |
| 94 | * description | |
| 95 | */ | |
| 96 | public function get percent(): int { return _percent; } | |
| 97 | ||
| 98 | /** | |
| 99 | * description | |
| 100 | */ | |
| 101 | public function get remainingTime(): int { return 0; } | |
| 102 | //TODO:implement detailed statistics | |
| 103 | /** | |
| 104 | * description | |
| 105 | * | |
| 106 | * @param latency | |
| 107 | * @param bytesTotal | |
| 108 | * @param bufferPercent | |
| 109 | */ | |
| 110 | public function LoadingMonitoring(latency:int, bufferPercent:int = 100) | |
| 111 | 1 | { |
| 112 | 1 | _latency = latency; |
| 113 | 1 | _bufferPercent = bufferPercent; |
| 114 | 1 | } |
| 115 | ||
| 116 | /** | |
| 117 | * description | |
| 118 | */ | |
| 119 | public function reset(): void | |
| 120 | { | |
| 121 | ||
| 122 | 0 | } |
| 123 | ||
| 124 | /** | |
| 125 | * description | |
| 126 | * | |
| 127 | * @param bytesLoaded | |
| 128 | */ | |
| 129 | public function update(bytesTotal:int, bytesLoaded:int): void | |
| 130 | { | |
| 131 | 1 | _bytesTotal = bytesTotal; |
| 132 | 1 | _bytesLoaded = bytesLoaded; |
| 133 | ||
| 134 | 1 | var tempPercent:int = (_bytesTotal > 0) ? Math.floor((_bytesLoaded * 100) / _bytesTotal) : 0; |
| 135 | 1 | if (tempPercent > _percent) _percent = tempPercent; |
| 136 | 1 | } |
| 137 | ||
| 138 | } | |
| 139 | ||
| 140 | } |