File tree Expand file tree Collapse file tree 4 files changed +14
-14
lines changed Expand file tree Collapse file tree 4 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ class Node {
34
34
}
35
35
36
36
toString ( ) {
37
- let s = "(" + this . identity . split ( '/' ) [ 1 ] ;
37
+ let s = "(" + this . identity ;
38
38
for ( let i = 0 ; i < this . labels . length ; i ++ ) {
39
39
s += ":" + this . labels [ i ] ;
40
40
}
Original file line number Diff line number Diff line change @@ -50,7 +50,8 @@ class WebSocketChannel {
50
50
} ;
51
51
this . _ws . onmessage = ( event ) => {
52
52
if ( self . onmessage ) {
53
- self . onmessage ( new HeapBuffer ( event . data ) ) ;
53
+ var b = new HeapBuffer ( event . data ) ;
54
+ self . onmessage ( b ) ;
54
55
}
55
56
} ;
56
57
}
@@ -67,7 +68,7 @@ class WebSocketChannel {
67
68
} else if ( buffer instanceof HeapBuffer ) {
68
69
this . _ws . send ( buffer . _buffer ) ;
69
70
} else {
70
- throw new Exception ( "Don't know how to send buffer: " + buffer ) ;
71
+ throw new Error ( "Don't know how to send buffer: " + buffer ) ;
71
72
}
72
73
}
73
74
Original file line number Diff line number Diff line change @@ -21,8 +21,9 @@ import WebSocketChannel from "./ch-websocket";
21
21
import NodeChannel from "./ch-node" ;
22
22
import chunking from "./chunking" ;
23
23
import packstream from "./packstream" ;
24
- import { alloc } from "./buf" ;
24
+ import { alloc , CombinedBuffer } from "./buf" ;
25
25
import GraphType from '../graph-types' ;
26
+ import { int , isInt } from '../integer' ;
26
27
27
28
let Channel ;
28
29
if ( WebSocketChannel . available ) {
Original file line number Diff line number Diff line change @@ -72,17 +72,15 @@ try {
72
72
if ( buffer instanceof buf . HeapBuffer ) {
73
73
return decoder . decode ( buffer . readView ( length ) ) ;
74
74
}
75
- else if ( buffer instanceof buf . CombinedBuffer ) {
76
- let out = streamDecodeCombinedBuffer ( buffer . _buffers , length ,
77
- ( partBuffer ) => {
78
- return decoder . decode ( partBuffer . readView ( partBuffer . length ) , { stream :true } ) ;
79
- } ,
80
- ( ) => { return decoder . decode ( ) ; }
81
- ) ;
82
- return out ;
83
- }
84
75
else {
85
- throw new Error ( "Don't know how to decode strings from `" + buffer + "`." ) ;
76
+ // Decoding combined buffer is complicated. For simplicity, for now,
77
+ // we simply copy the combined buffer into a regular buffer and decode that.
78
+ var tmpBuf = buf . alloc ( length ) ;
79
+ for ( var i = 0 ; i < length ; i ++ ) {
80
+ tmpBuf . writeUInt8 ( buffer . readUInt8 ( ) ) ;
81
+ } ;
82
+ tmpBuf . reset ( ) ;
83
+ return decoder . decode ( tmpBuf . readView ( length ) ) ;
86
84
}
87
85
}
88
86
}
You can’t perform that action at this time.
0 commit comments