Hi all,
I'm not giving up that easy and ask questions put I'm in a little trouble.
Spitting around in the Forum have not help.
I have build a Websocket server to Manage a Music Player on a Raspberry Pi 5.
In The WS Server there is also a TCP server listen to messages of the Player.
TCP is only used on 127.0.0.1 so we can use this to send messages to each other.
There can only be about 25 Clients and I wondering how to handle them the best way.
The Player is used for Jamulus a Internet Jam session Application.
B4J Player is working perfect. No problem there.
To Show you what I mean I will add some images..
View attachment 163499
First this is the Player with all his Audio connections to the Jam program.
View attachment 163500
This is the website not finish yet.
In my code I think I have a WS control conflict.
The website Is build from the ground up. No fancy Frameworks or overkill on code.
Maybe somebody can help out here how to control WS Clients the correct way.
Thanks in advance.
Roland
I'm not giving up that easy and ask questions put I'm in a little trouble.
Spitting around in the Forum have not help.
I have build a Websocket server to Manage a Music Player on a Raspberry Pi 5.
In The WS Server there is also a TCP server listen to messages of the Player.
TCP is only used on 127.0.0.1 so we can use this to send messages to each other.
There can only be about 25 Clients and I wondering how to handle them the best way.
The Player is used for Jamulus a Internet Jam session Application.
B4J Player is working perfect. No problem there.
To Show you what I mean I will add some images..
View attachment 163499
First this is the Player with all his Audio connections to the Jam program.
View attachment 163500
This is the website not finish yet.
In my code I think I have a WS control conflict.
WebSocket Trouble:
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
Try
ws = WebSocket1
If ws.Session = Null Then
Return
End If
' Log(ws.Session.Id)
modFunctions.LogText("Session ID " & ws.Session.Id, False)
Dim info As ClientInfo
info.Initialize
info.UserID = Rnd(1, 100) & " RND Has to be user ID " & DateTime.Time(DateTime.Now) ' Write this yourself or use a counter/UUID
info.UserName = "Anonymous" ' Or detect from query params
info.IsPlayer = False ' Set to True for your local Music Player if needed
info.SessionID = ws.Session.Id
Main.connectedClients.Put(ws, info)
If ServerTimer.IsInitialized = False Then
ServerTimer.Initialize("ServerTimer", 5000)
ServerTimer.Enabled = True
End If
End Sub
If I like to access 1 websocket I get the ID from Subs like this in a other Class
Public Sub Broadcast_List(ws As WebSocket, FunctionName As String, Data As List, sendToAll As Boolean)
If sendToAll = True Then
For Each objWs As Object In Main.connectedClients.Keys
Dim tmpWS As WebSocket = objWs
tmpWS.RunFunction(FunctionName, Array(Data))
tmpWS.Flush
Next
Else
Dim sessionID As String = GetWebSocketID(ws)
For Each objWs As Object In Main.connectedClients.Keys
Dim tmpWS As WebSocket = objWs
Log(tmpWS.Session.Id)
If tmpWS.Session.Id = sessionID Then
tmpWS.RunFunction(FunctionName, Array(Data))
tmpWS.Flush
Exit
End If
Next
End If
End Sub
The website Is build from the ground up. No fancy Frameworks or overkill on code.
Maybe somebody can help out here how to control WS Clients the correct way.
Thanks in advance.
Roland
Last edited: