Re: WEBSOCKET desktop client
Websocket protocols are only available in .Net Framework 4.5 (and possibly even then only with W8) so at the very least you're going to need to update your VS to 2013. The Websockets package is not included by default so you would also have to install it (using NuGet, for example). If you're in a position to do that, then we can consider the question.
Re: WEBSOCKET desktop client
Thank you for your response. Sorry for my outdated signature.
I have VS2013 and .NET 4.5.1 installed. As of 4.5 .NET suppose to support websockets. I have no problems adding
Imports System.Net.WebSockets.ClientWebSocket
to my projects. So I believe I have everything I need.
Thank you.
Re: WEBSOCKET desktop client
Sadly the ability to import the Socket and indeed to code for it does not necessarily mean that it is supported on your machine. I've just done a quick test and it does look like you need W8. If you have then you can proceed but I'm afraid I don't so this is as far as I can go with certainty.
Re: WEBSOCKET desktop client
I also tried Alchemy Websockets. I got onConnect event fired, also "client.connected" returns true but all other events does not fire.
Any thoughts?
My VB code:
Code:
Imports Alchemy
Imports Alchemy.Classes
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim aClient = New WebSocketClient("ws://echo.websocket.org:80/")
With aClient
.OnReceive = AddressOf onDataReceive
.OnConnect = AddressOf OnUserConnect
.OnConnected = AddressOf onUserConnected
.OnSend = AddressOf onDataSend
.OnDisconnect = AddressOf onUserDisconnect
End With
aClient.Connect()
MsgBox(aClient.Connected)
If aClient.Connected = True Then
aClient.Send("Hey!")
aClient.Disconnect()
End If
End
End Sub
Private Sub OnUserConnect(context As Alchemy.Classes.UserContext)
MsgBox("Connecting")
End Sub
Private Sub OnUserConnected(context As Alchemy.Classes.UserContext)
MsgBox("Connected")
End Sub
Private Sub onDataSend(context As Alchemy.Classes.UserContext)
MsgBox("Send")
End Sub
Private Sub onUserDisconnect(context As Alchemy.Classes.UserContext)
MsgBox("Disconnect")
End Sub
Private Sub onDataReceive(context As Alchemy.Classes.UserContext)
MsgBox("Server response : " & context.DataFrame.ToString())
End Sub
End Class
Re: WEBSOCKET desktop client
Had a long and frustrating fiddle with this and got very little sense out of it, I'm afraid. Part of the problem is that you're using message boxes which interrupt the flow of the program and are potentially cross threading. But having got rid of those and replaced them with a thread safe return to a textbox only succeeded in getting me as far as send. Nothing ever suggested that data was returned or if it was that it fired the receive event. Then there was the further problem that the disconnect returned a null reference exception and I can't for the life of me see why. So, fair to say that it's not looking like the road to success at the moment. I may give it another try as a Console app but I'm not hopeful.
Re: WEBSOCKET desktop client
Thank you for your effort on this. Did you try it on Windows 8? I tried it on Win7 sp1 and had same result as you except exception at disconnect.
It would be nice to have working desktop client. I'm not ready to abandon this idea just yet. But as I dig deeper into WEBSOCKETS more I realize that even if I somehow manage to create desktop client, there is no way that I can write application that will work from Win XP onwards.
Re: WEBSOCKET desktop client
No, I'm sticking to W7 (possibly for life)! I don't see anywhere in Alchemy's bumpf that it says it shouldn't work in W7 and it is compiled on .Net 4, but there you go. I did try a console version both in VB and C# but that did some very weird things that meant it wouldn't compile.
Re: WEBSOCKET desktop client
Quote:
Originally Posted by
ermingut
I also tried Alchemy Websockets. I got onConnect event fired, also "client.connected" returns true but all other events does not fire.
Any thoughts?
My VB code:
Code:
Imports Alchemy
...
With aClient
.OnReceive = AddressOf onDataReceive
.OnConnect = AddressOf OnUserConnect
.OnConnected = AddressOf onUserConnected
.OnSend = AddressOf onDataSend
.OnDisconnect = AddressOf onUserDisconnect
End With
Private Sub onDataSend(context As Alchemy.Classes.UserContext)
MsgBox("Send")
End Sub
Private Sub onUserDisconnect(context As Alchemy.Classes.UserContext)
MsgBox("Disconnect")
End Sub
Private Sub onDataReceive(context As Alchemy.Classes.UserContext)
MsgBox("Server response : " & context.DataFrame.ToString())
End Sub
End Class
probably dead thread, but I was looking for this kind of solution and (thanks btw, really helped me)
and I notice in your code was error in case-sensitive function name.
Vb6 (Classic) was case-insensitive,
Vb.Net is by IDE case-insensitive, but compiler (.NET) is case-SENSITIVE
(wich make thing very confusing)
Never forget that the team that forged Vb.Net wasn't the MVS Vb6 Team but the MVS VC Team.
thanks for the code.