mirror of
https://github.com/onyx-and-iris/q3rcon-ps.git
synced 2025-01-18 08:40:52 +00:00
upd {base}.send method.
If only a single fragment expected, don't use string array
This commit is contained in:
parent
61f7afb9f7
commit
e446a45a6c
23
lib/base.ps1
23
lib/base.ps1
@ -38,22 +38,16 @@ class Base {
|
|||||||
[string] _send([string]$msg) {
|
[string] _send([string]$msg) {
|
||||||
$this._socket.Send($this.request.Payload($msg))
|
$this._socket.Send($this.request.Payload($msg))
|
||||||
|
|
||||||
[string[]]$data = @()
|
$buf = New-Object System.Byte[] 4096
|
||||||
$sw = [Diagnostics.Stopwatch]::StartNew()
|
try {
|
||||||
While ($sw.ElapsedMilliseconds -lt 50) {
|
$this._socket.Receive($buf)
|
||||||
try {
|
}
|
||||||
$buf = New-Object System.Byte[] 4096
|
catch [System.Net.Sockets.SocketException] {
|
||||||
$this._socket.Receive($buf)
|
if ( $_.Exception.SocketErrorCode -eq 'TimedOut' ) {
|
||||||
$data += [System.Text.Encoding]::ASCII.GetString($($buf | Select-Object -Skip $($this.response.Header().Length - 1)))
|
"finished waiting for fragment" | Write-Debug
|
||||||
}
|
|
||||||
catch [System.Net.Sockets.SocketException] {
|
|
||||||
if ( $_.Exception.SocketErrorCode -eq 'TimedOut' ) {
|
|
||||||
"finished waiting for fragment" | Write-Debug
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sw.Stop()
|
return [System.Text.Encoding]::ASCII.GetString($($buf | Select-Object -Skip $($this.response.Header().Length - 1)))
|
||||||
return [string]::Join("", $data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[string] _send([string]$msg, [int]$timeout) {
|
[string] _send([string]$msg, [int]$timeout) {
|
||||||
@ -73,6 +67,7 @@ class Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$sw.Stop()
|
||||||
return [string]::Join("", $data)
|
return [string]::Join("", $data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user