void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos, false, false);
                GUILayout.BeginVertical();

                if (signalRConnection.AuthenticationProvider == null)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Username (Enter 'User'):");
                    userName = GUILayout.TextField(userName, GUILayout.MinWidth(100));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Roles (Enter 'Invoker' or 'Admin'):");
                    role = GUILayout.TextField(role, GUILayout.MinWidth(100));
                    GUILayout.EndHorizontal();

                    if (GUILayout.Button("Log in"))
                    {
                        Restart();
                    }
                }

                for (int i = 0; i < signalRConnection.Hubs.Length; ++i)
                {
                    (signalRConnection.Hubs[i] as BaseHub).Draw();
                }

                GUILayout.EndVertical();
                GUILayout.EndScrollView();
            });
        }
Beispiel #2
0
 private void OnGUI()
 {
     GUIHelper.DrawArea(GUIHelper.ClientArea, true, (Action)(() =>
     {
         GUILayout.Label("Request status: " + this.status);
         GUILayout.Space(5f);
         GUILayout.Label(string.Format("Progress: {0:P2} of {1:N0}Mb", (object)this.progress, (object)(PlayerPrefs.GetInt("DownloadLength") / 1048576)));
         double num = (double)GUILayout.HorizontalSlider(this.progress, 0.0f, 1f);
         GUILayout.Space(50f);
         if (this.request == null)
         {
             GUILayout.Label(string.Format("Desired Fragment Size: {0:N} KBytes", (object)(float)((double)this.fragmentSize / 1024.0)));
             this.fragmentSize = (int)GUILayout.HorizontalSlider((float)this.fragmentSize, 4096f, 1.048576E+07f);
             GUILayout.Space(5f);
             if (!GUILayout.Button(!PlayerPrefs.HasKey("DownloadProgress") ? "Start Download" : "Continue Download"))
             {
                 return;
             }
             this.StreamLargeFileTest();
         }
         else
         {
             if (this.request.State != HTTPRequestStates.Processing || !GUILayout.Button("Abort Download"))
             {
                 return;
             }
             this.request.Abort();
         }
     }));
 }
 private void OnGUI()
 {
     GUIHelper.DrawArea(GUIHelper.ClientArea, true, delegate {
         GUILayout.Label("Request status: " + this.status, Array.Empty <GUILayoutOption>());
         GUILayout.Space(5f);
         GUILayout.Label($"Progress: {this.progress:P2} of {PlayerPrefs.GetInt("DownloadLength") / 0x100000:N0}Mb", Array.Empty <GUILayoutOption>());
         GUILayout.HorizontalSlider(this.progress, 0f, 1f, Array.Empty <GUILayoutOption>());
         GUILayout.Space(50f);
         if (this.request == null)
         {
             GUILayout.Label($"Desired Fragment Size: {((float) this.fragmentSize) / 1024f:N} KBytes", Array.Empty <GUILayoutOption>());
             this.fragmentSize = (int)GUILayout.HorizontalSlider((float)this.fragmentSize, 4096f, 1.048576E+07f, Array.Empty <GUILayoutOption>());
             GUILayout.Space(5f);
             string str = !PlayerPrefs.HasKey("DownloadProgress") ? "Start Download" : "Continue Download";
             if (GUILayout.Button(str, Array.Empty <GUILayoutOption>()))
             {
                 this.StreamLargeFileTest();
             }
         }
         else if ((this.request.State == HTTPRequestStates.Processing) && GUILayout.Button("Abort Download", Array.Empty <GUILayoutOption>()))
         {
             this.request.Abort();
         }
     });
 }
        void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos);

                // Draw out the textures
                GUILayout.SelectionGrid(0, Textures, 3);

#if !BESTHTTP_DISABLE_CACHING
                if (finishedCount == Images.Length && allDownloadedFromLocalCache)
                {
                    GUIHelper.DrawCenteredText("All images loaded from the local cache!");
                }
