Version Details
SmartFoxServer: 2.6.0
SmartFox Client: 1.3.0
When I start my game client I attempt to connect to the server. Lets say that for some reason, my server is down or the client cannot establish a connection before I even attempt to send any other requests. I would like to get a notification that the connection attempt was not successful and then handle the failure appropriately. However all I get is messages in the log and no event is fired. What event should I listen for in this scenario or how can my client be notified that the connection attempt failed terminally?
The log messages are:
Code: Select all
SFS - WARN] You are not connected. Request cannot be sent: Sfs2X.Requests.ExtensionRequest
waiting for response...
[SFS - ERROR] TCPSocketLayer: Connection error: Connection refused at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket.Connect (System.Net.IPAddress address, Int32 port) [0x00000] in <filename unknown>:0
at Sfs2X.Core.Sockets.TCPSocketLayer.ConnectThread () [0x00000] in <filename unknown>:0
[SFS - DEBUG] [ BB-Connect ]: http://127.0.0.1:8080/BlueBox/BlueBox.do
[SFS - DEBUG] [ BB-Send ]: null|connect|null
[SFS - ERROR] ## BlueBox Error: Http error creating http connection: System.Net.Sockets.SocketException: Connection refused
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket.Connect (System.Net.IPAddress address, Int32 port) [0x00000] in <filename unknown>:0
at Sfs2X.Http.SFSWebClient.UploadValuesAsync (System.Uri uri, System.String paramName, System.String encodedData) [0x00000] in <filename unknown>:0
[SFS - DEBUG] [ BB-Connect ]: http://127.0.0.1:8080/BlueBox/BlueBox.do
[SFS - DEBUG] [ BB-Send ]: null|connect|null
[SFS - ERROR] ## BlueBox Error: Http error creating http connection: System.Net.Sockets.SocketException: Connection refused
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket.Connect (System.Net.IPAddress address, Int32 port) [0x00000] in <filename unknown>:0
at Sfs2X.Http.SFSWebClient.UploadValuesAsync (System.Uri uri, System.String paramName, System.String encodedData) [0x00000] in <filename unknown>:0
[SFS - DEBUG] [ BB-Connect ]: http://127.0.0.1:8080/BlueBox/BlueBox.do
[SFS - DEBUG] [ BB-Send ]: null|connect|null
[SFS - ERROR] ## BlueBox Error: Http error creating http connection: System.Net.Sockets.SocketException: Connection refused
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket.Connect (System.Net.IPAddress address, Int32 port) [0x00000] in <filename unknown>:0
at Sfs2X.Http.SFSWebClient.UploadValuesAsync (System.Uri uri, System.String paramName, System.String encodedData) [0x00000] in <filename unknown>:0
Below is the code I am using:
Code: Select all
MakeConnection()
{
SmartFox smartFox = new SmartFox(false);
// Register callback delegates
smartFox.AddEventListener(SFSEvent.CONNECTION, OnTest2);
smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, OnTest2);
smartFox.AddEventListener(SFSEvent.LOGIN, OnTest2);
smartFox.AddEventListener(SFSEvent.LOGIN_ERROR, OnTest2);
smartFox.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnTest2);
smartFox.AddEventListener(SFSEvent.LOGOUT, OnTest2);
smartFox.AddEventListener(SFSEvent.SOCKET_ERROR, OnTest2);
smartFox.AddEventListener(SFSEvent.CONNECTION_RETRY, OnTest2);
smartFox.AddEventListener(SFSEvent.CONNECTION_RESUME, OnTest2);
smartFox.Connect("127.0.0.1", 9933);
// For Debugging purposes only
Console.WriteLine("waiting for response...");
Thread.Sleep(3000);
}
// Method just for testing, not a real implementation
public void OnTest2(BaseEvent evt)
{
Console.WriteLine("response = " + evt);
Console.WriteLine("target = " + evt.Target);
Console.WriteLine("params = " + evt.Params);
foreach (DictionaryEntry entry in evt.Params)
Console.WriteLine(entry.Key + " = " + entry.Value);
Console.WriteLine("type = " + evt.Type);
}
Cheers,
Ben