websocket-node-express's People
Forkers
uthistran zakaria-sarmini utnas katzvelraj ankita-ecsion ruparee kzaporowski daveek bfojas giejay uluru-phatnguyen tiposaurio surbhiairan jyoken1 biiloom cvinodhkumar77 douglaslira aramkumar06 syeduali93 paulmsegeya pramadito kylebradshaw dthankab mrhb raising luisfelipecunhaduarte jdixit2848 coregatekit gregcummines marcusjack benjaminv tan-diling stascnb ansasa2122daw2 zmatarasso sandesh003 ferronrsmithwebsocket-node-express's Issues
JSON parsing issue when we have message sent with open connection
Hi - Thanks for the code. The client project works fine when there is no message sent from server (our own server) with open connection. But when there is a message sent with open connection, it throws a json parsing error. Could you pls help?
SyntaxError: Unexpected token H in JSON at position 0
at JSON.parse (<anonymous>)
at deserializer (WebSocketSubject.js:12)
at tryCatcher (tryCatch.js:6)
at WebSocket.socket.onmessage [as __zone_symbol__ON_PROPERTYmessage] (WebSocketSubject.js:174)
at WebSocket.wrapFn (zone.js:1188)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:3815)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:496)
bug(client): cannot read viewer before name selection
When I start the app, I see in my console:
ERROR TypeError: Cannot read property 'nativeElement' of undefined
at AppComponent.getDiff (app.component.ts:80)
at AppComponent.scrollToBottom (app.component.ts:86)
at eval (app.component.ts:75)
at ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4724)
at ZoneDelegate.invokeTask (zone.js:420)
at Zone.runTask (zone.js:188)
at ZoneTask.invokeTask (zone.js:496)
at ZoneTask.invoke (zone.js:485)
at timer (zone.js:2025)
After I select my name it disapears
I could see you fixing this two ways if you want to, either add check to getDiff()
private getDiff(): number {
- if (this.viewer) {
- const nativeElement = this.viewer.nativeElement;
- return nativeElement.scrollHeight - (nativeElement.scrollTop + nativeElement.clientHeight);
- } else {
- return -1;
- }
+ const nativeElement = this.viewer.nativeElement;
+ return nativeElement.scrollHeight - (nativeElement.scrollTop + nativeElement.clientHeight);
}
or, I think better yet, add default viewer to app.component.html
<input matInput placeholder="Your name here" type="text" [(ngModel)]="sender" [ngModelOptions]="{updateOn: 'blur'}">
</mat-form-field>
</div>
+ <div *ngIf="!sender" #viewer></div>
<div *ngIf="!!sender" #viewer class="body">
<div class="viewer">
<div class="message" *ngFor="let msg of serverMessages" [ngClass]="{'bold': msg.isBroadcast, 'others': !isMine(msg)}">
Could you add unit tests as well?
Hi,
would you be able to add unit tests? At least to the server. Say using Mocha, Chai and Sinon... I would like to know how to mock the ws libary and how to test the callbacks...
Thank you.
Kind regards,
Jarek
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.