Пример #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //ServicePointManager.ServerCertificateValidationCallback += (from, cert, chain, sslPolicyErrors) =>
            //{
            //    LogMsg("HTTP Remote Certificate Validation Callback!");
            //    return true;
            //};

            m_Client = MessageClient.CreateNewClient();

            m_Client.SetClientId(1);
            m_Client.IsOrderlyProcess = true;

            m_Client.Events.OnHandshake  += OnConnect;
            m_Client.Events.OnDisconnect += OnDisconnect;
            m_Client.Events.OnError      += OnError;

            //m_Client.SetValidationCallback(new RemoteCertificateValidationCallback((from, cert, chain, policyErrors) =>
            //{
            //    LogMsg("WebSocket Remote Certificate Validation Callback!");
            //    return true;
            //}));

            m_Client.Handlers.AddHandler(new EnterLobbyHandler(this));
            m_Client.Handlers.AddHandler(new GetRoomListHandler(this));
            m_Client.Handlers.AddHandler(new CreateRoomHandler(this));
            m_Client.Handlers.AddHandler(new EnterRoomHandler(this));
            m_Client.Handlers.AddHandler(new ExitRoomHandler(this));
            m_Client.Handlers.AddHandler(new RoomMessageHandler(this));

            listRooms.Items.Clear();
            listUsers.Items.Clear();

            gbChatRoom.Enabled = false;
            gbLobby.Enabled    = false;
            gbLogin.Enabled    = true;

            timerAutoRelogin.Enabled = false;

            this.AcceptButton = btnSend;

            DisableEditing(cbbChatToWho);
        }