@quenty/timesyncservice 7.0.0 → 7.0.1-canary.293.c1c91bd.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [7.0.1-canary.293.c1c91bd.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/timesyncservice@7.0.0...@quenty/timesyncservice@7.0.1-canary.293.c1c91bd.0) (2022-10-11)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add :GetPing() API call to TimeSyncService ([53b94c6](https://github.com/Quenty/NevermoreEngine/commit/53b94c68412df4f038d501423c4b9e58f176439c))
12
+
13
+
14
+
15
+
16
+
6
17
  # [7.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/timesyncservice@6.1.0...@quenty/timesyncservice@7.0.0) (2022-09-27)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/timesyncservice
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/timesyncservice",
3
- "version": "7.0.0",
3
+ "version": "7.0.1-canary.293.c1c91bd.0",
4
4
  "description": "Quenty's TimeSyncService keeps time synchronized between all clients and the server",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,16 +26,16 @@
26
26
  "Quenty"
27
27
  ],
28
28
  "dependencies": {
29
- "@quenty/baseobject": "^6.0.0",
30
- "@quenty/loader": "^6.0.0",
31
- "@quenty/maid": "^2.4.0",
32
- "@quenty/promise": "^6.0.0",
33
- "@quenty/remoting": "^6.0.0",
34
- "@quenty/signal": "^2.3.0",
35
- "@quenty/table": "^3.1.0"
29
+ "@quenty/baseobject": "6.0.0",
30
+ "@quenty/loader": "6.0.0",
31
+ "@quenty/maid": "2.4.0",
32
+ "@quenty/promise": "6.0.0",
33
+ "@quenty/remoting": "6.0.0",
34
+ "@quenty/signal": "2.3.0",
35
+ "@quenty/table": "3.1.0"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "cbbe2a3e91f0d1e337bb33652b4e32bec685bb76"
40
+ "gitHead": "c1c91bd797aeee5cd167d614890f0999809a9a93"
41
41
  }
@@ -54,6 +54,14 @@ function MasterClock:IsSynced()
54
54
  return true
55
55
  end
56
56
 
57
+ --[=[
58
+ Returns estimated ping in seconds
59
+ @return number
60
+ ]=]
61
+ function MasterClock:GetPing()
62
+ return self._offset
63
+ end
64
+
57
65
  --[=[
58
66
  Returns the sycncronized time
59
67
  @return number
@@ -24,6 +24,7 @@ function SlaveClock.new(remoteEvent, remoteFunction)
24
24
 
25
25
  self._remoteEvent = remoteEvent or error("No remoteEvent")
26
26
  self._remoteFunction = remoteFunction or error("No remoteFunction")
27
+ self._ping = 0
27
28
 
28
29
  self._maid:GiveTask(self._remoteEvent.OnClientEvent:Connect(function(timeOne)
29
30
  self:_handleSyncEventAsync(timeOne)
@@ -71,12 +72,23 @@ function SlaveClock:_getLocalTime()
71
72
  return tick()
72
73
  end
73
74
 
75
+ --[=[
76
+ Returns estimated ping in seconds
77
+ @return number
78
+ ]=]
79
+ function SlaveClock:GetPing()
80
+ return self._ping
81
+ end
82
+
74
83
  function SlaveClock:_handleSyncEventAsync(timeOne)
75
84
  local timeTwo = self:_getLocalTime() -- We can't actually get hardware stuff, so we'll send T1 immediately.
76
85
  local masterSlaveDifference = timeTwo - timeOne -- We have Offst + MS Delay
77
86
 
78
87
  local timeThree = self:_getLocalTime()
88
+
89
+ local startTime = os.clock()
79
90
  local slaveMasterDifference = self:_sendDelayRequestAsync(timeThree)
91
+ local ping = os.clock() - startTime
80
92
 
81
93
  --[[ From explination link.
82
94
  The result is that we have the following two equations:
@@ -101,6 +113,7 @@ function SlaveClock:_handleSyncEventAsync(timeOne)
101
113
 
102
114
  self._offset = offset -- Estimated difference between server/client
103
115
  self._pneWayDelay = oneWayDelay -- Estimated time for network events to send. (MSDelay/SMDelay)
116
+ self._ping = ping
104
117
 
105
118
  self._syncedBindable:Fire()
106
119
  end
@@ -120,6 +120,10 @@ function TimeSyncService:_buildMockClock()
120
120
  return tick()
121
121
  end
122
122
 
123
+ function mock.GetPing(_self)
124
+ return 0
125
+ end
126
+
123
127
  return mock
124
128
  end
125
129