#endif

                GUILayout.FlexibleSpace();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Max Connection/Server: ", GUILayout.Width(150));
                GUILayout.Label(HTTPManager.MaxConnectionPerServer.ToString(), GUILayout.Width(20));
                HTTPManager.MaxConnectionPerServer = (byte)GUILayout.HorizontalSlider(HTTPManager.MaxConnectionPerServer, 1, 10);
                GUILayout.EndHorizontal();

                if (GUILayout.Button("Start Download"))
                {
                    DownloadImages();
                }

                GUILayout.EndScrollView();
            });
        }
 private void OnGUI()
 {
     GUIHelper.DrawArea(GUIHelper.ClientArea, true, (Action)(() =>
     {
         this.scrollPos = GUILayout.BeginScrollView(this.scrollPos);
         GUILayout.SelectionGrid(0, (Texture[])this.Textures, 3);
         if (this.finishedCount == this.Images.Length && this.allDownloadedFromLocalCache)
         {
             GUIHelper.DrawCenteredText("All images loaded from the local cache!");
         }
         GUILayout.FlexibleSpace();
         GUILayout.BeginHorizontal();
         GUILayout.Label("Max Connection/Server: ", new GUILayoutOption[1]
         {
             GUILayout.Width(150f)
         });
         GUILayout.Label(HTTPManager.MaxConnectionPerServer.ToString(), new GUILayoutOption[1]
         {
             GUILayout.Width(20f)
         });
         HTTPManager.MaxConnectionPerServer = (byte)GUILayout.HorizontalSlider((float)HTTPManager.MaxConnectionPerServer, 1f, 10f);
         GUILayout.EndHorizontal();
         if (GUILayout.Button("Start Download"))
         {
             this.DownloadImages();
         }
         GUILayout.EndScrollView();
     }));
 }
        void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                GUILayout.BeginHorizontal();

                if (GUILayout.Button("START") && signalRConnection.State != ConnectionStates.Connected)
                {
                    signalRConnection.Open();
                }

                if (GUILayout.Button("STOP") && signalRConnection.State == ConnectionStates.Connected)
                {
                    signalRConnection.Close();
                    messages.Clear();
                }

                if (GUILayout.Button("PING") && signalRConnection.State == ConnectionStates.Connected)
                {
                    // Call a Hub-method on the server.
                    signalRConnection["StatusHub"].Call("Ping");
                }

                GUILayout.EndHorizontal();

                GUILayout.Space(20);

                GUILayout.Label("Connection Status Messages");

                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                messages.Draw(Screen.width - 20, 0);
                GUILayout.EndHorizontal();
            });
        }
        private void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, (Action)(() =>
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Delete cached entities older then");
                GUILayout.Label(this.value.ToString(), new GUILayoutOption[1]
                {
                    GUILayout.MinWidth(50f)
                });
                this.value = (int)GUILayout.HorizontalSlider((float)this.value, 1f, 60f, GUILayout.MinWidth(100f));
                GUILayout.Space(10f);
                this.deleteOlderType = (CacheMaintenanceSample.DeleteOlderTypes)GUILayout.SelectionGrid((int)this.deleteOlderType, new string[4]
                {
                    "Days",
                    "Hours",
                    "Mins",
                    "Secs"
                }, 4);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.Space(10f);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Max Cache Size (bytes): ", new GUILayoutOption[1]
                {
                    GUILayout.Width(150f)
                });
                GUILayout.Label(this.maxCacheSize.ToString("N0"), new GUILayoutOption[1]
                {
                    GUILayout.Width(70f)
                });
                this.maxCacheSize = (int)GUILayout.HorizontalSlider((float)this.maxCacheSize, 1024f, 1.048576E+07f);
                GUILayout.EndHorizontal();
                GUILayout.Space(10f);
                if (!GUILayout.Button("Maintenance"))
                {
                    return;
                }
                TimeSpan deleteOlder = TimeSpan.FromDays(14.0);
                switch (this.deleteOlderType)
                {
                case CacheMaintenanceSample.DeleteOlderTypes.Days:
                    deleteOlder = TimeSpan.FromDays((double)this.value);
                    break;

                case CacheMaintenanceSample.DeleteOlderTypes.Hours:
                    deleteOlder = TimeSpan.FromHours((double)this.value);
                    break;

                case CacheMaintenanceSample.DeleteOlderTypes.Mins:
                    deleteOlder = TimeSpan.FromMinutes((double)this.value);
                    break;

                case CacheMaintenanceSample.DeleteOlderTypes.Secs:
                    deleteOlder = TimeSpan.FromSeconds((double)this.value);
                    break;
                }
                HTTPCacheService.BeginMaintainence(new HTTPCacheMaintananceParams(deleteOlder, (ulong)this.maxCacheSize));
            }));
        }
        void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                GUILayout.Label("Messages");

                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                messages.Draw(Screen.width - 20, 0);
                GUILayout.EndHorizontal();
            });
        }
