Exemplo n.º 1
0
 public WndMain()
 {
     InitializeComponent();
     cClient             = new CClient();
     cClient.LoginOK    += new EventHandler(cOnLoginOk);    //Das Event "subscriben"
     cClient.LoginNotOk += new EventHandler(cOnLoginNotOk); //Das Event "subscriben"
 }
Exemplo n.º 2
0
        int[] selectedContact; //index des zuletzt und des neu ausgewählten Kontakts

        public WndChat(CClient cClient)
        {
            InitializeComponent();
            selectedContact    = new int[2];
            selectedContact[1] = 99; // zur Initialisierung müssen zwei unterschiedliche Werte vorhanden sein.


            foreach (User user in cClient.contactList.listContacts)
            {
                UserControlContactItem contact = new UserControlContactItem(user.Email, user.Status, user.NewMessages, user.FsName);
                lvContacts.Items.Add(contact);
            }

            #region Kontrollelemente zum Senden einer Nachricht verstecken
            btnSendMessage.Visibility = Visibility.Hidden;
            txtMessage.Visibility     = Visibility.Hidden;
            splChat.Children.Add(new UserControlMessageSent("Bitte wählen Sie einen Chat aus, um eine Unterhaltung zu beginnen", " "));
            #endregion

            #region EventListener
            this.Closing                 += ManageClosing; //Wenn der User das Fenster schließen möchte
            cClient.RefreshContacts      += new EventHandler(ReloadContacts);
            this.cClient                  = cClient;
            receivedHandler               = new CReceivedEventHandler(cMessageReceived);//TODO: Recherchieren "Wie übergebe ich mit einem Event Parameter ?"
            this.cClient.MessageReceived += receivedHandler;
            this.cClient.ChatReceived    += CClient_ChatReceived;
            this.cClient.AddContactWrong += CClient_AddContactWrong;
            #endregion
        }
Exemplo n.º 3
0
        public WndRegistration()
        {
            InitializeComponent();

            cClient = new CClient();
            cClient.RegistrationOK    += new EventHandler(cOnRegistrationOK);
            cClient.RegistrationNotOk += new EventHandler(cOnRegistrationNotOK);
            cClient.LoginNotOk        += new EventHandler(cOnLoginNotOk);
        }
