Xamarin Forms: How do I implement WebSockets? - xamarin

We want to transfer data from a client to a server in realtime, so we have decided to go with WebSockets.
Using Xamarin.Forms it was surprisingly difficult to find a suitable WebSocket library.
The best match was "WebSocket4Net" because it is directly suggested on Xamarin's Homepage. However I was not able to install this library, because it only supports versions of .NET up to v4.0. (We are using v4.5)
Whenever I try to change the target framework of my PCLs from v4.5 to v4.0 I get loads of weird errors stating "Windows.Input library could not be found", "ObservableCollection could not be found" etc.
So we are currently using the library "WebSocket.Portable.Core", which although lacking some functionality worked out. However for some reason we can only receive one message. The event "MessageReceived" always is just called once.
Has anyone heard about such a problem with WebSockets? Maybe it is just time to use another library, but I just can't find one?
I also can't find any solution how to implement WebSockets natively for each platform.

WebSockets.PCL has a native implementation for each platform and it's well documented
https://github.com/NVentimiglia/WebSockets.Pcl

Related

Haxe and native interop

I'm working on an online game that will communicate with the backend using gRPC protocol. There are gRPC client libraries for iOS, Android and JavaScript.
The plan is to implement the game logic and rendering using Haxe, but networking using native code with gRPC. What's the recommended approach for that? I can see 2 options:
Implement and build the game using Haxe in a way that it exposes some methods to native, e.g. a method to update game state using server data, and also accepts some callbacks from native, like a callback that is called every time the player makes an action that should be sent to the server. Then the callbacks and appropriate method calls can be implemented in the native projects generated by Haxe, using native tools like Xcode.
Implement networking using native tools like Xcode and expose them to Haxe somehow. Then the game logic written in Haxe will call native methods and provide callbacks implemented in Haxe to native.
What's the recommended approach? It seems to me that the first approach might be simpler and have less potential issues. If you could also point me to some articles about that, it would be great, since I haven't found anything detailed enough.
Even though not complete, maybe these guides can help:
https://github.com/snowkit/hxcpp-guide/tree/master/work-in-progress/build
or as an example:
https://snowkit.github.io/linc/

Read existing SMS using Xamarin Forms

I am new to Xamarin. Can someone point me to a way to read existing SMSs using Xamarin Forms.
I know we can do it using Android specific libraries (and probably with iOS specific libraries as well). But, I want to use a library that will help me avoid using platform specific library.
You will have to use platform specific code for this. Remember; all libraries out there actually are platform specific code but just offer you an abstraction. This includes Xamarin.Forms itself.
As mentioned by Jason in the comments, you aren't going to be able to do this on iOS altogether, they do not allow to read or sends texts directly. So you should probably rethink what you are trying to do.

ninject.extensions.factory on WP8?

I’m trying to use ninject.extensions.factory on WP8 but it seems to not work – I have no ToFactory() extension available . After looking at sources I see that everything is omitted when compiling on Windows Phone. Is there any way to use this extension and if not why is there WP compilation in builds?
WP does not support the Emit Framework that is used internally by Castle Dynamic Proxy. The Factory proxies rely on this framework. Therefore the extension just supports Func and Lazy.
Unless someone comes up with dynamic proxy framework for WP this won’t ever be supported.

Winsock LSP vs API hooking

I need your advices what to use - Layered Service Provider or just load mine DLL in all
process and hook necessary functions using, NCodeHook or EasyHook library.
This is needed for inspection of HTTP traffic.
P.S. This need to be done for commercial application
Thanks!
Before making a decision you need to consider the following:
Code hooking:
AV doesn't like code hooking, if you're using a library that has external DLLs, run a check with AV total before committing to it.
Make sure the library's license works for you, for example, for LGPL you won't be able to embed the library as static without becoming GPL yourself.
I heard people managed to hook Metro apps, it's something to investigate.
If you have another code hooking app, it may conflict.
LSP:
The default MS sample/installer is broken.
You may get something working on a VM or fresh install, but to get LSP working properly across all OS and browsers, will take 6-12 months.
Will not work with Metro apps.
In Komodia we use a combo of LSP/WFP for our SDK, knowing what I know now, if I'd go back 4 years, I'd use LSP all over again.
Good luck.
Using Easyhook will be a nice way to do it check the following http://www.sghaida.com/easyhook-for-systemcall-hooking/

Fastest/easiest way to build a WebKit based Windows application?

I am a web developer. I don't know how to build native Windows applications. I recently built a Mac desktop application (using MacRuby) which is a WebKit wrapper around one of my web applications. I'd like to do the same thing for Windows (preferably in Ruby, but whatever is easiest).
Since this is not the core of the application, I'd rather not spend a lot of time trying to build and maintain it. I just need a Windows application that can:
Open a specific website on application launch using an embedded WebKit WebView
Trigger Growl notifications via JavaScript (with some sort of named bridge)
What is the easiest, fastest, cleanest way to do this?
Update: So far I've come across some frameworks like Qt and Awesomium. I don't know how these frameworks compare to other options available, so if you have any opinions or advice, I would appreciate it.
Check out http://appjs.org/ it's built with NodeJS at its core! And it uses chromium webkit at it's core :D
Well, this is a very old question, but if you are still interested...
I'd recommend Qt. There are some very good books available with a lot of boilerplate code and wizard-type tools. You will be able to find example code demonstrating the embedded Webkit that you can modify to suit your needs. It is free and redistribution is free (last I knew). You won't have to know anything about native Windows development, nor even use any native Windows dev tools.
Good luck!

Resources