I'm using the following C# code to show real time data in my desktop application
string strQuery = "AbcD";
string socketURI = "https://mysocketio.com/";
Dictionary<string, string> dictQS = new Dictionary<string, string>();
dictQS.Add("token", strQuery);
dictQS.Add("transport", "websocket");
try
{
IO.Options options = new IO.Options() { AutoConnect = true, ForceNew = true, Path = "/socket/", Query = dictQS };
var cSocket = IO.Socket(socketURI, options); //An item with the same key has already been added
cSocket.Connect();
cSocket.On(Socket.EVENT_CONNECT, () =>
{
Console.WriteLine("success");
});
cSocket.On("change", (data) => {
MessageBox.Show("change");
});
cSocket.On(Socket.EVENT_DISCONNECT, () =>
{
Console.WriteLine("Disconnected");
});
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
But I got an error An item with the same key has already been added
. Please provide a solution.
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…