public static void ReceiveCallback(IAsyncResult res)
 {
     try
     {
         ReceiveObject ro  = (ReceiveObject)res.AsyncState;
         int           len = sock.EndReceive(res);
         ro.sb.Append(Encoding.ASCII.GetString(ro.buffer, 0, len));
         if (ro.sb.Length > 0)
         {
             ServerProcessing.processReceivedMessage(ro.sb.ToString());
         }
         receiveDone.Set();
     }
     catch (SocketException) //when server crash or close
     {
         if (closingApp)
         {
             return;
         }
         MessageBox.Show("Utracono połaczenie z serwerem, uruchom aplikacje ponownie!");
         System.Windows.Forms.Application.Exit();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
         return;
     }
 }
 public static void logout()
 {
     ServerProcessing.processSendMessage(MessageProccesing.CreateMessage(Options.LOGOUT));
     logoutNotFinished = true;
     do
     {
     } while (logoutNotFinished);
 }
Beispiel #3
0
        public static void login(String username, String pass)
        {
            Login login = new Login(username, pass);

            ServerProcessing.processSendMessage(MessageProccesing.CreateMessage(Options.LOGIN, login));
            loginNotFinished = true;
            do
            {
            } while (loginNotFinished);
        }
Beispiel #4
0
 public static void ReceiveCallback(IAsyncResult res)
 {
     try
     {
         ReceiveObject ro  = (ReceiveObject)res.AsyncState;
         int           len = sock.EndReceive(res);
         ro.sb.Append(Encoding.ASCII.GetString(ro.buffer, 0, len));
         if (ro.sb.Length > 0)
         {
             ServerProcessing.processReceivedMessage(ro.sb.ToString());
         }
         receiveDone.Set();
     }
     catch (Exception e)
     {
         return;
         //TODO Implement faults
     }
 }
Beispiel #5
0
        static void Main(string[] args)
        {
            OperatingSystem os = Environment.OSVersion;

            if (os.Platform == PlatformID.Win32NT)
            {
                if (!(os.Version.Major >= 6))
                {
                    MessageBox.Show("Program działa tylko na systemach Windows Vista/7 i nowszych!");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Program działa tylko na systemach Windows Vista/7 i nowszych!");
                return;
            }

            setServ = new SettingsService();

            /*if (args.Length==1) //Temporary change of server IP Address
             * {
             *  //MessageBox.Show("Tymczasowo nadpisano IP serwera za pomocą argumentu! Adres IP nie zostanie zapisany w konfiguracji.");
             *  Shared.IP.serverIp = args[0];
             * }*/

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            ServerConnectorAsync.StartConnection();
            ServerProcessing.startUp();

            Task.Run(() => ServerConnectorAsync.ReceiveWhile());
            Application.Run(new LoginForm());
            ServerConnectorAsync.closingApp = true;
            ServerConnectorAsync.StopConnection();
        }
Beispiel #6
0
        public static void register(String username, String pass)
        {
            Login login = new Login(username, pass);

            ServerProcessing.processSendMessage(MessageProccesing.CreateMessage(Options.CREATE_USER, login));
        }