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

Reconnect after an initial connection failure #34

Open
sfranzyshen opened this issue Nov 7, 2018 · 1 comment
Open

Reconnect after an initial connection failure #34

sfranzyshen opened this issue Nov 7, 2018 · 1 comment

Comments

@sfranzyshen
Copy link

sfranzyshen commented Nov 7, 2018

I have a scenario where the unity socket.io client might get started before the server is ready for connections ... I would like to have the client code repeatedly attempt connection until a connection is made. I'm having problems figuring out how ... this doesn't work

socket.On(SystemEvents.connectError , (Exception e) => {
	Debug.Log("Socket.io Connection Error: " + e.ToString());
	socket = Socket.Connect(serverUrl);
}

I see changes in the develop branch for disconnect and reconnect ... but when I try and use Socket.Reconnect(socket) I get errors ...

@sfranzyshen
Copy link
Author

added ... to Socket.cs ...

        /// <summary>
        /// Reconnects the socket which is disconnected
        /// </summary>
        /// <param name="socket"></param>
        public static void Reconnect(Socket socket) {
            SocketManager.Instance.Reconnect(socket, 1);
        }

then (in the Connect.cs example) catch event connectError and try again ... using Socket.Reconnect()

socket.On(SystemEvents.connectError , (Exception e) => {
	Debug.Log("Socket.io Connection Error: " + e.ToString());
	Socket.Reconnect(socket);
});

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