Sub wsh_RA(Params As List)
'receive audio from websocket server
audioStream.StartPlaying
AppActive = DateTime.Now
lastServerPong = DateTime.Now
Dim RxGSM1() As Byte
Dim RxM As Map
Dim RxStR As String
Dim QL As String
RxM = Params.Get(0)
RxStR = RxM.Get("A")
QL = RxM.Get("Q")
RxName = RxM.Get("N")
RxGroup = RxM.Get("G")
'Log(RxM)
If PreviousRxName <> RxName Then
ToastMessageShow(RxName&CRLF&RxGroup,False)
PreviousRxName = RxName
End If
If Silence = False Then ' if sender is myself don not play audio
RxGSM1 = su.DecodeBase64(RxStR)
''Log("Receiving audio : "& RxM.Get("X"))
If QL = "L" Then 'Decode GSM codec
'ec")
Dim nbytes As Int=RxGSM1.Length
Dim bc As ByteConverter
Dim ninp As Int
Dim ptrx As Int
Dim ptrx2 As Int=0
''Log("Got N. Bytes: " & nbytes)
Dim lungbuf As Int =nbytes/33*Buffersizeslash2
Dim buffbyte(lungbuf) As Byte
Dim bufgsm(33) As Byte
Dim buffint(160) As Short
Try
ptrx2=0
For ninp =0 To nbytes-1 Step 33
bc.ArrayCopy(RxGSM1,ninp,bufgsm,0,33)
GSM.decodex(bufgsm,buffint,33)
For ptrx = 0 To 158
buffbyte(ptrx2+1 ) = Bit.ShiftRight (Bit.And(buffint(ptrx) , 0xFF00), 8)
buffbyte(ptrx2) = Bit.And(buffint(ptrx), 0xFF)
ptrx2 = ptrx2 + 2
Next
Next
audioStream.write(buffbyte) 'send to play device(speaker or earpiece)
Catch
End Try
Else
''Log("PCM codec")
audioStream.write(RxGSM1)
' If Recording = True Then
' output.WriteBytes(RxGSM1, 0, RxGSM1.Length)
' End If
End If
End If
End Sub