Beispiel #9
0
        // Draw the text stored in the 'uiText' field
        void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos, false, false);
                GUILayout.BeginVertical();

                GUILayout.Label(uiText);

                GUILayout.EndVertical();
                GUILayout.EndScrollView();
            });
        }
        /// <summary>
        /// Called from an OnGUI event to draw the Chat Screen.
        /// </summary>
        void DrawChatScreen()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                GUILayout.BeginVertical();
                scrollPos = GUILayout.BeginScrollView(scrollPos);
                GUILayout.Label(chatLog, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                GUILayout.EndScrollView();

                string typing = string.Empty;

                if (typingUsers.Count > 0)
                {
                    typing += string.Format("{0}", typingUsers[0]);

                    for (int i = 1; i < typingUsers.Count; ++i)
                    {
                        typing += string.Format(", {0}", typingUsers[i]);
                    }

                    if (typingUsers.Count == 1)
                    {
                        typing += " is typing!";
                    }
                    else
                    {
                        typing += " are typing!";
                    }
                }

                GUILayout.Label(typing);

                GUILayout.Label("Type here:");

                GUILayout.BeginHorizontal();
                message = GUILayout.TextField(message);

                if (GUILayout.Button("Send", GUILayout.MaxWidth(100)))
                {
                    SendMessage();
                }
                GUILayout.EndHorizontal();

                if (GUI.changed)
                {
                    UpdateTyping();
                }

                GUILayout.EndVertical();
            });
        }
Beispiel #11
0
        void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
#if !BESTHTTP_DISABLE_CACHING && (!UNITY_WEBGL || UNITY_EDITOR)
                GUILayout.BeginHorizontal();

                GUILayout.Label("Delete cached entities older then");

                GUILayout.Label(value.ToString(), GUILayout.MinWidth(50));
                value = (int)GUILayout.HorizontalSlider(value, 1, 60, GUILayout.MinWidth(100));

                GUILayout.Space(10);

                deleteOlderType = (DeleteOlderTypes)(int)GUILayout.SelectionGrid((int)deleteOlderType, new string[] { "Days", "Hours", "Mins", "Secs" }, 4);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.Space(10);

                GUILayout.BeginHorizontal();
                GUILayout.Label("Max Cache Size (bytes): ", GUILayout.Width(150));
                GUILayout.Label(maxCacheSize.ToString("N0"), GUILayout.Width(70));
                maxCacheSize = (int)GUILayout.HorizontalSlider(maxCacheSize, 1024, 10 * 1024 * 1024);
                GUILayout.EndHorizontal();

                GUILayout.Space(10);

                if (GUILayout.Button("Maintenance"))
                {
                    TimeSpan deleteOlder = TimeSpan.FromDays(14);

                    switch (deleteOlderType)
                    {
                    case DeleteOlderTypes.Days: deleteOlder = TimeSpan.FromDays(value); break;

                    case DeleteOlderTypes.Hours: deleteOlder = TimeSpan.FromHours(value); break;

                    case DeleteOlderTypes.Mins: deleteOlder = TimeSpan.FromMinutes(value); break;

                    case DeleteOlderTypes.Secs: deleteOlder = TimeSpan.FromSeconds(value); break;
                    }

                    // Call the BeginMaintainence function. It will run on a thread to do not block the main thread.
                    HTTPCacheService.BeginMaintainence(new HTTPCacheMaintananceParams(deleteOlder, (ulong)maxCacheSize));
                }
