consuming Wcf polling duplex service with non-silverlight client? - javascript

i have been working on a online game of TicTacToe and to achive it i am using WCF polling duplex service.
But after thorough searching for the whole week, i think it is possible for only silverlight clients.
If anyone knows that polling duplex service can be used with non Silverlight client like mvc3,asp.net or likewise javascript and so ,,,, then please give me idea, link or sample code snipet.
Thanks in Advance...

you should build your wcf with a REST endpoint. That could be the way to go to consume with javascript.
You can start learning how to do that here: http://msdn.microsoft.com/en-us/magazine/dd315413.aspx

Don't forget about very cool and useful (auto json serialization/deserialization, easy debugging) WebMethods/PageMethods
To use server WebMethods from some external (outside page) wcf service you can add script reference to asmx "JS" endpoint. For ex. "/_vti_bin/PageService.asmx/JS" and you are good to go:
{WCFNamespace}.{WebMethodName}({arguments}) in javascript. Very handy.
By the way Ascx controls for ex. doesn't allow to use PageMethods! And Sharepoint visual webparts based on ascx.

Related

Is there any way to send http requests from JS by pushing button, to a C++

I am currently designing a GUI for a piece of hardware. We want the GUI to be able to be accessed over a browser. The browser would be displaying a map generated from C++ code, but I also need to send some params to the code that generates the map from buttons on the JS front end? Is there anyway to accomplish this. I have done a little research so far and know about web sockets and AJAX, but I am not entirely sure it is what I am looking for. In an ideal world I would be able to just send UDP packets, but my research tells me that is not possible, not is TCP. Is this correct?
Thank's in advance for any help!
Your C++ code could setup a server that listens for requests. You could use libhttpserver, for example. Then, in your JavaScript code, you can use XMLHttpRequest or the Fetch API (for newer browsers) to make an HTTP request to the server, which would then return a new static page (with the generated map embedded into the page).

How to use Vuforia Web Services API with JavaScript?

I've trying several things but nothing is really working. There are some examples in Vuforia Web Services API documentation using PHP but there's nothing with JavaScript.
It seems there's no Javascript API available for VWS. Even if it were, you will probably not be able to call it from web browser because of Cross domain policies.
That said, you can write your own back-end client in JS or run one of the samples in (Java/PHP/Python) in the server and expose all the methods as REST end-points.
VWS seems to be plain old REST services, which can be called from any language.
Only hurdle in writing your own simple client is to calculate signature for the requests, here's the logic to calculate signature from the documenation
Ref: https://library.vuforia.com/content/vuforia-library/en/articles/Training/Using-the-VWS-API.html
After you have the function for signature you will have to convert sample requests from the download for selected language to Javascript
These are the files in sample that I downloaded for Java, (https://github.com/christolb/MobEmbedded/tree/master/Pradeep/VWS%20Sample, it's uploaded by someone else on Github, I'm not adding it here myself, as I'm unsure of the licensing restrictions)
DeleteTarget.java
GetAllTargets.java
GetTarget.java
PostNewTarget.java
SignatureBuilder.java
Summary.java
TargetState.java
TargetStatusListener.java
TargetStatusPoller.java
UpdateTarget.java

Real Time Background Service

I am now developing a mobile app using ionic framework and it's using larvel 4 REST API to do CRUD operations with MySql database. Based on the app requirement, the mobile app needs to call backend service everytime in order to complete certain process.
I am using Angular Resource to call those APIs and i am calling them every 3 secs using Javascript setinterval function. However, the app is working, I don't really feel that it's a good practice to do because it's a heavy task for both server and client.
Could you guys please guide me how I should solve this kind of situation and i really appreciate your help. Especially, which kind of tools I should setup and what are they? Thank you.
setInterval isn't a best practice to receive new data from your API server/DB because the server could get flooded when too many users access your web site. However there is a prettier solution: WebSockets. With websockets you receive notifications realtime. I am not a PHP developer so I don't know what WebSocket libraries are used for Laravel/PHP development. But on the AngularJS part I can recommend this: https://github.com/gdi2290/angular-websocket
A WebSocket example (non-related): http://jsfiddle.net/EAVvQ/24/
Hope this helped.
Cheers!

Call SOAP webservice(Made in .NET) through Javascript

I am developing one mobile web application.
In this, i want to call a Web Service and fetch data from their using Java Script only.
I searched a lot and try to implement some code also but it didn't help me out.
One thing is that the Web Service was made in .NET using SOAP.
So, please help me to solve it immediately.
One easy would be to create an ASP.NET Web API Http service wrapper around your current webservice and use jQuery to access it. This will be much simpler than using JS to access a SOAP service.
More on ASP.NET Web API: http://www.asp.net/web-api

Comet hints using .Net

I have a web site showing some data. It is constructed of:
- A web app, showing data.(ASP.Net app, but I don't use server side features in showing data; It's pure HTML and JavaScript)
- A Service providing data in Json format.(WCF)
the client requests data and receives and shows them.
Now I want to change the process in order to works in push base strategy.
I googled and I found out that that Comet is a good choice, but I don't found practical samples in my case.
Some samples had client with php (server-side) and so on.
Now I want some hints on using comet in a way that client is pure JavaScript and HTML and server is WCF (server pushes Json to JavaScript )
look at nComet it is an asp.net implementation of comet, not sure if it is wcf yet, but i would have thought much of the code would be reusable.
Or better pokein

Categories