The example given on this website working properly following is the link https://blogs.msdn.microsoft.com/brunoterkaly/2012/02/28/node-js-a-chat-server-written-in-node-and-a-client-app-written-in-c/#comment-12985
but when i am trying to implement this client app in uwp template .
issues are coming in Tcpclient , NetworkStream and some other classes which are not available in uwp.
The chat client in the blog you posted here is a WPF project, not a uwp app project. Classes like TcpClient and NetworkStream under System.Net.Sockets namespace are not supported in uwp.
In uwp we use classes under Windows.Networking.Sockets namespace instead, E.g.StreamSocket, StreamSocketListener and so on. More details please refence the sockets official documents in uwp. And the uwp official sample about sockets is here.
I also helped you transferred the chat client in the blog from wpf to uwp, you can directly download it from GitHub for further testing.
Parts of the code for uwp chat client:
private async void cmdConnect_Click(object sender, RoutedEventArgs e)
{
AddPrompt();
Windows.Networking.HostName serverHost = new Windows.Networking.HostName("127.0.0.1");
await tcpClient.ConnectAsync(serverHost, "8000");
serverStream = tcpClient.OutputStream.AsStreamForWrite();
StreamWriter writer = new StreamWriter(serverStream);
string request = txtChatName.Text.Trim() + " is joining";
await writer.WriteLineAsync(request);
await writer.FlushAsync();
Stream streamIn = tcpClient.InputStream.AsStreamForRead();
StreamReader reader = new StreamReader(streamIn);
string response = await reader.ReadLineAsync();
}
Related
I want to do the following in C#:
load website in background (google search site)
look into the sourcecode of this site and get a specific link
I tried this before:
Use the WebClient Class to download the String of the website
WebClient client = new WebClient();
string reply = client.DownloadString(url);
client.DownloadFile(gesamter_String, #"C:\neu\localfile.html");
Console.WriteLine(reply);
Use the HTTPClient Class to download the String of the website
string url = hyperlink;
HttpClient client = new HttpClient();
using (HttpResponseMessage response = client.GetAsync(url).Result)
{
using (HttpContent content = response.Content)
{
string result =content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
}
But the downloaded or displayed sourcecode is very small and doesn't contain the specific link.
However my links works. I have opened the link in foreground with this: System.Diagnostics.Process.Start(url);. This foreground opened site contains the full sourcecode.
Thanks a lot.
SendGrid advises using its Version 6.3, but that only supports .NET 4.5 ; My app is 4.6.1 and is serving on an Azure app service.
I want to try to send smtp through SendGrid and see only this page for documentation. It does not show how to write the message in the IdentityConfig class and it does not say how/where to reference the SendGrid apikey via Azure's Environment Variable storage https://sendgrid.com/docs/Integrate/Code_Examples/v2_Mail/csharp.html#-Using-NETs-Builtin-SMTP-Library.
I'd really appreciate some help on this.
I looked again at the SendGrid documentation and saw that the updates in late 2017 didn't say that the api only targeted 4.5.*, so decided to try the most recent version, 9.8 .
It worked with the Register Post method out of the box, simply adding a redirect to a "confirmationsent" view.
Here's the code that works for me:
public Task SendAsync(IdentityMessage message)
{
return configSendGridasync(message);
}
private async Task configSendGridasync(IdentityMessage message)
{
var apiKey = System.Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
var client = new SendGridClient(apiKey);
var msg = new SendGridMessage();
msg.AddTo(message.Destination);
msg.From = new EmailAddress("info#XXX.org", "Website Name");
msg.Subject = message.Subject;
msg.PlainTextContent = message.Body;
msg.HtmlContent = message.Body;
var response = await client.SendEmailAsync(msg);
}
}
Is it possible to integrate API.Ai into a web channel? Microsoft Bot framework has an option that the bot can be invoked through a web chat along with FB messenger, skype etc. For this MSFT provies a chat url which can be embedded in any html page. Can the same happen through API.AI?
Is it also possible to invoke the NLP part of API.Ai, like the trained intents, context etc. from any stand-alone application?
Yes you can invoke the NLP part of api.ai with the help of events.
First create events with the help of the following URL :
https://docs.api.ai/docs/concept-events
Now from your web application you could use the following code to invoke these events,
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("https://api.api.ai/v1/query?v=20150910");
StringEntity params =new StringEntity("{\"event\":{ \"name\": \"custom_event\", \"data\": {\"name\": \"Sam\"}}, \"timezone\":\"America/New_York\", \"lang\":\"en\", \"sessionId\":\"123abc\"}");
request.addHeader("content-type", "application/json");
request.addHeader("Authorization", "Bearer 0651225b57464d209936252796106e59");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null)
{
System.out.println(line);
}
This would then return you the appropriate response.
Yes you can.
You need to build a frontend application ables to invoke api.ai services (by api.ai sdk).
I ve installed Jasper Reports Server and i want to develop a GWT application to call the jasper server web services as : Login , Running a report in the server, listing reports, View User .... I 've implemented web services in java through the Jasper Soft web services guide for example for authentitcation :
public static void connect(String URL,HttpClient httpclient)
{
serverURL = URL;
//report path
HttpClient client = httpclient;
// Setting Login URL in a POST method
String loginURL = serverURL+"rest/login";
PostMethod postMethod = new PostMethod(loginURL);
// Set authentication parameters
postMethod.addParameter("j_username", "jasperadmin");
postMethod.addParameter("j_password", "jasperadmin");
int statusCodeL;
try {
statusCodeL=client.executeMethod(postMethod);
if (statusCodeL != HttpStatus.SC_OK) {
System.out.println("Login failed: " + postMethod.getStatusLine());
return;
}
}catch (HttpException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
But i can t explore those web services when developing with GWT framework Which is no compatible with HTTPClient, even when using the Request Builder the authentication failed.
My question is HOW TO INTEGRATE JASPER REPORTS SERVER INTO GWT APPLICATION ?
I also had to implement the Jasper Report integration at my company. And yes, I also had difficulties. We ended up only using the Jasper Report Library to generate our report and we did the rest ourselves (listing reports, storing generated reports, etc...).
It is possible to use GWT. In the HttpServlet, have that call the Jasper APIs. Then the HttpServlet can return the results of the Jasper call to GWT. I put a comment that links to where the answer is.
I want my game player to able to post game score to his facebook wall from WP7 game. I have gone through following tutorials
1> Tutorial: Logging Into Facebook with Windows Phone 7 (Silverlight) (source code is downloaded from their website.)
PROBLEM: After running sample project, i can login to facebook, but can't figure out how to post the message.
2> I have download sample project from github.
PROBLEM: When i open the project for WP7, a window pop up saying "Solution folder are not supported in this version of application. solution folder '.nudget' will be displayed as unavailable."
I have tried downloading nuget updates as suggested by Prabir's Blog.
3> With this tutorial, i am able to login to facebook.
PROBLEM: unable to post any message. it display inside emulator "The remote server returned an error:NotFound".
please let me know if you find this question inappropriate or lack of research, i will romove question immediately.
I am novice to both WP7 and C#. Please help me to correct above problems.
Thanks in advance
EDIT : Finally got 3rd one working by making small changes in PGLogin.xaml.cs, just change "PRE" to "pre" in "wbLogin_LoadCompleted" method. but still not much satisfy. because its work and sometime don't. it's not stable. and don't know how to logout. any suggestion?
Another user had this exact issue, it was resolved using the following code:
var args = new Dictionary<string, object>();
args["name"] = "Check this out";
args["link"] = "www.xyz.com";
args["caption"] = "";
args["description"] = "description";
args["picture"] = "";
args["message"] = "Check this out";
args["actions"] = "";
FacebookAsyncCallback callBack = new FacebookAsyncCallback(this.postResult);
fbApp.PostAsync("me/feed", args, callBack);
private void postResult(FacebookAsyncResult asyncResult)
{
System.Diagnostics.Debug.WriteLine(asyncResult);
}
Post to Facebook wall using WP7 and Facebook.dll
ShareLinkTask shareLinkTask = new ShareLinkTask();
shareLinkTask.Title = "Divum Photo Browser";
shareLinkTask.LinkUri = new Uri(list_photos.ElementAt(index_).imageUrl, UriKind.Absolute);
shareLinkTask.Show();