#endif
            });
        }
        private void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, delegate {
                GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>());
                GUILayout.Label("Delete cached entities older then", Array.Empty <GUILayoutOption>());
                GUILayoutOption[] optionArray1 = new GUILayoutOption[] { GUILayout.MinWidth(50f) };
                GUILayout.Label(this.value.ToString(), optionArray1);
                GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.MinWidth(100f) };
                this.value = (int)GUILayout.HorizontalSlider((float)this.value, 1f, 60f, optionArray2);
                GUILayout.Space(10f);
                string[] textArray1  = new string[] { "Days", "Hours", "Mins", "Secs" };
                this.deleteOlderType = (DeleteOlderTypes)GUILayout.SelectionGrid((int)this.deleteOlderType, textArray1, 4, Array.Empty <GUILayoutOption>());
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.Space(10f);
                GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>());
                GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width(150f) };
                GUILayout.Label("Max Cache Size (bytes): ", optionArray3);
                GUILayoutOption[] optionArray4 = new GUILayoutOption[] { GUILayout.Width(70f) };
                GUILayout.Label(this.maxCacheSize.ToString("N0"), optionArray4);
                this.maxCacheSize = (int)GUILayout.HorizontalSlider((float)this.maxCacheSize, 1024f, 1.048576E+07f, Array.Empty <GUILayoutOption>());
                GUILayout.EndHorizontal();
                GUILayout.Space(10f);
                if (GUILayout.Button("Maintenance", Array.Empty <GUILayoutOption>()))
                {
                    TimeSpan deleteOlder = TimeSpan.FromDays(14.0);
                    switch (this.deleteOlderType)
                    {
                    case DeleteOlderTypes.Days:
                        deleteOlder = TimeSpan.FromDays((double)this.value);
                        break;

                    case DeleteOlderTypes.Hours:
                        deleteOlder = TimeSpan.FromHours((double)this.value);
                        break;

                    case DeleteOlderTypes.Mins:
                        deleteOlder = TimeSpan.FromMinutes((double)this.value);
                        break;

                    case DeleteOlderTypes.Secs:
                        deleteOlder = TimeSpan.FromSeconds((double)this.value);
                        break;
                    }
                    HTTPCacheService.BeginMaintainence(new HTTPCacheMaintananceParams(deleteOlder, (ulong)this.maxCacheSize));
                }
            });
        }
Beispiel #13
0
        void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos);
                GUILayout.Label(Text);
                GUILayout.EndScrollView();

                GUILayout.Space(5);

                GUILayout.FlexibleSpace();

                address = GUILayout.TextField(address);

                if (this.eventSource == null && GUILayout.Button("Open Server-Sent Events"))
                {
                    // Create the EventSource instance
                    this.eventSource = new EventSource(new Uri(this.address));

                    // Subscribe to generic events
                    this.eventSource.OnOpen         += OnOpen;
                    this.eventSource.OnClosed       += OnClosed;
                    this.eventSource.OnError        += OnError;
                    this.eventSource.OnStateChanged += this.OnStateChanged;
                    this.eventSource.OnMessage      += OnMessage;

                    // Subscribe to an application specific event
                    this.eventSource.On("datetime", OnDateTime);

                    // Start to connect to the server
                    this.eventSource.Open();

                    Text += "Opening Server-Sent Events...\n";
                }

                if (this.eventSource != null && this.eventSource.State == States.Open)
                {
                    GUILayout.Space(10);

                    if (GUILayout.Button("Close"))
                    {
                        // Close the connection
                        this.eventSource.Close();
                    }
                }
            });
        }
        /// <summary>
        /// Called from an OnGUI event to draw the Login Screen.
        /// </summary>
        void DrawLoginScreen()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                GUILayout.BeginVertical();
                GUILayout.FlexibleSpace();

                GUIHelper.DrawCenteredText("What's your nickname?");
                userName = GUILayout.TextField(userName);

                if (GUILayout.Button("Join"))
                {
                    SetUserName();
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
            });
        }
Beispiel #15
0
 // Token: 0x060023E1 RID: 9185 RVA: 0x000B2BF0 File Offset: 0x000B0FF0
 private void OnGUI()
 {
     GUIHelper.DrawArea(GUIHelper.ClientArea, true, delegate
     {
         GUILayout.Label("Status: " + this.status, new GUILayoutOption[0]);
         if (this.texture != null)
         {
             GUILayout.Box(this.texture, new GUILayoutOption[]
             {
                 GUILayout.MaxHeight(256f)
             });
         }
         if (!this.downloading && GUILayout.Button("Start Download", new GUILayoutOption[0]))
         {
             this.UnloadBundle();
             base.StartCoroutine(this.DownloadAssetBundle());
         }
     });
 }
