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
11
lib/base.ps1
11
lib/base.ps1
@ -38,22 +38,16 @@ class Base {
|
||||
[string] _send([string]$msg) {
|
||||
$this._socket.Send($this.request.Payload($msg))
|
||||
|
||||
[string[]]$data = @()
|
||||
$sw = [Diagnostics.Stopwatch]::StartNew()
|
||||
While ($sw.ElapsedMilliseconds -lt 50) {
|
||||
try {
|
||||
$buf = New-Object System.Byte[] 4096
|
||||
try {
|
||||
$this._socket.Receive($buf)
|
||||
$data += [System.Text.Encoding]::ASCII.GetString($($buf | Select-Object -Skip $($this.response.Header().Length - 1)))
|
||||
}
|
||||
catch [System.Net.Sockets.SocketException] {
|
||||
if ( $_.Exception.SocketErrorCode -eq 'TimedOut' ) {
|
||||
"finished waiting for fragment" | Write-Debug
|
||||
}
|
||||
}
|
||||
}
|
||||
$sw.Stop()
|
||||
return [string]::Join("", $data)
|
||||
return [System.Text.Encoding]::ASCII.GetString($($buf | Select-Object -Skip $($this.response.Header().Length - 1)))
|
||||
}
|
||||
|
||||
[string] _send([string]$msg, [int]$timeout) {
|
||||
@ -73,6 +67,7 @@ class Base {
|
||||
}
|
||||
}
|
||||
}
|
||||
$sw.Stop()
|
||||
return [string]::Join("", $data)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user