I would like to know if somebody has allready developed a socket client based on pimatic, and is willing to show me some sample code? I found some pieces of code, but not in c# and cannot get the right trick
-
Help with developing socket client in c#
-
@vanturenhout May be the following is any useful: http://forum.pimatic.org/topic/882/how-to-make-a-post-or-get-request-using-net-c-or-vb-net-with-the-api
EDIT: See also https://github.com/mertensn/Pimatic.NET
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@mwittig Well, yes and no. The guy who developed the stuff you’re referring to is sitting next to me… So I can ask him if I need to.
However, I’m trying to develop a client that is responding to events from pimatic as a base for, for example a windows (phone) app and think that the Socket way is the way to go there.
-
@vanturenhout Ah, ok. Honestly, I am not familiar with .NET in detail. I guess you’ll need something like C# Implemntation of WebSockets (if not already part of .NET - apparently it is since v4) and start using the pimatic websocket from there.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@mwittig Oke, that looks promising, will dive into that. Thanks!
-
https://github.com/Quobject/SocketIoClientDotNet looks promising. However taking a quick look into the issue section it seems that it has some memory leaks.
-
@sweetpi Well depends, on what you’re looking at. I think it is hard to say whether websocket-sharp or SocketIoClientDotNet is better as both seem to have serious unresolved issues. Perhaps the best advice is to keep the client code portable (which should be easy) and to try both. @vanturenhout please share your findings with us.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
websocket-sharp is only a websocket implementation. SocketIoClientDotNet is a socket.io implementation, so it is much less work to use. However I’m not that into .Net / c# and have tried neither of them.
-
Finally got some time to get it working…
I used SocketIOClientDotNet and with some debugging I now see events and stuff appearing in my console.
Still in very very very early developing stage but this is a start!
-
Really interesting.
I work a little bit with C#. So do you want to share your work? Eventually i can help with some coding stuff for this. It would be awesome to have a Windows Widget.pimatic rocks!!!
-
@vanturenhout said:
Finally got some time to get it working…
I suppose you did not create issue #760, did you?! So, it might be helpful to share know-how with @neographikal on this stuff. May be you have an idea on how to get the cookie handling right.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
I think I can help, I will reply there
-
@vanturenhout said:
I think I can help, I will reply there And here
try { var option = new IO.Options { Reconnection = true, ReconnectionDelay = 1000, ReconnectionDelayMax = 3000, Timeout = 20000, ForceNew = true, QueryString = "username=uname&password=pwd" }; var socket = IO.Socket("http:/YOUR_IP", option); socket.On("deviceAttributeChanged", (object obj) => { var dev = JsonConvert.DeserializeObject<DeviceAttribute>((obj.ToString())); logger.Info($"{dev.attributeName} | {dev.deviceId} | {dev.time} | {dev.value}"); logger.Info(dev.deviceId); Console.WriteLine(obj); });
I created a class DeviceAttribute for deserializing the JSON object.