Beispiel #16
0
        void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                GUILayout.Label("Status: " + status);

                // Draw the texture from the downloaded bundle
                if (texture != null)
                {
                    GUILayout.Box(texture, GUILayout.MaxHeight(256));
                }

                if (!downloading && GUILayout.Button("Start Download"))
                {
                    UnloadBundle();

                    StartCoroutine(DownloadAssetBundle());
                }
            });
        }
        void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos, false, false);
                GUILayout.BeginVertical();

                demoHub.Draw();

                typedDemoHub.Draw();

                GUILayout.Label("Read State Value");
                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                GUILayout.Label(vbReadStateResult);
                GUILayout.EndHorizontal();

                GUILayout.Space(10);

                GUILayout.EndVertical();
                GUILayout.EndScrollView();
            });
        }
        void OnGUI()
        {
            switch (State)
            {
            case States.Connecting:
                GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
                {
                    GUILayout.BeginVertical();
                    GUILayout.FlexibleSpace();
                    GUIHelper.DrawCenteredText("Connecting to the server...");
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();
                });
                break;

            case States.WaitForNick:
                GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
                {
                    DrawLoginScreen();
                });
                break;

            case States.Joined:
                GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
                {
                    // Draw Texture
                    if (FrameTexture != null)
                    {
                        GUILayout.Box(FrameTexture);
                    }

                    DrawControls();
                    DrawChat();
                });
                break;
            }
        }
        void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                // Draw the current status
                GUILayout.Label("Request status: " + status);

                GUILayout.Space(5);

                // Draw the current progress
                GUILayout.Label(string.Format("Progress: {0:P2} of {1:N0}Mb", progress, PlayerPrefs.GetInt("DownloadLength") / 1048576 /*1 Mb*/));
                GUILayout.HorizontalSlider(progress, 0, 1);

                GUILayout.Space(50);

                if (request == null)
                {
                    // Draw a slider to be able to change the fragment size
                    GUILayout.Label(string.Format("Desired Fragment Size: {0:N} KBytes", fragmentSize / 1024f));
                    fragmentSize = (int)GUILayout.HorizontalSlider(fragmentSize, HTTPResponse.MinBufferSize, 10 * 1024 * 1024);

                    GUILayout.Space(5);

                    string buttonStr = PlayerPrefs.HasKey("DownloadProgress") ? "Continue Download" : "Start Download";
                    if (GUILayout.Button(buttonStr))
                    {
                        StreamLargeFileTest();
                    }
                }
                else if (request.State == HTTPRequestStates.Processing && GUILayout.Button("Abort Download"))
                {
                    // Simulate a connection lost
                    request.Abort();
                }
            });
        }
 private void OnGUI()
 {
     GUIHelper.DrawArea(GUIHelper.ClientArea, true, delegate {
         this.scrollPos = GUILayout.BeginScrollView(this.scrollPos, Array.Empty <GUILayoutOption>());
         GUILayout.SelectionGrid(0, this.Textures, 3, Array.Empty <GUILayoutOption>());
         if ((this.finishedCount == this.Images.Length) && this.allDownloadedFromLocalCache)
         {
             GUIHelper.DrawCenteredText("All images loaded from the local cache!");
         }
         GUILayout.FlexibleSpace();
         GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>());
         GUILayoutOption[] optionArray1 = new GUILayoutOption[] { GUILayout.Width(150f) };
         GUILayout.Label("Max Connection/Server: ", optionArray1);
         GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(20f) };
         GUILayout.Label(HTTPManager.MaxConnectionPerServer.ToString(), optionArray2);
         HTTPManager.MaxConnectionPerServer = (byte)GUILayout.HorizontalSlider((float)HTTPManager.MaxConnectionPerServer, 1f, 10f, Array.Empty <GUILayoutOption>());
         GUILayout.EndHorizontal();
         if (GUILayout.Button("Start Download", Array.Empty <GUILayoutOption>()))
         {
             this.DownloadImages();
         }
         GUILayout.EndScrollView();
     });
 }
        /// <summary>
        /// Draw the gui.
        /// Get input strings.
        /// Handle function calls.
        /// </summary>
        void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                GUILayout.BeginVertical();

                #region To Everybody
                GUILayout.Label("To Everybody");

                GUILayout.BeginHorizontal();

                ToEveryBodyText = GUILayout.TextField(ToEveryBodyText, GUILayout.MinWidth(100));

                if (GUILayout.Button("Broadcast"))
                {
                    Broadcast(ToEveryBodyText);
                }

                if (GUILayout.Button("Broadcast (All Except Me)"))
                {
                    BroadcastExceptMe(ToEveryBodyText);
                }

                if (GUILayout.Button("Enter Name"))
                {
                    EnterName(ToEveryBodyText);
                }

                if (GUILayout.Button("Join Group"))
                {
                    JoinGroup(ToEveryBodyText);
                }

                if (GUILayout.Button("Leave Group"))
                {
                    LeaveGroup(ToEveryBodyText);
                }

                GUILayout.EndHorizontal();
                #endregion

                #region To Me
                GUILayout.Label("To Me");

                GUILayout.BeginHorizontal();

                ToMeText = GUILayout.TextField(ToMeText, GUILayout.MinWidth(100));

                if (GUILayout.Button("Send to me"))
                {
                    SendToMe(ToMeText);
                }

                GUILayout.EndHorizontal();
                #endregion

                #region Private Message
                GUILayout.Label("Private Message");

                GUILayout.BeginHorizontal();

                GUILayout.Label("Message:");
                PrivateMessageText = GUILayout.TextField(PrivateMessageText, GUILayout.MinWidth(100));

                GUILayout.Label("User or Group name:");
                PrivateMessageUserOrGroupName = GUILayout.TextField(PrivateMessageUserOrGroupName, GUILayout.MinWidth(100));

                if (GUILayout.Button("Send to user"))
                {
                    SendToUser(PrivateMessageUserOrGroupName, PrivateMessageText);
                }

                if (GUILayout.Button("Send to group"))
                {
                    SendToGroup(PrivateMessageUserOrGroupName, PrivateMessageText);
                }

                GUILayout.EndHorizontal();
                #endregion

                GUILayout.Space(20);

                if (signalRConnection.State == ConnectionStates.Closed)
                {
                    if (GUILayout.Button("Start Connection"))
                    {
                        signalRConnection.Open();
                    }
                }
                else if (GUILayout.Button("Stop Connection"))
                {
                    signalRConnection.Close();
                }

                GUILayout.Space(20);

                // Draw the messages
                GUILayout.Label("Messages");

                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                messages.Draw(Screen.width - 20, 0);
                GUILayout.EndHorizontal();

                GUILayout.EndVertical();
            });
        }