Exemplo n.º 4
0
 public ClientAPI(CClient client)
 {
     _client = client;
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            // 클라이언트 처리 클래스 생성
            CClient Client = new CClient();


            PutCommandList();


            // 비동기 방식으로 명령어를 입력받습니다
            var ret = NetCommon.Common.ReadLineAsync();


            // 프로그램 반복 실행을 위해...
            bool run_program = true;


            // 프로그램 종료시까지 명령어 받고.. 네트워크 관련 처리하고.. 무한 반복
            while (run_program)
            {
                if (ret.IsCompleted)
                {
                    switch (ret.Result)
                    {
                    case "/c":
                        // 서버로 접속을 시도합니다
                        if (Client.server_now < UnityCommon.Server.Login)
                        {
                            // 최초 로그인 시도인 경우
                            Client.m_Core.Connect(UnityCommon.Join.ipaddr, UnityCommon.Join.portnum, UnityCommon.Join.protocol_ver);
                            Console.WriteLine("Connect to server ({0}:{1}) ...", UnityCommon.Join.ipaddr, UnityCommon.Join.portnum);
                        }
                        else
                        {
                            // 재접속을 시도하는 경우
                            Client.m_Core.ReConnect(UnityCommon.Join.ipaddr, UnityCommon.Join.portnum);
                        }
                        break;

                    case "/q":
                        // 서버에서 퇴장합니다
                        Client.m_Core.Leave();
                        break;

                    case "/exit":
                        // 콘솔 프로그램을 종료합니다
                        run_program = false;
                        break;

                    case "/h":
                        // 명령어 도움말 출력
                        PutCommandList();
                        break;


                    case "/login":
                        // 로그인 서버로 이동 요청
                        if (Client.server_now != UnityCommon.Server.None)     // 서버에 연결되있을때만 패킷을 보내기 위해
                        {
                            Client.server_tag = UnityCommon.Server.Login;
                            Client.proxy.server_move(ZNet.RemoteID.Remote_Server, ZNet.CPackOption.Basic, (int)Client.server_tag);
                        }
                        break;

                    case "/lobby":
                        // 로비 서버로 이동 요청
                        if (Client.server_now != UnityCommon.Server.None)     // 서버에 연결되있을때만 패킷을 보내기 위해
                        {
                            Client.server_tag = UnityCommon.Server.Lobby;
                            Client.proxy.server_move(ZNet.RemoteID.Remote_Server, ZNet.CPackOption.Basic, (int)Client.server_tag);
                        }
                        break;

                    case "/room":
                        // 룸 서버로 이동 요청
                        if (Client.server_now != UnityCommon.Server.None)     // 서버에 연결되있을때만 패킷을 보내기 위해
                        {
                            Client.server_tag = UnityCommon.Server.Room;
                            Client.proxy.server_move(ZNet.RemoteID.Remote_Server, ZNet.CPackOption.Basic, (int)Client.server_tag);
                        }
                        break;

                    default:
                        if (Client.server_now != UnityCommon.Server.None)     // 서버에 연결되있을때만 패킷을 보내기 위해
                        {
                            Client.proxy.Chat(ZNet.RemoteID.Remote_Server, ZNet.CPackOption.Basic, ret.Result);
                        }
                        else
                        {
                            Console.WriteLine("/c 로 서버에 먼저 연결하세요");
                        }
                        break;
                    }

                    if (run_program)
                    {
                        ret = NetCommon.Common.ReadLineAsync();
                    }
                }

                Client.m_Core.NetLoop();
                System.Threading.Thread.Sleep(1);
            }

            Client.m_Core.Destroy();
            System.Threading.Thread.Sleep(1000 * 2);
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args">
        ///     args[0]->username
        ///     args[1]->clientUrl
        ///     args[2]->serverUrl
        ///     args[3]->scriptFile
        ///     args[4]->nBackupServers
        ///     args[5:5+args[4]]->backupServer
        ///     (optional)
        ///     args[5+args[4]:]->otherClientsUrls
        /// </param>
        static void Main(string[] args)
        {
            CClient client;

            List <string> backupServers  = new List <string>();
            int           nBackupServers = Int32.Parse(args[4]);
            int           i = 0;

            for (i = 5; i < 5 + nBackupServers; i++)
            {
                backupServers.Add(args[i]);
            }

            if (args.Length > 5 + nBackupServers)
            {
                int           nClients        = Int32.Parse(args[5 + nBackupServers + 1]);
                List <string> otherClientsUrl = new List <string>();
                for (; i < 5 + nBackupServers + nClients; i++)
                {
                    otherClientsUrl.Add(args[i]);
                }
                client = new CClient(args[0], args[1], args[2], backupServers, otherClientsUrl);
            }
            else
            {
                client = new CClient(args[0], args[1], args[2], backupServers);
            }

            string       scriptPath   = args[3];
            ScriptClient scriptClient = new ScriptClient(client);

            string[] lines = System.IO.File.ReadAllLines(@scriptPath);

            Console.WriteLine("Press s for executing commands sequentially and n for executing step by step");
            string mode = Console.ReadLine();

            // sequentially
            if (mode.Equals("s"))
            {
                foreach (string line in lines)
                {
                    Console.WriteLine(line);
                    scriptClient.ReceiveCommand(line);
                }
            }
            // step by step
            else if (mode.Equals("n"))
            {
                foreach (string line in lines)
                {
                    scriptClient.ReceiveCommand(line);
                    Console.WriteLine("Enter for next command");
                    Console.ReadLine();
                }
            }

            // accepts command-line commands
            string command = "";

            while (!command.Equals("shutdown"))
            {
                scriptClient.PrintGUI();
                command = Console.ReadLine();
                scriptClient.ReceiveCommand(command);
            }
        }
Exemplo n.º 7
0
 public ScriptClient(CClient client) : base(client)
 {
 }