@@ -11,9 +11,25 @@ function Send-OBS
1111 Watch-OBS
1212 #>
1313 param (
14+ # The data to send to the obs websocket.
1415 [Parameter (ValueFromPipeline , ValueFromPipelineByPropertyName )]
1516 [Alias (' Payload' )]
16- $MessageData
17+ $MessageData ,
18+
19+ # If provided, will sleep after each step.
20+ # If -StepTime is less than 10000 ticks, it will be treated as frames per second.
21+ # If -SerialFrame was provied, -StepTime will be the number of frames to wait.
22+ [Parameter (ValueFromPipelineByPropertyName )]
23+ [timespan ]
24+ $StepTime ,
25+
26+ # If set, will process a batch of requests in parallel.
27+ [switch ]
28+ $Parallel ,
29+
30+ # If set, will process a batch of requests in parallel.
31+ [switch ]
32+ $SerialFrame
1733 )
1834
1935 begin {
@@ -103,6 +119,26 @@ function Send-OBS
103119
104120 process {
105121 $allMessages.Enqueue ($MessageData )
122+ if ($StepTime.TotalMilliseconds -gt 0 ) {
123+ if ($SerialFrame ) {
124+ $allMessages.Enqueue ([PSCustomObject ][Ordered ]@ {
125+ requestType = ' Sleep'
126+ requestData = @ {
127+ sleepFrames = [int ]$StepTime.Ticks
128+ }
129+ })
130+ } else {
131+ if ($StepTime.Ticks -lt 10000 ) {
132+ $StepTime = [TimeSpan ]::FromMilliseconds(1000 / $StepTime.Ticks )
133+ }
134+ $allMessages.Enqueue ([PSCustomObject ][Ordered ]@ {
135+ requestType = ' Sleep'
136+ requestData = @ {
137+ sleepMillis = [int ]$StepTime.TotalMilliseconds
138+ }
139+ })
140+ }
141+ }
106142 }
107143
108144 end {
@@ -119,7 +155,14 @@ function Send-OBS
119155 [PSCustomObject ]@ {
120156 op = 8
121157 d = [Ordered ]@ {
122- requestID = " Batch.$ ( $script :ObsRequestsCounts [" Batch" ]) "
158+ requestId = " Batch.$ ( [guid ]::NewGuid()) "
159+ executionType = if ($Parallel ) {
160+ 2
161+ } elseif ($SerialFrame ) {
162+ 1
163+ } else {
164+ 0
165+ }
123166 requests = $allMessages.ToArray ()
124167 }
125168 } | SendSingleMessageToOBS
0 commit comments