Beispiel #22
0
        void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos);
                GUILayout.Label(Text);
                GUILayout.EndScrollView();

                GUILayout.Space(5);

                GUILayout.FlexibleSpace();

                address = GUILayout.TextField(address);

                if (webSocket == null && GUILayout.Button("Open Web Socket"))
                {
                    // Create the WebSocket instance
                    webSocket = new WebSocket.WebSocket(new Uri(address));

#if !UNITY_WEBGL
                    webSocket.StartPingThread = true;

#if !BESTHTTP_DISABLE_PROXY
                    if (HTTPManager.Proxy != null)
                    {
                        webSocket.InternalRequest.Proxy = new HTTPProxy(HTTPManager.Proxy.Address, HTTPManager.Proxy.Credentials, false);
                    }
#endif
#endif

                    // Subscribe to the WS events
                    webSocket.OnOpen    += OnOpen;
                    webSocket.OnMessage += OnMessageReceived;
                    webSocket.OnClosed  += OnClosed;
                    webSocket.OnError   += OnError;

                    // Start connecting to the server
                    webSocket.Open();

                    Text += "Opening Web Socket...\n";
                }

                if (webSocket != null && webSocket.IsOpen)
                {
                    GUILayout.Space(10);

                    GUILayout.BeginHorizontal();
                    msgToSend = GUILayout.TextField(msgToSend);

                    GUILayout.EndHorizontal();

                    if (GUILayout.Button("Send", GUILayout.MaxWidth(70)))
                    {
                        Text += "Sending message...\n";

                        // Send message to the server
                        webSocket.Send(msgToSend);
                    }

                    GUILayout.Space(10);

                    if (GUILayout.Button("Close"))
                    {
                        // Close the connection
                        webSocket.Close(1000, "Bye!");
                    }
                }
            });
        }
