-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CSharp] DirectLine + WebSockets sample #86
[CSharp] DirectLine + WebSockets sample #86
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall, only a few small changes
{ | ||
private static string directLineSecret = ConfigurationManager.AppSettings["DirectLineSecret"]; | ||
private static string botId = ConfigurationManager.AppSettings["BotId"]; | ||
private static string fromUser = "DirectLineSampleClientUser"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the following comment above fromUser?
// fromUser is the field that identifies which user is sending activities to the Direct Line service.
// Because this value is created and sent within your Direct Line client, your bot should not
// trust the value for any security-sensitive operations. Instead, have the user log in and
// store any sign-in tokens against the Conversation or Private state fields. Those fields
// are secured by the conversation ID, which is protected with a signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
private static void WebSocketClient_OnMessage(object sender, MessageEventArgs e) | ||
{ | ||
// avoid null reference exception when no data received |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this comment to:
// Occasionally, the Direct Line service sends an empty message as a liveness ping. Ignore these messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other item I just thought of: can you add some code to the sample that exchanges the Direct Line secret for a token before using it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done and added call to Tokens API to retrieve token, also added note to README
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.Bot.Connector.DirectLine" version="3.0.0" targetFramework="net461" /> | ||
<package id="Microsoft.Rest.ClientRuntime" version="2.3.4" targetFramework="net461" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've hit binary incompatibilities between minor versions of Microsoft.Rest.ClientRuntime. 2.3.2 is probably a better example to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
select x; | ||
```` | ||
|
||
DirectLine v3.0 (unlike version 1.1) has support for Attachments (see [Adding Attachments to a Message](https://docs.botframework.com/en-us/core-concepts/attachments) for more information about attachments). Check out the `WebSocketClient_OnMessage` method in [Program.cs](DirectLineClient/Program.cs#L73-L90) to see how the Attachments are retrieved and rendered appropriately based on their type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In printed text, Direct Line is normally two words.
It's OK to collapse them in filenames, though. ("DirectLineClient.cs" is OK)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in Node too
Hi @dandriscoll , we've updated the PR with the latest feedback. |
No description provided.