Skip to content

Commit 4cfdbeb

Browse files
committed
[Modify] Use the Is properties
1 parent f7330ff commit 4cfdbeb

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,21 @@ ws.OnMessage += (sender, e) => {
138138

139139
`e` has passed as a `WebSocketSharp.MessageEventArgs`.
140140

141-
`e.Type` property returns either `WebSocketSharp.Opcode.Text` or `WebSocketSharp.Opcode.Binary` that represents the message type. So by checking it, you can determine which item you should use.
141+
If you would like to get the message data, you should access `e.Data` or `e.RawData` property. And you can determine which property you should access by checking `e.IsText` or `e.IsBinary` property.
142142

143-
If it returns `Opcode.Text`, you should use `e.Data` property that returns a `string` (represents a **text** message).
143+
If `e.IsText` is `true`, you should access `e.Data` that returns a `string` (represents a **text** message).
144144

145-
Or if it returns `Opcode.Binary`, you should use `e.RawData` property that returns a `byte[]` (represents a **binary** message).
145+
Or if `e.IsBinary` is `true`, you should access `e.RawData` that returns a `byte[]` (represents a **binary** message).
146146

147147
```csharp
148-
if (e.Type == Opcode.Text) {
148+
if (e.IsText) {
149149
// Do something with e.Data.
150150
...
151151

152152
return;
153153
}
154154

155-
if (e.Type == Opcode.Binary) {
155+
if (e.IsBinary) {
156156
// Do something with e.RawData.
157157
...
158158

@@ -165,14 +165,12 @@ And if you would like to notify that a **ping** has been received, via this even
165165
```csharp
166166
ws.EmitOnPing = true;
167167
ws.OnMessage += (sender, e) => {
168-
if (e.Type == Opcode.Ping) {
168+
if (e.IsPing) {
169169
// Do something to notify that a ping has been received.
170170
...
171171

172172
return;
173173
}
174-
175-
...
176174
};
177175
```
178176

0 commit comments

Comments
 (0)