-
Notifications
You must be signed in to change notification settings - Fork 15
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
Node v10 changes and added consistency with .NET core example #4
base: master
Are you sure you want to change the base?
Conversation
signalr-node-server/app.js
Outdated
console.log(`${id} disconnected`); | ||
}); | ||
|
||
chat.on('send', (message) => { | ||
chat.clients.all.send('send', message); | ||
chat.on('SendMessage', (user, message) => { |
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.
changed commands to match the .NET core example https://docs.microsoft.com/en-us/aspnet/core/tutorials/signalr?view=aspnetcore-3.1&tabs=visual-studio-code
|
||
const chat = signalR.mapHub('/chat'); | ||
const chat = signalR.mapHub('/chatHub'); |
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.
changed hub endpoint to match the .NET core example https://docs.microsoft.com/en-us/aspnet/core/tutorials/signalr?view=aspnetcore-3.1&tabs=visual-studio-code
} | ||
else { | ||
this._doHandshakeResponse( | ||
`Requested protocol '${handshakeMessage.protocol}' is not available.` |
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.
Why this formatting change?
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.
Ah this is caused by the .prettierrc
file printWidth
setting I guess (max 100 chars per line)
constructor() { | ||
this._methods = new Map(); |
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.
Why did you make this a member?
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.
This was the part where Node v10 failed. I figured this would be an easy solution but not sure
@@ -39,12 +39,12 @@ class HubConnection { | |||
this._closeHandler = null; | |||
|
|||
this._handshakeTimeout = setTimeout(() => { | |||
if (!this._handshake) { | |||
if (!this._handshake && this.connection) { |
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.
failed sometimes when reconnecting / session ended, not sure but this fixed 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.
Hmm.
for (const group of client.groups) { | ||
// REVIEW: Performance.. | ||
this.removeFromGroup(connection.id, group); | ||
if (client) { |
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.
failed sometimes when reconnecting / session ended, not sure but this fixed it.
<input type="text" id="user" placeholder="user" required /><br /> | ||
<input type="text" id="message" placeholder="message" required /><br /> | ||
<button type="submit" id="send">Send</button> | ||
</form> |
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.
updated the form so it matches the .NET example (hence the user field)
connection.on('send', message => { | ||
var li = document.createElement('li'); | ||
li.innerText = message; | ||
connection.on('ReceiveMessage', (user, message) => { |
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.
updated the event names so it matches the .NET example
chat.on('send', (message) => { | ||
chat.clients.all.send('send', message); | ||
chat.on('sendmessage', (user, message) => { | ||
chat.clients.all.send('receivemessage', user, message); |
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.
changed this to lowercase events for consistency with the "sendmessage" toLowerCase function in signalr.js
Node v10 changes. And check CHANGELOG.md for more changes