Skip to content

Commit df74f3d

Browse files
committed
[Modify] Polish it
1 parent 9775d93 commit df74f3d

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

Example1/AudioStreamer.cs

+7-8
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,13 @@ private byte[] createBinaryMessage (float[,] bufferArray)
119119

120120
private string createTextMessage (string type, string message)
121121
{
122-
return JsonConvert.SerializeObject (
123-
new TextMessage {
124-
user_id = _id,
125-
name = _name,
126-
type = type,
127-
message = message
128-
}
129-
);
122+
return new TextMessage {
123+
UserID = _id,
124+
Name = _name,
125+
Type = type,
126+
Message = message
127+
}
128+
.ToString ();
130129
}
131130

132131
private void processBinaryMessage (byte[] data)

Example1/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public class Program
77
{
88
public static void Main (string[] args)
99
{
10-
using (var streamer = new AudioStreamer ("ws://agektmr.node-ninja.com:3000/socket"))
11-
//using (var streamer = new AudioStreamer ("ws://localhost:3000/socket"))
10+
//using (var streamer = new AudioStreamer ("ws://agektmr.node-ninja.com:3000/socket"))
11+
using (var streamer = new AudioStreamer ("ws://localhost:3000/socket"))
1212
{
1313
string name;
1414
do {

Example1/TextMessage.cs

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
1+
using Newtonsoft.Json;
12
using System;
23

34
namespace Example1
45
{
56
internal class TextMessage
67
{
7-
public uint? user_id;
8-
public string name;
9-
public string type;
10-
public string message;
8+
[JsonProperty ("user_id")]
9+
public uint? UserID {
10+
get; set;
11+
}
12+
13+
[JsonProperty ("name")]
14+
public string Name {
15+
get; set;
16+
}
17+
18+
[JsonProperty ("type")]
19+
public string Type {
20+
get; set;
21+
}
22+
23+
[JsonProperty ("message")]
24+
public string Message {
25+
get; set;
26+
}
27+
28+
public override string ToString ()
29+
{
30+
return JsonConvert.SerializeObject (this);
31+
}
1132
}
1233
}

0 commit comments

Comments
 (0)