예제 #1
0
 static DesktopClient()
 {
     Status = Enuns.UniBot.Server.Status.Connecting;
     client = new Client(Settings.Server.IPAddress.ToString(), Settings.Server.Port);
     client.OnRead += new Unimake.Socket.Abstract.ClientBase.EventHandlerConnection(client_OnRead);
     client.OnError += new Unimake.Socket.Abstract.ClientBase.EventHanlderError(client_OnError);
     client.OnConnect += new Unimake.Socket.Abstract.ClientBase.EventHandlerConnection(client_OnConnect);
     client.OnDisconnect += new Unimake.Socket.Abstract.ClientBase.EventHandlerConnection(client_OnDisconnect);
     client.Connect();
 }
예제 #2
0
        static void client_OnError(string errorMessage, System.Net.Sockets.Socket soc, int errorCode)
        {
            if(errorCode == 10056)
            {
                client.Disconnect();
                client = null;
                GC.WaitForPendingFinalizers();
                client = new Client(Settings.Server.IPAddress.ToString(), Settings.Server.Port);
                client.OnRead += new Unimake.Socket.Abstract.ClientBase.EventHandlerConnection(client_OnRead);
                client.OnError += new Unimake.Socket.Abstract.ClientBase.EventHanlderError(client_OnError);
                client.Connect();
            }
            else
            {
                Success = false;
                Message = String.Format("Código: {0} \r\nMensagem: {1}", errorCode, errorMessage);
                Status = Enuns.UniBot.Server.Status.Error;
            }

            ServerLog.Log(Settings.Server.IPAddress, TipoEvento.ClientOnError, errorMessage);
        }