Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread leak #52

Open
Hello-Mango opened this issue Feb 10, 2018 · 0 comments
Open

thread leak #52

Hello-Mango opened this issue Feb 10, 2018 · 0 comments

Comments

@Hello-Mango
Copy link

Hello-Mango commented Feb 10, 2018

Hi, i'm using SocketIoClientDotNet for .Net 4.0 and i have some problems. This example code make thread leak. the thread is more and more,and follow the source code,I find the method run in Heartbeat_net35.cs is not release thread,and now I Comment this method,it is work well,but i don't know this will have any problem,my code is here
`public void Connect()
{
socket = IO.Socket(GlobalStatic.PRINTCONFIG.HeartHOST.host, new IO.Options()
{
Reconnection = true,
ReconnectionDelay = 1000,
Transports = new List() { "websocket" },
Path = GlobalStatic.PRINTCONFIG.HeartHOST.path
});

        socket.On(Socket.EVENT_CONNECT, () =>
        {

            JObject jObject = JObject.Parse(Newtonsoft.Json.JsonConvert.SerializeObject(new
            {
                companyId = GlobalStatic.COMPANY.COMPANY_ID,
                token = GlobalStatic.TOKEN,
                hostId = GlobalStatic.HOST_ID,
                hostName = GlobalStatic.HOST_NAME,
                printerNames = GlobalStatic.HOSTINFO.PrinterName,
                source = "assistant",
                userId = GlobalStatic.UserDomain.user.USER_ID
            }));
            socket.Emit("authentication", jObject);
            Debug.WriteLine("authentication");

            socket.On(Socket.EVENT_DISCONNECT, (data) =>
            {
                Debug.WriteLine("heart disconnect" + data);
                flag = false;
                OnConnectionStatus?.Invoke(flag);
                socket.Disconnect();
            });
            socket.On("authenticated", (obj) =>
            {
                flag = true;
                OnConnectionStatus?.Invoke(flag);
                Debug.WriteLine("success:" + obj);
            });
            socket.On("unauthorized", (obj) =>
            {
                Debug.WriteLine("fail" + obj);
                socket.Disconnect();
            });

            socket.On("logOut", (obj) =>
            {
                OnLogOut?.Invoke();
            });
        });
    }

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant