Repository navigation
Expand file tree
/
Copy pathMySQLNetworkPacket.cls
More file actions
84 lines (62 loc) · 1.71 KB
/
Copy pathMySQLNetworkPacket.cls
File metadata and controls
84 lines (62 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"Filed out from Dolphin Smalltalk"!
Object subclass: #MySQLNetworkPacket
instanceVariableNames: 'length number data'
classVariableNames: 'MaxPacketLength'
poolDictionaries: ''
classInstanceVariableNames: ''!
MySQLNetworkPacket guid: (GUID fromString: '{76b472fb-c6d3-4db8-9750-f16f16e74ac4}')!
MySQLNetworkPacket comment: 'A MySQL Network packet'!
!MySQLNetworkPacket categoriesForClass!MySQL-Core-Network! !
!MySQLNetworkPacket methodsFor!
data ^ data!
data: buffer "should be ByteArray" data := buffer!
isOfMaxLength ^ length = MaxPacketLength!
length ^ length !
length: size length := size!
maxLength ^ MaxPacketLength!
number ^ number!
number: num number := num!
readFrom: aStream length := aStream next + (aStream next << 8) + (aStream next << 16). number := aStream next. data := aStream next: length.!
writeTo: aStream length = data size ifFalse: [ self error: 'Mismatch between packet length and data size' ]. aStream nextPut: (length byteAt: 1); nextPut: (length byteAt: 2); nextPut: (length byteAt: 3);
nextPut: (number byteAt: 1);
nextPutAll: data;
flush! !
!MySQLNetworkPacket categoriesForMethods!
data!accessing!public! !
data:!accessing!public! !
isOfMaxLength!public!testing! !
length!accessing!public! !
length:!accessing!public! !
maxLength!accessing!public! !
number!accessing!public! !
number:!accessing!public! !
readFrom:!public!reading! !
writeTo:!public!writing! !
!
!MySQLNetworkPacket class methodsFor!
initialize MaxPacketLength := 16rFFFFFF!
maxLength ^ MaxPacketLength! !
!MySQLNetworkPacket class categoriesForMethods!
initialize!class initialization!public! !
maxLength!accessing!public! !
!