DisableInput() public method

public DisableInput ( ) : void
return void
        public static void GotMessage(object peer)
        {
            NetClient s_client = peer as NetClient;
            //foreach (var s_client in s_clients) {
            NetIncomingMessage im;

            while ((im = s_client.ReadMessage()) != null)
            {
                // handle incoming message
                switch (im.MessageType)
                {
                case NetIncomingMessageType.DebugMessage:
                case NetIncomingMessageType.ErrorMessage:
                case NetIncomingMessageType.WarningMessage:
                case NetIncomingMessageType.VerboseDebugMessage:
                    string text = im.ReadString();
                    Output(s_client.Port.ToString() + " recevied:" + text);
                    break;

                case NetIncomingMessageType.StatusChanged:
                    NetConnectionStatus status = (NetConnectionStatus)im.ReadByte();

                    if (status == NetConnectionStatus.Connected)
                    {
                        s_form.EnableInput();
                    }
                    else
                    {
                        s_form.DisableInput();
                    }

                    if (status == NetConnectionStatus.Disconnected)
                    {
                        s_form.button2.Text = "Connect";
                    }

                    string reason = im.ReadString();
                    Output(status.ToString() + ": " + reason);

                    break;

                case NetIncomingMessageType.Data:
                    string chat = im.ReadString();
                    Output(s_client.Port.ToString() + " recevied:" + chat);
                    break;

                default:
                    Output("Unhandled type: " + im.MessageType + " " + im.LengthBytes + " bytes");
                    break;
                }
                s_client.Recycle(im);
                //}
            }
        }
Example #2
0
        private static void Application_Idle(object sender, EventArgs e)
        {
            while (NativeMethods.AppStillIdle)
            {
                NetIncomingMessage im;
                while ((im = s_client.ReadMessage()) != null)
                {
                    // handle incoming message
                    switch (im.MessageType)
                    {
                    case NetIncomingMessageType.DebugMessage:
                    case NetIncomingMessageType.ErrorMessage:
                    case NetIncomingMessageType.WarningMessage:
                    case NetIncomingMessageType.VerboseDebugMessage:
                        string text = im.ReadString();
                        Output(text);
                        break;

                    case NetIncomingMessageType.StatusChanged:
                        NetConnectionStatus status = (NetConnectionStatus)im.ReadByte();

                        if (status == NetConnectionStatus.Connected)
                        {
                            s_form.EnableInput();
                        }
                        else
                        {
                            s_form.DisableInput();
                        }
                        string reason = im.ReadString();
                        Output(status.ToString() + ": " + reason);

                        break;

                    case NetIncomingMessageType.Data:
                        string chat = im.ReadString();
                        Output(chat);
                        break;

                    default:
                        Output("Unhandled type: " + im.MessageType + " " + im.LengthBytes + " bytes");
                        break;
                    }
                }
                Thread.Sleep(1);
            }
        }