Exemplo n.º 1
0
 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (WebSocketsWrapper.IsConnected())
     {
         WebSocketsWrapper.Disconnect();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Called when a key is pressed in the broadcast box
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void textBoxBroadcast_KeyPress(object sender, KeyPressEventArgs e)
 {
     if ((ConsoleKey)e.KeyChar == ConsoleKey.Enter)
     {
         WebSocketsWrapper.Send($"say {textBoxBroadcast.Text}");
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Called when a key is pressed in the command box
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void textBoxCommand_KeyPress(object sender, KeyPressEventArgs e)
 {
     if ((ConsoleKey)e.KeyChar == ConsoleKey.Enter)
     {
         WebSocketsWrapper.SendCommand(textBoxCommand.Text);
     }
 }
Exemplo n.º 4
0
 public static void UpdatePlayers()
 {
     while (WebSocketsWrapper.IsConnected())
     {
         WebSocketsWrapper.SendCommand("playerlist");
         Thread.Sleep(TimeSpan.FromSeconds(10));
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Called when "Send" (command) button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonCommand_Click(object sender, EventArgs e)
 {
     WebSocketsWrapper.SendCommand(textBoxCommand.Text);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Called when "Disconnect" button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonDisconnect_Click(object sender, EventArgs e)
 {
     WebSocketsWrapper.Disconnect();
 }
Exemplo n.º 7
0
 /// <summary>
 /// Called when "Send" (broadcast) button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonBroadcast_Click(object sender, EventArgs e)
 {
     WebSocketsWrapper.Send($"say {textBoxBroadcast.Text}");
 }
Exemplo n.º 8
0
        /// <summary>
        /// Formats the string for the status text
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private static string FormatStatus(string text)
        {
            var connected = WebSocketsWrapper.IsConnected() ? "Connected" : "Disconnected";

            return($"{text} ({connected})");
        }