Beispiel #23
0
        void OnGUI()
        {
            var stats = HTTPManager.GetGeneralStatistics(StatisticsQueryFlags.All);

            // Connection statistics
            GUIHelper.DrawArea(new Rect(0, 0, Screen.width / 3, statisticsHeight), false, () =>
            {
                // Header
                GUIHelper.DrawCenteredText("Connections");

                GUILayout.Space(5);

                GUIHelper.DrawRow("Sum:", stats.Connections.ToString());
                GUIHelper.DrawRow("Active:", stats.ActiveConnections.ToString());
                GUIHelper.DrawRow("Free:", stats.FreeConnections.ToString());
                GUIHelper.DrawRow("Recycled:", stats.RecycledConnections.ToString());
                GUIHelper.DrawRow("Requests in queue:", stats.RequestsInQueue.ToString());
            });

            // Cache statistics
            GUIHelper.DrawArea(new Rect(Screen.width / 3, 0, Screen.width / 3, statisticsHeight), false, () =>
            {
                GUIHelper.DrawCenteredText("Cache");

#if !BESTHTTP_DISABLE_CACHING
                if (!BestHTTP.Caching.HTTPCacheService.IsSupported)
                {
#endif
                GUI.color = Color.yellow;
                GUIHelper.DrawCenteredText("Disabled in WebPlayer, WebGL & Samsung Smart TV Builds!");
                GUI.color = Color.white;
#if !BESTHTTP_DISABLE_CACHING
            }
                               else
            {
                GUILayout.Space(5);

                GUIHelper.DrawRow("Cached entities:", stats.CacheEntityCount.ToString());
                GUIHelper.DrawRow("Sum Size (bytes): ", stats.CacheSize.ToString("N0"));

                GUILayout.BeginVertical();

                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Clear Cache"))
                {
                    BestHTTP.Caching.HTTPCacheService.BeginClear();
                }

                GUILayout.EndVertical();
            }
#endif
            });

            // Cookie statistics
            GUIHelper.DrawArea(new Rect((Screen.width / 3) * 2, 0, Screen.width / 3, statisticsHeight), false, () =>
            {
                GUIHelper.DrawCenteredText("Cookies");

#if !BESTHTTP_DISABLE_COOKIES
                if (!BestHTTP.Cookies.CookieJar.IsSavingSupported)
                {
#endif
                GUI.color = Color.yellow;
                GUIHelper.DrawCenteredText("Saving and loading from disk is disabled in WebPlayer, WebGL & Samsung Smart TV Builds!");
                GUI.color = Color.white;
#if !BESTHTTP_DISABLE_COOKIES
            }
                               else
            {
                GUILayout.Space(5);

                GUIHelper.DrawRow("Cookies:", stats.CookieCount.ToString());
                GUIHelper.DrawRow("Estimated size (bytes):", stats.CookieJarSize.ToString("N0"));

                GUILayout.BeginVertical();

                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Clear Cookies"))
                {
                    BestHTTP.Cookies.CookieJar.Clear();
                }

                GUILayout.EndVertical();
            }
#endif
            });

            if (SelectedSample == null || (SelectedSample != null && !SelectedSample.IsRunning))
            {
                // Draw the list of samples
                GUIHelper.DrawArea(new Rect(0, statisticsHeight + 5, SelectedSample == null ? Screen.width : Screen.width / 3, Screen.height - statisticsHeight - 5), false, () =>
                {
                    scrollPos = GUILayout.BeginScrollView(scrollPos);
                    for (int i = 0; i < Samples.Count; ++i)
                    {
                        DrawSample(Samples[i]);
                    }
                    GUILayout.EndScrollView();
                });

                if (SelectedSample != null)
                {
                    DrawSampleDetails(SelectedSample);
                }
            }
            else if (SelectedSample != null && SelectedSample.IsRunning)
            {
                GUILayout.BeginArea(new Rect(0, Screen.height - 50, Screen.width, 50), string.Empty);
                GUILayout.FlexibleSpace();
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                GUILayout.BeginVertical();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Back", GUILayout.MinWidth(100)))
                {
                    SelectedSample.DestroyUnityObject();
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
                GUILayout.EndArea();
            }
        }