diff --git a/.gitignore b/.gitignore
index b392b70..760ccf7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,5 @@
/Waste.CreateDB/obj
/Waste.SocketService.cs/bin
/Waste.SocketService.cs/obj
+/WasteHexTest/obj
+/WasteHexTest/bin
diff --git a/Waste.Doc/苏州平台地址.txt b/Waste.Doc/苏州平台地址.txt
new file mode 100644
index 0000000..22e7b5a
--- /dev/null
+++ b/Waste.Doc/苏州平台地址.txt
@@ -0,0 +1 @@
+https://iot.ljflytjl.cn/Developer/Devices
\ No newline at end of file
diff --git a/WasteConsoleTest/WasteConsoleTest/WSocketClientHelp.cs b/WasteConsoleTest/WasteConsoleTest/WSocketClientHelp.cs
index 542ba83..794d87f 100644
--- a/WasteConsoleTest/WasteConsoleTest/WSocketClientHelp.cs
+++ b/WasteConsoleTest/WasteConsoleTest/WSocketClientHelp.cs
@@ -8,14 +8,14 @@ using System.Threading.Tasks;
namespace WasteConsoleTest
{
- public class WSocketClientHelp
+ public class WSocketClientHelp
{
- ClientWebSocket ws = null;
- Uri uri = null;
- bool isUserClose = false;//是否最后由用户手动关闭
- public static string Secret = "T2hZmT3LhIvl0a0E";
- public static string SecretHash = "bvfEFN9CegW1SLEOlOGA5d+ht3RlXrmAOAr099AG7K8=";
- public static string deviceid = "08d97f54-c0f6-4f57-81aa-296f93be7eb2";
+ private ClientWebSocket ws = null;
+ private Uri uri = null;
+ private bool isUserClose = false;//是否最后由用户手动关闭
+ public static string Secret = "ai5ak2Q5TpkOLO4T";
+ public static string SecretHash = "6c29321e21e9c202";
+ public static string deviceid = "08d99b6b-a16f-4a5a-81ad-ffeaa9fdc94e";
//
/// WebSocket状态
@@ -26,20 +26,24 @@ namespace WasteConsoleTest
/// 包含一个数据的事件
///
public delegate void MessageEventHandler(object sender, string data);
+
public delegate void ErrorEventHandler(object sender, Exception ex);
///
/// 连接建立时触发
///
public event EventHandler OnOpen;
+
///
/// 客户端接收服务端数据时触发
///
public event MessageEventHandler OnMessage;
+
///
/// 通信发生错误时触发
///
public event ErrorEventHandler OnError;
+
///
/// 连接关闭时触发
///
@@ -67,7 +71,7 @@ namespace WasteConsoleTest
//初始化链接
isUserClose = false;
ws = new ClientWebSocket();
- // ws.Options.AddSubProtocol("protocol1"); //使用的协议
+ // ws.Options.AddSubProtocol("protocol1"); //使用的协议
ws.Options.SetRequestHeader("device", deviceid); //设备ID
ws.Options.SetRequestHeader("secret", SecretHash); //设备secrethash
ws.Options.SetRequestHeader("time", GetTimestamp().ToString()); //时间戳
@@ -134,8 +138,8 @@ namespace WasteConsoleTest
Close(ws.CloseStatus.Value, ws.CloseStatusDescription + netErr);
}
});
-
}
+
///
/// 增加记录分隔符
///
@@ -146,6 +150,7 @@ namespace WasteConsoleTest
List t = new List(data) { 0x1e };//0x1e record separator
return t.ToArray();
}
+
//删除记录分隔符
private static byte[] RemoveSeparator(byte[] data)
{
@@ -153,6 +158,7 @@ namespace WasteConsoleTest
t.Remove(0x1e);
return t.ToArray();
}
+
///
/// 获取时间戳
///
@@ -163,6 +169,7 @@ namespace WasteConsoleTest
int timestamp = Convert.ToInt32((DateTime.Now - dateTimeStart).TotalSeconds);
return timestamp;
}
+
///
/// 使用连接发送文本消息
///
@@ -225,7 +232,6 @@ namespace WasteConsoleTest
}
catch (Exception ex)
{
-
}
ws.Abort();
@@ -236,4 +242,4 @@ namespace WasteConsoleTest
});
}
}
-}
+}
\ No newline at end of file